本文整理匯總了PHP中item_type2str函數的典型用法代碼示例。如果您正苦於以下問題:PHP item_type2str函數的具體用法?PHP item_type2str怎麽用?PHP item_type2str使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了item_type2str函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: CSpan
// item key
$itemKey = $item['type'] == ITEM_TYPE_HTTPTEST || $item['flags'] == ZBX_FLAG_DISCOVERY_CREATED ? new CSpan($item['key_expanded'], 'enabled') : new CLink($item['key_expanded'], 'items.php?form=update&itemid=' . $item['itemid'], 'enabled');
// info
if ($item['status'] == ITEM_STATUS_ACTIVE && $item['error'] !== '') {
$info = new CDiv(null, 'status_icon iconerror');
$info->setHint($item['error'], 'on');
} else {
$info = '';
}
// trend value
if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
$trendValue = $config['hk_trends_global'] ? $config['hk_trends'] : $item['trends'];
} else {
$trendValue = UNKNOWN_VALUE;
}
$row = new CRow(array('', $checkbox, $hostColumn, new CCol(new CDiv(array($item['name_expanded'], BR(), $itemKey), $stateCss . ' item')), new CCol(new CSpan($item['type'] == ITEM_TYPE_SNMPTRAP || $item['type'] == ITEM_TYPE_TRAPPER ? UNKNOWN_VALUE : $item['delay'], $stateCss)), new CCol(new CSpan($config['hk_history_global'] ? $config['hk_history'] : $item['history'], $stateCss)), new CCol(new CSpan($trendValue, $stateCss)), new CCol(new CSpan(item_type2str($item['type']), $stateCss)), new CCol(new CSpan($lastClock, $stateCss)), new CCol(new CSpan($lastValue, $stateCss)), new CCol(new CSpan($change, $stateCss)), new CCol($actions, $stateCss), $info));
} else {
$row = new CRow(array('', $checkbox, $hostColumn, new CCol(new CSpan($item['name_expanded'], $stateCss . ' item')), new CCol(new CSpan($lastClock, $stateCss)), new CCol(new CSpan($lastValue, $stateCss)), new CCol(new CSpan($change, $stateCss)), new CCol($actions, $stateCss)));
}
$hosts[$item['hostid']]['item_cnt']++;
$tab_rows[$item['hostid']][] = $row;
}
foreach ($hosts as $hostId => $dbHost) {
$host = $hosts[$dbHost['hostid']];
if (!isset($tab_rows[$hostId])) {
continue;
}
$appRows = $tab_rows[$hostId];
$openState = CProfile::get('web.latest.toggle_other', null, $host['hostid']);
$toggle = new CDiv(null, 'app-list-toggle icon-plus-9x9');
if ($openState) {
示例2: CDiv
$error = '';
if ($discovery['status'] == ITEM_STATUS_ACTIVE) {
if (zbx_empty($discovery['error'])) {
$error = new CDiv(SPACE, 'status_icon iconok');
} else {
$error = new CDiv(SPACE, 'status_icon iconerror');
$error->setHint($discovery['error'], '', 'on');
}
}
}
// host prototype link
$hostPrototypeLink = null;
if ($data['host']['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
$hostPrototypeLink = array(new CLink(_('Host prototypes'), 'host_prototypes.php?parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['hostPrototypes'] . ')');
}
$discoveryTable->addRow(array(new CCheckBox('g_hostdruleid[' . $discovery['itemid'] . ']', null, null, $discovery['itemid']), $description, array(new CLink(_('Item prototypes'), 'disc_prototypes.php?hostid=' . get_request('hostid') . '&parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['items'] . ')'), array(new CLink(_('Trigger prototypes'), 'trigger_prototypes.php?hostid=' . get_request('hostid') . '&parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['triggers'] . ')'), array(new CLink(_('Graph prototypes'), 'graphs.php?hostid=' . get_request('hostid') . '&parent_discoveryid=' . $discovery['itemid']), ' (' . $discovery['graphs'] . ')'), $hostPrototypeLink, $discovery['key_'], $discovery['delay'], item_type2str($discovery['type']), $status, $data['showErrorColumn'] ? $error : null));
}
// create go buttons
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected discovery rules?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected discovery rules?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected discovery rules?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "g_hostdruleid";');
示例3: foreach
foreach ($item['triggers'] as $trigger) {
foreach ($trigger['functions'] as $function) {
if (!str_in_array($function['function'], array('regexp', 'iregexp'))) {
continue 2;
}
}
$triggers[] = array('id' => $trigger['triggerid'], 'name' => $trigger['description']);
}
$menuIcon = new CIcon(_('Menu'), 'iconmenu_b');
$menuIcon->setMenuPopup(CMenuPopupHelper::getTriggerLog($item['itemid'], $item['name'], $triggers));
} else {
$menuIcon = SPACE;
}
$checkBox = new CCheckBox('group_itemid[' . $item['itemid'] . ']', null, null, $item['itemid']);
$checkBox->setEnabled(empty($item['discoveryRule']));
$itemTable->addRow(array($checkBox, $menuIcon, empty($this->data['filter_hostid']) ? $item['host'] : null, $description, $triggerInfo, CHtml::encode($item['key_']), $item['type'] == ITEM_TYPE_TRAPPER || $item['type'] == ITEM_TYPE_SNMPTRAP ? '' : $item['delay'], $item['history'], in_array($item['value_type'], array(ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_TEXT)) ? '' : $item['trends'], item_type2str($item['type']), new CCol(CHtml::encode($item['applications_list']), 'wraptext'), $status, $infoIcons));
}
// create go buttons
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('item.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected items?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected items?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.massupdateform', _('Mass update'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.masscopyto', _('Copy selected to ...'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.massclearhistory', _('Clear history for selected'));
$goOption->setAttribute('confirm', _('Delete history of selected items?'));
示例4: foreach
if ($now - $row["nextcheck"] <= 300) {
$sec_300[$row["type"]]++;
} else {
if ($now - $row["nextcheck"] <= 600) {
$sec_600[$row["type"]]++;
} else {
$sec_rest[$row["type"]]++;
}
}
}
}
}
}
$table->setHeader(array(S_ITEMS, S_5_SECONDS, S_10_SECONDS, S_30_SECONDS, S_1_MINUTE, S_5_MINUTES, S_MORE_THAN_10_MINUTES));
foreach ($item_types as $type) {
$elements = array(item_type2str($type), new CCol($sec_10[$type], $sec_10[$type] ? "unknown_trigger" : "normal"), new CCol($sec_30[$type], $sec_30[$type] ? "information" : "normal"), new CCol($sec_60[$type], $sec_60[$type] ? "warning" : "normal"), new CCol($sec_300[$type], $sec_300[$type] ? "average" : "normal"), new CCol($sec_600[$type], $sec_600[$type] ? "high" : "normal"), new CCol($sec_rest[$type], $sec_rest[$type] ? "disaster" : "normal"));
$table->addRow($elements);
}
} else {
if ($_REQUEST["show"] == 1) {
$db_proxies = DBselect('select hostid from hosts where status=' . HOST_STATUS_PROXY);
while (null != ($db_proxy = DBfetch($db_proxies))) {
$sec_10[$db_proxy['hostid']] = 0;
$sec_30[$db_proxy['hostid']] = 0;
$sec_60[$db_proxy['hostid']] = 0;
$sec_300[$db_proxy['hostid']] = 0;
$sec_600[$db_proxy['hostid']] = 0;
$sec_rest[$db_proxy['hostid']] = 0;
}
$sec_10[0] = 0;
$sec_30[0] = 0;
示例5: zbx_jsvalue
continue 2;
}
}
$triggers .= ',["' . $trigger['description'] . '",' . zbx_jsvalue("javascript: openWinCentered('tr_logform.php?sform=1&itemid=" . $item['itemid'] . "&triggerid=" . $trigger['triggerid'] . "','TriggerLog',760,540," . "'titlebar=no, resizable=yes, scrollbars=yes');") . ']';
$triggers_flag = true;
}
if ($triggers_flag) {
$triggers = rtrim($triggers, ',') . ')';
} else {
$triggers = 'Array()';
}
$menuicon = new CIcon(S_MENU, 'iconmenu_b', 'call_triggerlog_menu(event, ' . zbx_jsvalue($item['itemid']) . ',' . zbx_jsvalue($item['description_expanded']) . ',' . $triggers . ');');
} else {
$menuicon = SPACE;
}
$table->addRow(array(new CCheckBox('group_itemid[' . $item['itemid'] . ']', null, null, $item['itemid']), $menuicon, $host, $description, $trigger_info, $item['key_'], $item['type'] == ITEM_TYPE_TRAPPER ? '' : $item['delay'], $item['history'], in_array($item['value_type'], array(ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_TEXT)) ? '' : $item['trends'], item_type2str($item['type']), $status, new CCol($applications, 'wraptext'), $error));
}
// GO{
$goBox = new CComboBox('go');
$goOption = new CComboItem('activate', S_ACTIVATE_SELECTED);
$goOption->setAttribute('confirm', S_ENABLE_SELECTED_ITEMS_Q);
$goBox->addItem($goOption);
$goOption = new CComboItem('disable', S_DISABLE_SELECTED);
$goOption->setAttribute('confirm', S_DISABLE_SELECTED_ITEMS_Q);
$goBox->addItem($goOption);
$goOption = new CComboItem('massupdate', S_MASS_UPDATE);
//$goOption->setAttribute('confirm',S_MASS_UPDATE_SELECTED_ITEMS_Q);
$goBox->addItem($goOption);
$goOption = new CComboItem('copy_to', S_COPY_SELECTED_TO);
//$goOption->setAttribute('confirm',S_COPY_SELECTED_ITEMS_Q);
$goBox->addItem($goOption);
示例6: CFormList
// create form list
$itemFormList = new CFormList('itemFormList');
if (!empty($this->data['templates'])) {
if ($this->data['is_discovery_rule']) {
$itemFormList->addRow(_('Parent discovery rules'), $this->data['templates']);
} else {
$itemFormList->addRow(_('Parent items'), $this->data['templates']);
}
}
$nameTextBox = new CTextBox('name', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE, $this->data['limited']);
$nameTextBox->attr('autofocus', 'autofocus');
$itemFormList->addRow(_('Name'), $nameTextBox);
// append type to form list
if ($this->data['limited']) {
$itemForm->addVar('type', $this->data['type']);
$itemFormList->addRow(_('Type'), new CTextBox('typename', item_type2str($this->data['type']), ZBX_TEXTBOX_STANDARD_SIZE, 'yes'));
} else {
$typeComboBox = new CComboBox('type', $this->data['type']);
$typeComboBox->addItems($this->data['types']);
$itemFormList->addRow(_('Type'), $typeComboBox);
}
// append key to form list
$itemFormList->addRow(_('Key'), array(new CTextBox('key', $this->data['key'], ZBX_TEXTBOX_STANDARD_SIZE, $this->data['limited']), !$this->data['limited'] && !$this->data['is_discovery_rule'] ? new CButton('keyButton', _('Select'), 'return PopUp("popup.php?srctbl=help_items&srcfld1=key' . '&dstfrm=' . $itemForm->getName() . '&dstfld1=key&itemtype="+jQuery("#type option:selected").val());', 'formlist') : null));
// append interfaces to form list
if (!empty($this->data['interfaces'])) {
$interfacesComboBox = new CComboBox('interfaceid', $this->data['interfaceid']);
// set up interface groups
$interfaceGroups = array();
foreach (zbx_objectValues($this->data['interfaces'], 'type') as $interfaceType) {
$interfaceGroups[$interfaceType] = new COptGroup(interfaceType2str($interfaceType));
}
示例7: CWidget
}
$widget = (new CWidget())->setTitle(_('Queue of items to be updated'))->setControls((new CForm('get'))->cleanItems()->addItem((new CList())->addItem((new CComboBox('config', $config, 'submit();'))->addItem(QUEUE_OVERVIEW, _('Overview'))->addItem(QUEUE_OVERVIEW_BY_PROXY, _('Overview by proxy'))->addItem(QUEUE_DETAILS, _('Details')))));
$table = new CTableInfo();
$severityConfig = select_config();
// overview
if ($config == QUEUE_OVERVIEW) {
$itemTypes = [ITEM_TYPE_ZABBIX, ITEM_TYPE_ZABBIX_ACTIVE, ITEM_TYPE_SIMPLE, ITEM_TYPE_SNMPV1, ITEM_TYPE_SNMPV2C, ITEM_TYPE_SNMPV3, ITEM_TYPE_INTERNAL, ITEM_TYPE_AGGREGATE, ITEM_TYPE_EXTERNAL, ITEM_TYPE_DB_MONITOR, ITEM_TYPE_IPMI, ITEM_TYPE_SSH, ITEM_TYPE_TELNET, ITEM_TYPE_JMX, ITEM_TYPE_CALCULATED];
$table->setHeader([_('Items'), _('5 seconds'), _('10 seconds'), _('30 seconds'), _('1 minute'), _('5 minutes'), _('More than 10 minutes')]);
$queueData = zbx_toHash($queueData, 'itemtype');
foreach ($itemTypes as $type) {
if (isset($queueData[$type])) {
$itemTypeData = $queueData[$type];
} else {
$itemTypeData = ['delay5' => 0, 'delay10' => 0, 'delay30' => 0, 'delay60' => 0, 'delay300' => 0, 'delay600' => 0];
}
$table->addRow([item_type2str($type), getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $severityConfig, $itemTypeData['delay5'], !$itemTypeData['delay5']), getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $severityConfig, $itemTypeData['delay10'], !$itemTypeData['delay10']), getSeverityCell(TRIGGER_SEVERITY_WARNING, $severityConfig, $itemTypeData['delay30'], !$itemTypeData['delay30']), getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $severityConfig, $itemTypeData['delay60'], !$itemTypeData['delay60']), getSeverityCell(TRIGGER_SEVERITY_HIGH, $severityConfig, $itemTypeData['delay300'], !$itemTypeData['delay300']), getSeverityCell(TRIGGER_SEVERITY_DISASTER, $severityConfig, $itemTypeData['delay600'], !$itemTypeData['delay600'])]);
}
} elseif ($config == QUEUE_OVERVIEW_BY_PROXY) {
$proxies = API::proxy()->get(['output' => ['hostid', 'host'], 'preservekeys' => true]);
order_result($proxies, 'host');
$proxies[0] = ['host' => _('Server')];
$table->setHeader([_('Proxy'), _('5 seconds'), _('10 seconds'), _('30 seconds'), _('1 minute'), _('5 minutes'), _('More than 10 minutes')]);
$queueData = zbx_toHash($queueData, 'proxyid');
foreach ($proxies as $proxyId => $proxy) {
if (isset($queueData[$proxyId])) {
$proxyData = $queueData[$proxyId];
} else {
$proxyData = ['delay5' => 0, 'delay10' => 0, 'delay30' => 0, 'delay60' => 0, 'delay300' => 0, 'delay600' => 0];
}
$table->addRow([$proxy['host'], getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $severityConfig, $proxyData['delay5'], !$proxyData['delay5']), getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $severityConfig, $proxyData['delay10'], !$proxyData['delay10']), getSeverityCell(TRIGGER_SEVERITY_WARNING, $severityConfig, $proxyData['delay30'], !$proxyData['delay30']), getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $severityConfig, $proxyData['delay60'], !$proxyData['delay60']), getSeverityCell(TRIGGER_SEVERITY_HIGH, $severityConfig, $proxyData['delay300'], !$proxyData['delay300']), getSeverityCell(TRIGGER_SEVERITY_DISASTER, $severityConfig, $proxyData['delay600'], !$proxyData['delay600'])]);
}
示例8: getItemFormData
/**
* Get data for item edit page.
*
* @param array $item item, item prototype or LLD rule to take the data from
* @param bool $options['is_discovery_rule']
*
* @return array
*/
function getItemFormData(array $item = [], array $options = [])
{
$data = ['form' => getRequest('form'), 'form_refresh' => getRequest('form_refresh'), 'is_discovery_rule' => !empty($options['is_discovery_rule']), 'parent_discoveryid' => getRequest('parent_discoveryid', !empty($options['is_discovery_rule']) ? getRequest('itemid') : null), 'itemid' => getRequest('itemid'), 'limited' => false, 'interfaceid' => getRequest('interfaceid', 0), 'name' => getRequest('name', ''), 'description' => getRequest('description', ''), 'key' => getRequest('key', ''), 'hostname' => getRequest('hostname'), 'delay' => getRequest('delay', ZBX_ITEM_DELAY_DEFAULT), 'history' => getRequest('history', 90), 'status' => getRequest('status', isset($_REQUEST['form_refresh']) ? 1 : 0), 'type' => getRequest('type', 0), 'snmp_community' => getRequest('snmp_community', 'public'), 'snmp_oid' => getRequest('snmp_oid', 'interfaces.ifTable.ifEntry.ifInOctets.1'), 'port' => getRequest('port', ''), 'value_type' => getRequest('value_type', ITEM_VALUE_TYPE_UINT64), 'data_type' => getRequest('data_type', ITEM_DATA_TYPE_DECIMAL), 'trapper_hosts' => getRequest('trapper_hosts', ''), 'units' => getRequest('units', ''), 'valuemapid' => getRequest('valuemapid', 0), 'params' => getRequest('params', ''), 'multiplier' => getRequest('multiplier', 0), 'delta' => getRequest('delta', 0), 'trends' => getRequest('trends', DAY_IN_YEAR), 'new_application' => getRequest('new_application', ''), 'applications' => getRequest('applications', []), 'delay_flex' => getRequest('delay_flex', []), 'snmpv3_contextname' => getRequest('snmpv3_contextname', ''), 'snmpv3_securityname' => getRequest('snmpv3_securityname', ''), 'snmpv3_securitylevel' => getRequest('snmpv3_securitylevel', 0), 'snmpv3_authprotocol' => getRequest('snmpv3_authprotocol', ITEM_AUTHPROTOCOL_MD5), 'snmpv3_authpassphrase' => getRequest('snmpv3_authpassphrase', ''), 'snmpv3_privprotocol' => getRequest('snmpv3_privprotocol', ITEM_PRIVPROTOCOL_DES), 'snmpv3_privpassphrase' => getRequest('snmpv3_privpassphrase', ''), 'ipmi_sensor' => getRequest('ipmi_sensor', ''), 'authtype' => getRequest('authtype', 0), 'username' => getRequest('username', ''), 'password' => getRequest('password', ''), 'publickey' => getRequest('publickey', ''), 'privatekey' => getRequest('privatekey', ''), 'formula' => getRequest('formula', 1), 'logtimefmt' => getRequest('logtimefmt', ''), 'add_groupid' => getRequest('add_groupid', getRequest('groupid', 0)), 'valuemaps' => null, 'possibleHostInventories' => null, 'alreadyPopulated' => null, 'initial_item_type' => null, 'templates' => []];
// hostid
if (!empty($data['parent_discoveryid'])) {
$discoveryRule = API::DiscoveryRule()->get(['itemids' => $data['parent_discoveryid'], 'output' => API_OUTPUT_EXTEND, 'editable' => true]);
$discoveryRule = reset($discoveryRule);
$data['hostid'] = $discoveryRule['hostid'];
$data['new_application_prototype'] = getRequest('new_application_prototype', '');
$data['application_prototypes'] = getRequest('application_prototypes', array());
} else {
$data['hostid'] = getRequest('hostid', 0);
}
// types, http items only for internal processes
$data['types'] = item_type2str();
unset($data['types'][ITEM_TYPE_HTTPTEST]);
if (!empty($options['is_discovery_rule'])) {
unset($data['types'][ITEM_TYPE_AGGREGATE], $data['types'][ITEM_TYPE_CALCULATED], $data['types'][ITEM_TYPE_SNMPTRAP]);
}
// item
if ($item) {
$data['item'] = $item;
$data['hostid'] = !empty($data['hostid']) ? $data['hostid'] : $data['item']['hostid'];
$data['limited'] = $data['item']['templateid'] != 0;
// get templates
$itemid = $item['itemid'];
do {
$params = ['itemids' => $itemid, 'output' => ['itemid', 'templateid'], 'selectHosts' => ['name']];
if ($data['is_discovery_rule']) {
$item = API::DiscoveryRule()->get($params);
} else {
$params['selectDiscoveryRule'] = ['itemid'];
$params['filter'] = ['flags' => null];
$item = API::Item()->get($params);
}
$item = reset($item);
if (!empty($item)) {
$host = reset($item['hosts']);
if (!empty($item['hosts'])) {
$host['name'] = CHtml::encode($host['name']);
if (bccomp($data['itemid'], $itemid) == 0) {
} elseif ($data['is_discovery_rule']) {
$data['templates'][] = new CLink($host['name'], 'host_discovery.php?form=update&itemid=' . $item['itemid']);
$data['templates'][] = SPACE . '⇒' . SPACE;
} elseif ($item['discoveryRule']) {
$data['templates'][] = new CLink($host['name'], 'disc_prototypes.php?form=update' . '&itemid=' . $item['itemid'] . '&parent_discoveryid=' . $item['discoveryRule']['itemid']);
$data['templates'][] = SPACE . '⇒' . SPACE;
} else {
$data['templates'][] = new CLink($host['name'], 'items.php?form=update&itemid=' . $item['itemid']);
$data['templates'][] = SPACE . '⇒' . SPACE;
}
}
$itemid = $item['templateid'];
} else {
break;
}
} while ($itemid != 0);
$data['templates'] = array_reverse($data['templates']);
array_shift($data['templates']);
}
// caption
if (!empty($data['is_discovery_rule'])) {
$data['caption'] = _('Discovery rule');
} else {
$data['caption'] = !empty($data['parent_discoveryid']) ? _('Item prototype') : _('Item');
}
// hostname
if (empty($data['is_discovery_rule']) && empty($data['hostname'])) {
if (!empty($data['hostid'])) {
$hostInfo = API::Host()->get(['hostids' => $data['hostid'], 'output' => ['name'], 'templated_hosts' => true]);
$hostInfo = reset($hostInfo);
$data['hostname'] = $hostInfo['name'];
} else {
$data['hostname'] = _('not selected');
}
}
// fill data from item
if (!hasRequest('form_refresh') && ($item || $data['limited'])) {
$data['name'] = $data['item']['name'];
$data['description'] = $data['item']['description'];
$data['key'] = $data['item']['key_'];
$data['interfaceid'] = $data['item']['interfaceid'];
$data['type'] = $data['item']['type'];
$data['snmp_community'] = $data['item']['snmp_community'];
$data['snmp_oid'] = $data['item']['snmp_oid'];
$data['port'] = $data['item']['port'];
$data['value_type'] = $data['item']['value_type'];
$data['data_type'] = $data['item']['data_type'];
$data['trapper_hosts'] = $data['item']['trapper_hosts'];
$data['units'] = $data['item']['units'];
$data['valuemapid'] = $data['item']['valuemapid'];
$data['multiplier'] = $data['item']['multiplier'];
//.........這裏部分代碼省略.........
示例9: addValue
if ($multiselect) {
$js_action = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($item['itemid']) . ');';
} else {
$values = array();
for ($i = 1; $i <= $dstfldCount; $i++) {
$dstfld = getRequest('dstfld' . $i);
$srcfld = getRequest('srcfld' . $i);
if (!empty($dstfld) && !empty($item[$srcfld])) {
$values[$dstfld] = $item[$srcfld];
}
}
// if we need to submit parent window
$js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . ', ' . ($submitParent ? 'true' : 'false') . '); return false;';
}
$description->setAttribute('onclick', $js_action . ' jQuery(this).removeAttr("onclick");');
$table->addRow(array($hostid > 0 ? null : $item['hostname'], $multiselect ? new CCheckBox('items[' . zbx_jsValue($item[$srcfld1]) . ']', null, null, $item['itemid']) : null, $description, $item['key_'], item_type2str($item['type']), itemValueTypeString($item['value_type']), new CSpan(itemIndicator($item['status'], $item['state']), itemIndicatorStyle($item['status'], $item['state']))));
// made to save memory usage
if ($multiselect) {
$jsItems[$item['itemid']] = array('itemid' => $item['itemid'], 'name' => $item['name'], 'key_' => $item['key_'], 'flags' => $item['flags'], 'type' => $item['type'], 'value_type' => $item['value_type'], 'host' => $item['hostname']);
}
}
if ($multiselect) {
$button = new CButton('select', _('Select'), "javascript: addSelectedValues('items', " . zbx_jsvalue($reference) . ');');
$table->setFooter(new CCol($button, 'right'));
insert_js('var popupReference = ' . zbx_jsvalue($jsItems, true) . ';');
}
$form->addItem($table);
$form->show();
} elseif ($srctbl == 'applications') {
$form = new CForm();
$form->setName('applicationform');
示例10: insert_mass_update_item_form
function insert_mass_update_item_form()
{
global $USER_DETAILS;
$frmItem = new CFormTable(S_ITEM, null, 'post');
$frmItem->setHelp('web.items.item.php');
$frmItem->setTitle(S_MASS_UPDATE);
$frmItem->addVar('massupdate', 1);
$frmItem->addVar('group_itemid', get_request('group_itemid', array()));
$frmItem->addVar('config', get_request('config', 0));
$delay = get_request('delay', 30);
$history = get_request('history', 90);
$status = get_request('status', 0);
$type = get_request('type', 0);
$snmp_community = get_request('snmp_community', 'public');
$snmp_port = get_request('snmp_port', 161);
$value_type = get_request('value_type', ITEM_VALUE_TYPE_UINT64);
$data_type = get_request('data_type', ITEM_DATA_TYPE_DECIMAL);
$trapper_hosts = get_request('trapper_hosts', '');
$units = get_request('units', '');
$authtype = get_request('authtype', '');
$username = get_request('username', '');
$password = get_request('password', '');
$publickey = get_request('publickey', '');
$privatekey = get_request('privatekey', '');
$valuemapid = get_request('valuemapid', 0);
$delta = get_request('delta', 0);
$trends = get_request('trends', 365);
$applications = get_request('applications', array());
$delay_flex = get_request('delay_flex', array());
$snmpv3_securityname = get_request('snmpv3_securityname', '');
$snmpv3_securitylevel = get_request('snmpv3_securitylevel', 0);
$snmpv3_authpassphrase = get_request('snmpv3_authpassphrase', '');
$snmpv3_privpassphrase = get_request('snmpv3_privpassphrase', '');
$formula = get_request('formula', '1');
$logtimefmt = get_request('logtimefmt', '');
$delay_flex_el = array();
$i = 0;
foreach ($delay_flex as $val) {
if (!isset($val['delay']) && !isset($val['period'])) {
continue;
}
array_push($delay_flex_el, array(new CCheckBox('rem_delay_flex[]', 'no', null, $i), $val['delay'], SPACE . S_SEC_AT . SPACE, $val['period']), BR());
$frmItem->addVar("delay_flex[" . $i . "][delay]", $val['delay']);
$frmItem->addVar("delay_flex[" . $i . "][period]", $val['period']);
$i++;
if ($i >= 7) {
break;
}
/* limit count of intervals
* 7 intervals by 30 symbols = 210 characters
* db storage field is 256
*/
}
if (count($delay_flex_el) == 0) {
array_push($delay_flex_el, S_NO_FLEXIBLE_INTERVALS);
} else {
array_push($delay_flex_el, new CButton('del_delay_flex', S_DELETE_SELECTED));
}
if (count($applications) == 0) {
array_push($applications, 0);
}
$itemTypes = item_type2str();
// http items only for internal processes
unset($itemTypes[ITEM_TYPE_HTTPTEST]);
$cmbType = new CComboBox('type', $type);
$cmbType->addItems($itemTypes);
$frmItem->addRow(array(new CVisibilityBox('type_visible', get_request('type_visible'), 'type', S_ORIGINAL), S_TYPE), $cmbType);
$frmItem->addRow(array(new CVisibilityBox('community_visible', get_request('community_visible'), 'snmp_community', S_ORIGINAL), S_SNMP_COMMUNITY), new CTextBox('snmp_community', $snmp_community, 16));
$frmItem->addRow(array(new CVisibilityBox('securityname_visible', get_request('securityname_visible'), 'snmpv3_securityname', S_ORIGINAL), S_SNMPV3_SECURITY_NAME), new CTextBox('snmpv3_securityname', $snmpv3_securityname, 64));
$cmbSecLevel = new CComboBox('snmpv3_securitylevel', $snmpv3_securitylevel);
$cmbSecLevel->addItem(ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV, "noAuthNoPriv");
$cmbSecLevel->addItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHNOPRIV, "authNoPriv");
$cmbSecLevel->addItem(ITEM_SNMPV3_SECURITYLEVEL_AUTHPRIV, "authPriv");
$frmItem->addRow(array(new CVisibilityBox('securitylevel_visible', get_request('securitylevel_visible'), 'snmpv3_securitylevel', S_ORIGINAL), S_SNMPV3_SECURITY_LEVEL), $cmbSecLevel);
$frmItem->addRow(array(new CVisibilityBox('authpassphrase_visible', get_request('authpassphrase_visible'), 'snmpv3_authpassphrase', S_ORIGINAL), S_SNMPV3_AUTH_PASSPHRASE), new CTextBox('snmpv3_authpassphrase', $snmpv3_authpassphrase, 64));
$frmItem->addRow(array(new CVisibilityBox('privpassphras_visible', get_request('privpassphras_visible'), 'snmpv3_privpassphrase', S_ORIGINAL), S_SNMPV3_PRIV_PASSPHRASE), new CTextBox('snmpv3_privpassphrase', $snmpv3_privpassphrase, 64));
$frmItem->addRow(array(new CVisibilityBox('port_visible', get_request('port_visible'), 'snmp_port', S_ORIGINAL), S_SNMP_PORT), new CNumericBox('snmp_port', $snmp_port, 5));
$cmbValType = new CComboBox('value_type', $value_type);
$cmbValType->addItem(ITEM_VALUE_TYPE_UINT64, S_NUMERIC_UNSIGNED);
$cmbValType->addItem(ITEM_VALUE_TYPE_FLOAT, S_NUMERIC_FLOAT);
$cmbValType->addItem(ITEM_VALUE_TYPE_STR, S_CHARACTER);
$cmbValType->addItem(ITEM_VALUE_TYPE_LOG, S_LOG);
$cmbValType->addItem(ITEM_VALUE_TYPE_TEXT, S_TEXT);
$frmItem->addRow(array(new CVisibilityBox('value_type_visible', get_request('value_type_visible'), 'value_type', S_ORIGINAL), S_TYPE_OF_INFORMATION), $cmbValType);
$cmbDataType = new CComboBox('data_type', $data_type);
$cmbDataType->addItem(ITEM_DATA_TYPE_DECIMAL, item_data_type2str(ITEM_DATA_TYPE_DECIMAL));
$cmbDataType->addItem(ITEM_DATA_TYPE_OCTAL, item_data_type2str(ITEM_DATA_TYPE_OCTAL));
$cmbDataType->addItem(ITEM_DATA_TYPE_HEXADECIMAL, item_data_type2str(ITEM_DATA_TYPE_HEXADECIMAL));
$frmItem->addRow(array(new CVisibilityBox('data_type_visible', get_request('data_type_visible'), 'data_type', S_ORIGINAL), S_DATA_TYPE), $cmbDataType);
$frmItem->addRow(array(new CVisibilityBox('units_visible', get_request('units_visible'), 'units', S_ORIGINAL), S_UNITS), new CTextBox('units', $units, 40));
$cmbAuthType = new CComboBox('authtype', $authtype);
$cmbAuthType->addItem(ITEM_AUTHTYPE_PASSWORD, S_PASSWORD);
$cmbAuthType->addItem(ITEM_AUTHTYPE_PUBLICKEY, S_PUBLIC_KEY);
$frmItem->addRow(array(new CVisibilityBox('authtype_visible', get_request('authtype_visible'), 'authtype', S_ORIGINAL), S_AUTHENTICATION_METHOD), $cmbAuthType);
$frmItem->addRow(array(new CVisibilityBox('username_visible', get_request('username_visible'), 'username', S_ORIGINAL), S_USER_NAME), new CTextBox('username', $username, 40));
$frmItem->addRow(array(new CVisibilityBox('publickey_visible', get_request('publickey_visible'), 'publickey', S_ORIGINAL), S_PUBLIC_KEY_FILE), new CTextBox('publickey', $publickey, 40));
$frmItem->addRow(array(new CVisibilityBox('privatekey_visible', get_request('privatekey_visible'), 'privatekey', S_ORIGINAL), S_PRIVATE_KEY_FILE), new CTextBox('privatekey', $privatekey, 40));
$frmItem->addRow(array(new CVisibilityBox('password_visible', get_request('password_visible'), 'password', S_ORIGINAL), S_PASSWORD), new CTextBox('password', $password, 40));
$frmItem->addRow(array(new CVisibilityBox('formula_visible', get_request('formula_visible'), 'formula', S_ORIGINAL), S_CUSTOM_MULTIPLIER . ' (0 - ' . S_DISABLED . ')'), new CTextBox('formula', $formula, 40));
$frmItem->addRow(array(new CVisibilityBox('delay_visible', get_request('delay_visible'), 'delay', S_ORIGINAL), S_UPDATE_INTERVAL_IN_SEC), new CNumericBox('delay', $delay, 5));
//.........這裏部分代碼省略.........
示例11: get_realhost_by_itemid
if ($discovery['templateid']) {
$dbTemplate = get_realhost_by_itemid($discovery['templateid']);
$description[] = (new CLink($dbTemplate['name'], '?hostid=' . $dbTemplate['hostid']))->addClass(ZBX_STYLE_LINK_ALT)->addClass(ZBX_STYLE_GREY);
$description[] = NAME_DELIMITER;
}
$description[] = new CLink($discovery['name_expanded'], '?form=update&itemid=' . $discovery['itemid']);
// status
$status = (new CLink(itemIndicator($discovery['status'], $discovery['state']), '?hostid=' . $_REQUEST['hostid'] . '&g_hostdruleid=' . $discovery['itemid'] . '&action=' . ($discovery['status'] == ITEM_STATUS_DISABLED ? 'discoveryrule.massenable' : 'discoveryrule.massdisable')))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(itemIndicatorStyle($discovery['status'], $discovery['state']))->addSID();
// info
if ($data['showInfoColumn']) {
if ($discovery['status'] == ITEM_STATUS_ACTIVE && !zbx_empty($discovery['error'])) {
$info = makeErrorIcon($discovery['error']);
} else {
$info = '';
}
} else {
$info = null;
}
// host prototype link
$hostPrototypeLink = null;
if ($data['host']['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
$hostPrototypeLink = [new CLink(_('Host prototypes'), 'host_prototypes.php?parent_discoveryid=' . $discovery['itemid']), CViewHelper::showNum($discovery['hostPrototypes'])];
}
$discoveryTable->addRow([new CCheckBox('g_hostdruleid[' . $discovery['itemid'] . ']', $discovery['itemid']), $description, [new CLink(_('Item prototypes'), 'disc_prototypes.php?parent_discoveryid=' . $discovery['itemid']), CViewHelper::showNum($discovery['items'])], [new CLink(_('Trigger prototypes'), 'trigger_prototypes.php?parent_discoveryid=' . $discovery['itemid']), CViewHelper::showNum($discovery['triggers'])], [new CLink(_('Graph prototypes'), 'graphs.php?parent_discoveryid=' . $discovery['itemid']), CViewHelper::showNum($discovery['graphs'])], $hostPrototypeLink, $discovery['key_'], $discovery['delay'] === '' ? '' : convertUnitsS($discovery['delay']), item_type2str($discovery['type']), $status, $info]);
}
zbx_add_post_js('cookie.prefix = "' . $this->data['hostid'] . '";');
// append table to form
$discoveryForm->addItem([$discoveryTable, $this->data['paging'], new CActionButtonList('action', 'g_hostdruleid', ['discoveryrule.massenable' => ['name' => _('Enable'), 'confirm' => _('Enable selected discovery rules?')], 'discoveryrule.massdisable' => ['name' => _('Disable'), 'confirm' => _('Disable selected discovery rules?')], 'discoveryrule.massdelete' => ['name' => _('Delete'), 'confirm' => _('Delete selected discovery rules?')]], $this->data['hostid'])]);
// append form to widget
$widget->addItem($discoveryForm);
return $widget;
示例12: array_push
array_push($description, new CLink($template_host['host'], '?' . 'hostid=' . $template_host['hostid'], 'unknown'), ':');
}
array_push($description, new CLink(item_description($db_item), '?form=update&itemid=' . $db_item['itemid'] . '&hostid=' . $db_item['hostid']));
$status = new CCol(new CLink(item_status2str($db_item['status']), '?group_itemid%5B%5D=' . $db_item['itemid'] . '&go=' . ($db_item['status'] ? 'activate' : 'disable'), item_status2style($db_item['status'])));
if (!zbx_empty($db_item['error'])) {
$error = new CDiv(SPACE, 'error_icon');
$error->setHint($db_item['error'], '', 'on');
} else {
$error = new CDiv(SPACE, 'ok_icon');
}
$applications = $show_applications ? implode(', ', get_applications_by_itemid($db_item['itemid'], 'name')) : null;
if (!is_null($applications) && empty($applications)) {
$applications = ' - ';
}
$applications = new CCol($applications, 'wraptext');
$table->addRow(array(new CCheckBox('group_itemid[' . $db_item['itemid'] . ']', null, null, $db_item['itemid']), $show_host ? $db_item['host'] : null, $description, $db_item['key_'], $db_item['delay'], $db_item['history'], $db_item['trends'], item_type2str($db_item['type']), $status, $applications, $error));
$row_count++;
}
//----- GO ------
$goBox = new CComboBox('go');
$goBox->addItem('activate', S_ACTIVATE_SELECTED);
$goBox->addItem('disable', S_DISABLE_SELECTED);
$goBox->addItem('massupdate', S_MASS_UPDATE);
$goBox->addItem('copy_to', S_COPY_SELECTED_TO);
$goBox->addItem('clean_history', S_CLEAN_HISTORY_SELECTED_ITEMS);
$goBox->addItem('delete', S_DELETE_SELECTED);
// goButton name is necessary!!!
$goButton = new CButton('goButton', S_GO . ' (0)');
$goButton->setAttribute('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "group_itemid";');
$table->setFooter(new CCol(array($goBox, $goButton)));
示例13: array_push
array_push($description, new CLink($template_host['host'], '?' . 'hostid=' . $template_host['hostid'], 'unknown'), ':');
}
array_push($description, new CLink(item_description($db_item), '?form=update&itemid=' . $db_item['itemid'] . '&hostid=' . $db_item['hostid'], 'action'));
$status = new CCol(new CLink(item_status2str($db_item['status']), '?group_itemid%5B%5D=' . $db_item['itemid'] . '&group_task=' . ($db_item['status'] ? 'Activate+selected' : 'Disable+selected'), item_status2style($db_item['status'])));
if ($db_item['error'] == '') {
$error = new CCol('-', 'off');
} else {
$error = new CCol($db_item['error'], 'on');
}
$applications = $show_applications ? implode(', ', get_applications_by_itemid($db_item['itemid'], 'name')) : null;
if (!is_null($applications) && empty($applications)) {
$applications = ' - ';
}
$chkBox = new CCheckBox('group_itemid[' . $db_item['itemid'] . ']', null, null, $db_item['itemid']);
//if($db_item['templateid'] > 0) $chkBox->setEnabled(false);
$table->addRow(array($show_host ? $db_item['host'] : null, array($chkBox, $description), $db_item['key_'], $db_item['delay'], $db_item['history'], $db_item['trends'], item_type2str($db_item['type']), $status, $applications, $error));
$row_count++;
}
$footerButtons = array();
array_push($footerButtons, new CButtonQMessage('group_task', S_ACTIVATE_SELECTED, S_ACTIVATE_SELECTED_ITEMS_Q));
array_push($footerButtons, SPACE);
array_push($footerButtons, new CButtonQMessage('group_task', S_DISABLE_SELECTED, S_DISABLE_SELECTED_ITEMS_Q));
array_push($footerButtons, SPACE);
array_push($footerButtons, new CButtonQMessage('group_task', S_CLEAN_HISTORY_SELECTED_ITEMS, S_HISTORY_CLEANING_CAN_TAKE_A_LONG_TIME_CONTINUE_Q));
array_push($footerButtons, SPACE);
array_push($footerButtons, new CButtonQMessage('group_task', S_DELETE_SELECTED, S_DELETE_SELECTED_ITEMS_Q));
array_push($footerButtons, SPACE);
array_push($footerButtons, new CButton('form_copy_to', S_COPY_SELECTED_TO));
array_push($footerButtons, SPACE);
array_push($footerButtons, new CButton('form_mass_update', S_MASS_UPDATE));
$table->setFooter(new CCol($footerButtons));
示例14: array
$statusIcons = array();
if ($item['status'] == ITEM_STATUS_ACTIVE) {
if (zbx_empty($item['error'])) {
$error = new CDiv(SPACE, 'status_icon iconok');
} else {
$error = new CDiv(SPACE, 'status_icon iconerror');
$error->setHint($item['error'], '', 'on');
}
$statusIcons[] = $error;
}
if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
$trendValue = $config['hk_trends_global'] ? $config['hk_trends'] : $item['trends'];
} else {
$trendValue = UNKNOWN_VALUE;
}
$row = new CRow(array(SPACE, is_show_all_nodes() ? $host['item_cnt'] ? SPACE : get_node_name_by_elid($item['itemid']) : null, $hostColumn, new CCol(new CDiv(array($item['name_expanded'], BR(), $itemKey), $stateCss . ' item')), new CCol(new CSpan($item['type'] == ITEM_TYPE_SNMPTRAP || $item['type'] == ITEM_TYPE_TRAPPER ? UNKNOWN_VALUE : $item['delay'], $stateCss)), new CCol(new CSpan($config['hk_history_global'] ? $config['hk_history'] : $item['history'], $stateCss)), new CCol(new CSpan($trendValue, $stateCss)), new CCol(new CSpan(item_type2str($item['type']), $stateCss)), new CCol(new CSpan($lastClock, $stateCss)), new CCol(new CSpan($lastValue, $stateCss)), new CCol(new CSpan($change, $stateCss)), $actions, $statusIcons));
} else {
$row = new CRow(array(SPACE, is_show_all_nodes() ? $host['item_cnt'] ? SPACE : get_node_name_by_elid($item['itemid']) : null, $hostColumn, new CCol(new CSpan($item['name_expanded'], $stateCss . ' item')), new CCol(new CSpan($lastClock, $stateCss)), new CCol(new CSpan($lastValue, $stateCss)), new CCol(new CSpan($change, $stateCss)), $actions));
}
$hosts[$item['hostid']]['item_cnt']++;
$tab_rows[$item['hostid']][] = $row;
}
foreach ($hosts as $hostId => $dbHost) {
$host = $hosts[$dbHost['hostid']];
if (!isset($tab_rows[$hostId])) {
continue;
}
$appRows = $tab_rows[$hostId];
$openState = CProfile::get('web.latest.toggle_other', null, $host['hostid']);
$toggle = new CDiv(SPACE, 'app-list-toggle icon-plus-9x9');
if ($openState) {
示例15: itemTypeInterface
$usedInterfacesTypes[$item['type']] = itemTypeInterface($item['type']);
}
$initialItemType = min(array_keys($usedInterfacesTypes));
$data['type'] = get_request('type') !== null ? $data['type'] : $initialItemType;
$data['initial_item_type'] = $initialItemType;
$data['multiple_interface_types'] = count(array_unique($usedInterfacesTypes)) > 1;
}
// application
if (count($data['applications']) == 0) {
array_push($data['applications'], 0);
}
if (!empty($data['hostid'])) {
$data['db_applications'] = DBfetchArray(DBselect('SELECT a.applicationid,a.name' . ' FROM applications a' . ' WHERE a.hostid=' . $data['hostid'] . ' ORDER BY a.name'));
}
// item types
$data['itemTypes'] = item_type2str();
unset($data['itemTypes'][ITEM_TYPE_HTTPTEST]);
// valuemap
$data['valuemaps'] = DBfetchArray(DBselect('SELECT v.valuemapid,v.name FROM valuemaps v WHERE ' . DBin_node('v.valuemapid')));
order_result($data['valuemaps'], 'name');
// render view
$itemView = new CView('configuration.item.massupdate', $data);
$itemView->render();
$itemView->show();
} elseif ($_REQUEST['go'] == 'copy_to' && isset($_REQUEST['group_itemid'])) {
$data = array('group_itemid' => get_request('group_itemid', array()), 'hostid' => get_request('hostid', 0), 'copy_type' => get_request('copy_type', 0), 'copy_groupid' => get_request('copy_groupid', 0), 'copy_targetid' => get_request('copy_targetid', array()));
if (!is_array($data['group_itemid']) || is_array($data['group_itemid']) && count($data['group_itemid']) < 1) {
error(_('Incorrect list of items.'));
} else {
// group
$data['groups'] = API::HostGroup()->get(array('output' => API_OUTPUT_EXTEND));