本文整理汇总了PHP中trigger_value2str函数的典型用法代码示例。如果您正苦于以下问题:PHP trigger_value2str函数的具体用法?PHP trigger_value2str怎么用?PHP trigger_value2str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trigger_value2str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
$options = array('monitored' => true, 'value' => array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE), 'triggerLimit' => $this->screenitem['elements'], 'eventLimit' => $this->screenitem['elements']);
$item = new CTableInfo(_('No events found.'));
$item->setHeader(array(_('Time'), is_show_all_nodes() ? _('Node') : null, _('Host'), _('Description'), _('Value'), _('Severity')));
$events = getLastEvents($options);
foreach ($events as $event) {
$trigger = $event['trigger'];
$host = $event['host'];
$statusSpan = new CSpan(trigger_value2str($event['value']));
// add colors and blinking to span depending on configuration and trigger parameters
addTriggerValueStyle($statusSpan, $event['value'], $event['clock'], $event['acknowledged']);
$item->addRow(array(zbx_date2str(_('d M Y H:i:s'), $event['clock']), get_node_name_by_elid($event['objectid']), $host['name'], new CLink($trigger['description'], 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid']), $statusSpan, getSeverityCell($trigger['priority'])));
}
return $this->getOutput($item);
}
示例2: get_act_new_cond_form
function get_act_new_cond_form($action = null)
{
$tblCond = new CTable('', 'nowrap');
if (isset($_REQUEST['actionid']) && empty($action)) {
$action = get_action_by_actionid($_REQUEST['actionid']);
}
if (isset($_REQUEST['actionid']) && !isset($_REQUEST['form_refresh'])) {
$eventsource = $action['eventsource'];
$evaltype = $action['evaltype'];
} else {
$evaltype = get_request('evaltype');
$eventsource = get_request('eventsource');
}
$allowed_conditions = get_conditions_by_eventsource($eventsource);
/* init new_condition variable */
$new_condition = get_request('new_condition', array());
if (!is_array($new_condition)) {
$new_condition = array();
}
if (!isset($new_condition['type'])) {
$new_condition['type'] = CONDITION_TYPE_TRIGGER_NAME;
}
if (!isset($new_condition['operator'])) {
$new_condition['operator'] = CONDITION_OPERATOR_LIKE;
}
if (!isset($new_condition['value'])) {
$new_condition['value'] = '';
}
if (!str_in_array($new_condition['type'], $allowed_conditions)) {
$new_condition['type'] = $allowed_conditions[0];
}
// NEW CONDITION
$rowCondition = array();
// add condition type
$cmbCondType = new CComboBox('new_condition[type]', $new_condition['type'], 'submit()');
foreach ($allowed_conditions as $cond) {
$cmbCondType->addItem($cond, condition_type2str($cond));
}
array_push($rowCondition, $cmbCondType);
// add condition operation
$cmbCondOp = new CComboBox('new_condition[operator]');
foreach (get_operators_by_conditiontype($new_condition['type']) as $op) {
$cmbCondOp->addItem($op, condition_operator2str($op));
}
array_push($rowCondition, $cmbCondOp);
// add condition value
switch ($new_condition['type']) {
case CONDITION_TYPE_HOST_GROUP:
$tblCond->addItem(new CVar('new_condition[value]', '0'));
$rowCondition[] = array(new CTextBox('group', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=group&srctbl=host_group" . "&srcfld1=groupid&srcfld2=name',450,450);", 'T'));
break;
case CONDITION_TYPE_HOST_TEMPLATE:
$tblCond->addItem(new CVar('new_condition[value]', '0'));
$rowCondition[] = array(new CTextBox('host', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=host&srctbl=host_templates" . "&srcfld1=hostid&srcfld2=host',450,450);", 'T'));
break;
case CONDITION_TYPE_HOST:
$tblCond->addItem(new CVar('new_condition[value]', '0'));
$rowCondition[] = array(new CTextBox('host', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=host&srctbl=hosts" . "&srcfld1=hostid&srcfld2=host',450,450);", 'T'));
break;
case CONDITION_TYPE_TRIGGER:
$tblCond->addItem(new CVar('new_condition[value]', '0'));
$rowCondition[] = array(new CTextBox('trigger', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=trigger&srctbl=triggers" . "&srcfld1=triggerid&srcfld2=description');", 'T'));
break;
case CONDITION_TYPE_TRIGGER_NAME:
$rowCondition[] = new CTextBox('new_condition[value]', "", 40);
break;
case CONDITION_TYPE_TRIGGER_VALUE:
$cmbCondVal = new CComboBox('new_condition[value]');
foreach (array(TRIGGER_VALUE_FALSE, TRIGGER_VALUE_TRUE) as $tr_val) {
$cmbCondVal->addItem($tr_val, trigger_value2str($tr_val));
}
$rowCondition[] = $cmbCondVal;
break;
case CONDITION_TYPE_TIME_PERIOD:
$rowCondition[] = new CTextBox('new_condition[value]', "1-7,00:00-23:59", 40);
break;
case CONDITION_TYPE_TRIGGER_SEVERITY:
$cmbCondVal = new CComboBox('new_condition[value]');
foreach (array(TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER) as $id) {
$cmbCondVal->addItem($id, get_severity_description($id));
}
$rowCondition[] = $cmbCondVal;
break;
case CONDITION_TYPE_MAINTENANCE:
$rowCondition[] = new CCol(S_MAINTENANCE_SMALL);
break;
case CONDITION_TYPE_DHOST_IP:
$rowCondition[] = new CTextBox('new_condition[value]', '192.168.0.1-127,192.168.2.1', 50);
break;
case CONDITION_TYPE_DSERVICE_TYPE:
$cmbCondVal = new CComboBox('new_condition[value]');
foreach (array(SVC_SSH, SVC_LDAP, SVC_SMTP, SVC_FTP, SVC_HTTP, SVC_POP, SVC_NNTP, SVC_IMAP, SVC_TCP, SVC_AGENT, SVC_SNMPv1, SVC_SNMPv2, SVC_ICMPPING) as $svc) {
$cmbCondVal->addItem($svc, discovery_check_type2str($svc));
}
$rowCondition[] = $cmbCondVal;
break;
case CONDITION_TYPE_DSERVICE_PORT:
$rowCondition[] = new CTextBox('new_condition[value]', '0-1023,1024-49151', 40);
break;
case CONDITION_TYPE_DSTATUS:
//.........这里部分代码省略.........
示例3: foreach
// events
foreach ($events as $event) {
$trigger = $triggers[$event['objectid']];
$host = reset($trigger['hosts']);
$host = $hosts[$host['hostid']];
$description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, ['clock' => $event['clock'], 'ns' => $event['ns']]));
// duration
$event['duration'] = ($nextEvent = get_next_event($event, $events)) ? zbx_date2age($event['clock'], $nextEvent['clock']) : zbx_date2age($event['clock']);
// action
$action = isset($actions[$event['eventid']]) ? $actions[$event['eventid']] : '';
if ($csvExport) {
$csvRows[] = [zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']), $pageFilter->hostid == 0 ? $host['name'] : null, $description, trigger_value2str($event['value']), getSeverityName($trigger['priority'], $config), $event['duration'], $config['event_ack_enable'] ? $event['acknowledges'] ? _('Yes') : _('No') : null, strip_tags((string) $action)];
} else {
$triggerDescription = (new CSpan($description))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getTrigger($trigger, null, $event['clock']));
// add colors and blinking to span depending on configuration and trigger parameters
$statusSpan = new CSpan(trigger_value2str($event['value']));
addTriggerValueStyle($statusSpan, $event['value'], $event['clock'], $event['acknowledged']);
// host JS menu link
$hostName = null;
if ($pageFilter->hostid == 0) {
$hostName = (new CSpan($host['name']))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$host['hostid']]));
}
$table->addRow([(new CLink(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']), 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid']))->addClass('action'), $hostName, $triggerDescription, $statusSpan, getSeverityCell($trigger['priority'], $config, null, !$event['value']), $event['duration'], $config['event_ack_enable'] ? getEventAckState($event, $page['file']) : null, (new CCol($action))->addClass(ZBX_STYLE_NOWRAP)]);
}
}
} else {
if (!$csvExport) {
$events = [];
$url = (new CUrl('events.php'))->setArgument('fullscreen', getRequest('fullscreen'))->setArgument('groupid', $pageFilter->groupid)->setArgument('hostid', $pageFilter->hostid);
$paging = getPagingLine($events, ZBX_SORT_UP, $url);
}
示例4: validateConditions
/**
* Validate conditions.
*
* @static
*
* @param array $conditions
* @param int $conditions['conditiontype']
* @param array $conditions['value']
*
* @return bool
*/
public static function validateConditions($conditions, $update = false)
{
$conditions = zbx_toArray($conditions);
$hostGroupIdsAll = array();
$templateIdsAll = array();
$triggerIdsAll = array();
$hostIdsAll = array();
$discoveryRuleIdsAll = array();
$proxyIdsAll = array();
$proxyidsAll = array();
// build validators
$timePeriodValidator = new CTimePeriodValidator();
$discoveryCheckTypeValidator = new CSetValidator(array('values' => array_keys(discovery_check_type2str())));
$discoveryObjectStatusValidator = new CSetValidator(array('values' => array_keys(discovery_object_status2str())));
$triggerSeverityValidator = new CSetValidator(array('values' => array_keys(getSeverityCaption())));
$discoveryObjectValidator = new CSetValidator(array('values' => array_keys(discovery_object2str())));
$triggerValueValidator = new CSetValidator(array('values' => array_keys(trigger_value2str())));
$eventTypeValidator = new CSetValidator(array('values' => array_keys(eventType())));
foreach ($conditions as $condition) {
// on create operator is mandatory and needs validation, but on update it must be validated only if it's set
if (!$update || $update && isset($condition['operator'])) {
$operatorValidator = new CSetValidator(array('values' => get_operators_by_conditiontype($condition['conditiontype'])));
if (!$operatorValidator->validate($condition['operator'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition operator.'));
}
}
if (!$update || $update && isset($condition['value'])) {
// validate condition values depending on condition type
switch ($condition['conditiontype']) {
case CONDITION_TYPE_HOST_GROUP:
if (!$condition['value']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
}
$hostGroupIdsAll[$condition['value']] = $condition['value'];
break;
case CONDITION_TYPE_TEMPLATE:
if (!$condition['value']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
}
$templateIdsAll[$condition['value']] = $condition['value'];
break;
case CONDITION_TYPE_TRIGGER:
if (!$condition['value']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
}
$triggerIdsAll[$condition['value']] = $condition['value'];
break;
case CONDITION_TYPE_HOST:
if (!$condition['value']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
}
$hostIdsAll[$condition['value']] = $condition['value'];
break;
case CONDITION_TYPE_DRULE:
if (!$condition['value']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
}
$discoveryRuleIdsAll[$condition['value']] = $condition['value'];
break;
case CONDITION_TYPE_DCHECK:
if (!$condition['value']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
}
$proxyIdsAll[$condition['value']] = $condition['value'];
break;
case CONDITION_TYPE_PROXY:
if (!$condition['value']) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
}
$proxyidsAll[$condition['value']] = $condition['value'];
break;
case CONDITION_TYPE_DOBJECT:
if (zbx_empty($condition['value'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
} elseif (!$discoveryObjectValidator->validate($condition['value'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition discovery object.'));
}
break;
case CONDITION_TYPE_TIME_PERIOD:
if (!$timePeriodValidator->validate($condition['value'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, $timePeriodValidator->getError());
}
break;
case CONDITION_TYPE_DHOST_IP:
if (zbx_empty($condition['value'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
} else {
if (!validate_ip_range($condition['value'])) {
self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect action condition ip "%1$s".', $condition['value']));
//.........这里部分代码省略.........
示例5: CVar
break;
case CONDITION_TYPE_HOST:
$tblNewCond->addItem(new CVar('new_condition[value]', '0'));
$rowCondition[] = array(new CTextBox('host', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?writeonly=1&dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=host&srctbl=hosts" . "&srcfld1=hostid&srcfld2=host',450,450);", 'T'));
break;
case CONDITION_TYPE_TRIGGER:
$tblNewCond->addItem(new CVar('new_condition[value]', '0'));
$rowCondition[] = array(new CTextBox('trigger', '', 20, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?writeonly=1&dstfrm=" . S_ACTION . "&dstfld1=new_condition%5Bvalue%5D&dstfld2=trigger&srctbl=triggers" . "&srcfld1=triggerid&srcfld2=description');", 'T'));
break;
case CONDITION_TYPE_TRIGGER_NAME:
$rowCondition[] = new CTextBox('new_condition[value]', "", 40);
break;
case CONDITION_TYPE_TRIGGER_VALUE:
$cmbCondVal = new CComboBox('new_condition[value]');
foreach (array(TRIGGER_VALUE_FALSE, TRIGGER_VALUE_TRUE) as $tr_val) {
$cmbCondVal->addItem($tr_val, trigger_value2str($tr_val));
}
$rowCondition[] = $cmbCondVal;
break;
case CONDITION_TYPE_TIME_PERIOD:
$rowCondition[] = new CTextBox('new_condition[value]', "1-7,00:00-23:59", 40);
break;
case CONDITION_TYPE_TRIGGER_SEVERITY:
$cmbCondVal = new CComboBox('new_condition[value]');
foreach (array(TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER) as $id) {
$cmbCondVal->addItem($id, get_severity_description($id));
}
$rowCondition[] = $cmbCondVal;
break;
case CONDITION_TYPE_MAINTENANCE:
$rowCondition[] = new CCol(S_MAINTENANCE_SMALL);
示例6: CMultiSelect
case CONDITION_TYPE_TEMPLATE:
$condition = new CMultiSelect(array('name' => 'new_condition[value][]', 'objectName' => 'templates', 'objectOptions' => array('editable' => true), 'defaultValue' => 0));
break;
case CONDITION_TYPE_HOST:
$condition = new CMultiSelect(array('name' => 'new_condition[value][]', 'objectName' => 'hosts', 'objectOptions' => array('editable' => true), 'defaultValue' => 0));
break;
case CONDITION_TYPE_TRIGGER:
$condition = new CMultiSelect(array('name' => 'new_condition[value][]', 'objectName' => 'triggers', 'objectOptions' => array('editable' => true), 'defaultValue' => 0));
break;
case CONDITION_TYPE_TRIGGER_NAME:
$condition = new CTextBox('new_condition[value]', '', ZBX_TEXTBOX_STANDARD_SIZE);
break;
case CONDITION_TYPE_TRIGGER_VALUE:
$condition = new CComboBox('new_condition[value]');
foreach (array(TRIGGER_VALUE_FALSE, TRIGGER_VALUE_TRUE) as $trigerValue) {
$condition->addItem($trigerValue, trigger_value2str($trigerValue));
}
break;
case CONDITION_TYPE_TIME_PERIOD:
$condition = new CTextBox('new_condition[value]', ZBX_DEFAULT_INTERVAL, ZBX_TEXTBOX_STANDARD_SIZE);
break;
case CONDITION_TYPE_TRIGGER_SEVERITY:
$condition = new CComboBox('new_condition[value]');
$condition->addItems(getSeverityCaption());
break;
case CONDITION_TYPE_MAINTENANCE:
$condition = new CCol(_('maintenance'));
break;
case CONDITION_TYPE_NODE:
$conditionFormList->addItem(new CVar('new_condition[value]', '0'));
$condition = array(new CTextBox('node', '', ZBX_TEXTBOX_STANDARD_SIZE, 'yes'), SPACE, new CButton('btn1', _('Select'), 'return PopUp("popup.php?srctbl=nodes&srcfld1=nodeid&srcfld2=name' . '&dstfrm=' . $actionForm->getName() . '&dstfld1=new_condition_value&dstfld2=node' . '&writeonly=1", 450, 450);', 'link_menu'));
示例7: condition_value2str
function condition_value2str($conditiontype, $value)
{
switch ($conditiontype) {
case CONDITION_TYPE_HOST_GROUP:
$group = get_hostgroup_by_groupid($value);
$str_val = '';
if (id2nodeid($value) != get_current_nodeid()) {
$str_val = get_node_name_by_elid($value, true);
}
$str_val .= $group['name'];
break;
case CONDITION_TYPE_TRIGGER:
$str_val = expand_trigger_description($value);
break;
case CONDITION_TYPE_HOST:
case CONDITION_TYPE_HOST_TEMPLATE:
$host = get_host_by_hostid($value);
$str_val = '';
if (id2nodeid($value) != get_current_nodeid()) {
$str_val = get_node_name_by_elid($value, true);
}
$str_val .= $host['host'];
break;
case CONDITION_TYPE_TRIGGER_NAME:
$str_val = $value;
break;
case CONDITION_TYPE_TRIGGER_VALUE:
$str_val = trigger_value2str($value);
break;
case CONDITION_TYPE_TRIGGER_SEVERITY:
$str_val = get_severity_description($value);
break;
case CONDITION_TYPE_TIME_PERIOD:
$str_val = $value;
break;
case CONDITION_TYPE_MAINTENANCE:
$str_val = S_MAINTENANCE_SMALL;
break;
case CONDITION_TYPE_DHOST_IP:
$str_val = $value;
break;
case CONDITION_TYPE_DSERVICE_TYPE:
$str_val = discovery_check_type2str($value);
break;
case CONDITION_TYPE_DSERVICE_PORT:
$str_val = $value;
break;
case CONDITION_TYPE_DSTATUS:
$str_val = discovery_object_status2str($value);
break;
case CONDITION_TYPE_DUPTIME:
$str_val = $value;
break;
case CONDITION_TYPE_DVALUE:
$str_val = $value;
break;
case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
$str_val = $value ? S_ACK : S_NOT_ACK;
break;
case CONDITION_TYPE_APPLICATION:
$str_val = $value;
break;
default:
return S_UNKNOWN;
break;
}
return '"' . $str_val . '"';
}
示例8: condition_value2str
function condition_value2str($conditiontype, $value)
{
switch ($conditiontype) {
case CONDITION_TYPE_HOST_GROUP:
$group = get_hostgroup_by_groupid($value);
$str_val = '';
if (id2nodeid($value) != get_current_nodeid()) {
$str_val = get_node_name_by_elid($value, true, ': ');
}
$str_val .= $group['name'];
break;
case CONDITION_TYPE_TRIGGER:
$trig = CTrigger::get(array('triggerids' => $value, 'expandTriggerDescriptions' => true, 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_EXTEND, 'nodeids' => get_current_nodeid(true)));
$trig = reset($trig);
$host = reset($trig['hosts']);
$str_val = '';
if (id2nodeid($value) != get_current_nodeid()) {
$str_val = get_node_name_by_elid($value, true, ': ');
}
$str_val .= $host['host'] . ':' . $trig['description'];
break;
case CONDITION_TYPE_HOST:
case CONDITION_TYPE_HOST_TEMPLATE:
$host = get_host_by_hostid($value);
$str_val = '';
if (id2nodeid($value) != get_current_nodeid()) {
$str_val = get_node_name_by_elid($value, true, ': ');
}
$str_val .= $host['host'];
break;
case CONDITION_TYPE_TRIGGER_NAME:
case CONDITION_TYPE_HOST_NAME:
$str_val = $value;
break;
case CONDITION_TYPE_TRIGGER_VALUE:
$str_val = trigger_value2str($value);
break;
case CONDITION_TYPE_TRIGGER_SEVERITY:
$str_val = get_severity_description($value);
break;
case CONDITION_TYPE_TIME_PERIOD:
$str_val = $value;
break;
case CONDITION_TYPE_MAINTENANCE:
$str_val = S_MAINTENANCE_SMALL;
break;
case CONDITION_TYPE_NODE:
$node = get_node_by_nodeid($value);
$str_val = $node['name'];
break;
case CONDITION_TYPE_DRULE:
$drule = get_discovery_rule_by_druleid($value);
$str_val = $drule['name'];
break;
case CONDITION_TYPE_DCHECK:
$row = DBfetch(DBselect('SELECT DISTINCT r.name,c.dcheckid,c.type,c.key_,c.snmp_community,c.ports' . ' FROM drules r,dchecks c WHERE r.druleid=c.druleid AND c.dcheckid=' . $value));
$str_val = $row['name'] . ':' . discovery_check2str($row['type'], $row['snmp_community'], $row['key_'], $row['ports']);
break;
case CONDITION_TYPE_DOBJECT:
$str_val = discovery_object2str($value);
break;
case CONDITION_TYPE_PROXY:
$host = get_host_by_hostid($value);
$str_val = $host['host'];
break;
case CONDITION_TYPE_DHOST_IP:
$str_val = $value;
break;
case CONDITION_TYPE_DSERVICE_TYPE:
$str_val = discovery_check_type2str($value);
break;
case CONDITION_TYPE_DSERVICE_PORT:
$str_val = $value;
break;
case CONDITION_TYPE_DSTATUS:
$str_val = discovery_object_status2str($value);
break;
case CONDITION_TYPE_DUPTIME:
$str_val = $value;
break;
case CONDITION_TYPE_DVALUE:
$str_val = $value;
break;
case CONDITION_TYPE_EVENT_ACKNOWLEDGED:
$str_val = $value ? S_ACK : S_NOT_ACK;
break;
case CONDITION_TYPE_APPLICATION:
$str_val = $value;
break;
default:
return S_UNKNOWN;
break;
}
return '"' . $str_val . '"';
}
示例9: CSpan
}
$statusSpan = new CSpan(trigger_value2str($event['value']));
// add colors and blinking to span depending on configuration and trigger parameters
addTriggerValueStyle($statusSpan, $event['value'], $event['clock'], $event['acknowledged']);
// host JS menu link
$hostSpan = null;
if ($_REQUEST['hostid'] == 0) {
$hostSpan = new CSpan($host['name'], 'link_menu menu-host');
$scripts = $hostScripts[$host['hostid']];
$hostSpan->setAttribute('data-menu', hostMenuData($host, $scripts));
}
// action
$action = isset($actions[$event['eventid']]) ? $actions[$event['eventid']] : ' - ';
$table->addRow(array(new CLink(zbx_date2str(EVENTS_ACTION_TIME_FORMAT, $event['clock']), 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid'], 'action'), is_show_all_nodes() ? get_node_name_by_elid($event['objectid']) : null, $hostSpan, new CSpan($tr_desc, 'link_menu'), $statusSpan, getSeverityCell($trigger['priority'], null, !$event['value']), $event['duration'], $config['event_ack_enable'] ? $ack : null, $action));
if ($CSV_EXPORT) {
$csvRows[] = array(zbx_date2str(EVENTS_ACTION_TIME_FORMAT, $event['clock']), is_show_all_nodes() ? get_node_name_by_elid($event['objectid']) : null, $_REQUEST['hostid'] == 0 ? $host['name'] : null, $description, trigger_value2str($event['value']), getSeverityCaption($trigger['priority']), $event['duration'], $config['event_ack_enable'] ? $event['acknowledges'] ? _('Yes') : _('No') : null, strip_tags((string) $action));
}
}
} else {
$events = array();
$paging = getPagingLine($events);
}
}
if ($CSV_EXPORT) {
print zbx_toCSV($csvRows);
exit;
}
$table = array($paging, $table, $paging);
}
$events_wdgt->addItem($table);
// NAV BAR
示例10: make_popup_eventlist
/**
* Create table with trigger description and events.
*
* @param array $trigger An array of trigger data.
* @param string $trigger['triggerid'] Trigger ID to select events.
* @param string $trigger['description'] Trigger description.
* @param string $trigger['url'] Trigger URL.
* @param string $trigger['lastEvent']['eventid'] Last event ID
* @param string $backurl URL to return to.
*
* @return CDiv
*/
function make_popup_eventlist($trigger, $backurl)
{
// Show trigger description and URL.
$div = new CDiv();
if ($trigger['comments'] !== '') {
$div->addItem((new CDiv())->addItem(zbx_str2links($trigger['comments']))->addClass(ZBX_STYLE_OVERLAY_DESCR));
}
if ($trigger['url'] !== '') {
$div->addItem((new CDiv())->addItem(new CLink($trigger['url'], $trigger['url']))->addClass(ZBX_STYLE_OVERLAY_DESCR_URL));
}
// Select and show events.
$config = select_config();
$table = new CTableInfo();
// If acknowledges are turned on, we show 'ack' column.
if ($config['event_ack_enable']) {
$table->setHeader([_('Time'), _('Status'), _('Duration'), _('Age'), _('Ack')]);
} else {
$table->setHeader([_('Time'), _('Status'), _('Duration'), _('Age')]);
}
if ($trigger['lastEvent']) {
$events = API::Event()->get(['source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'output' => API_OUTPUT_EXTEND, 'objectids' => [$trigger['triggerid']], 'eventid_till' => $trigger['lastEvent']['eventid'], 'select_acknowledges' => API_OUTPUT_COUNT, 'sortfield' => ['clock', 'eventid'], 'sortorder' => ZBX_SORT_DOWN, 'limit' => ZBX_WIDGET_ROWS]);
$lclock = time();
foreach ($events as $event) {
$duration = zbx_date2age($lclock, $event['clock']);
$lclock = $event['clock'];
$eventStatusSpan = new CSpan(trigger_value2str($event['value']));
// add colors and blinking to span depending on configuration and trigger parameters
addTriggerValueStyle($eventStatusSpan, $event['value'], $event['clock'], $event['acknowledged']);
$table->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']), $eventStatusSpan, $duration, zbx_date2age($event['clock']), $config['event_ack_enable'] ? getEventAckState($event, $backurl) : null]);
}
}
$div->addItem($table);
return $div;
}
示例11: CDiv
if ($show_event_col) {
$severity_col->setColSpan(2);
}
// Unknown triggers
$unknown = SPACE;
if ($trigger['value_flags'] == TRIGGER_VALUE_FLAG_UNKNOWN) {
$unknown = new CDiv(SPACE, 'status_icon iconunknown');
$unknown->setHint($trigger['error'], '', 'on');
}
//----
$table->addRow(array($open_close, $config['event_ack_enable'] ? $show_event_col ? null : new CCheckBox('triggers[' . $trigger['triggerid'] . ']', 'no', null, $trigger['triggerid']) : null, $severity_col, $statusSpan, $unknown, $lastchange, zbx_date2age($trigger['lastchange']), $show_event_col ? SPACE : NULL, $to_ack, get_node_name_by_elid($trigger['triggerid']), $host, $tr_desc, new CLink(zbx_empty($trigger['comments']) ? _('Add') : _('Show'), 'tr_comments.php?triggerid=' . $trigger['triggerid'])), 'even_row');
if ($show_events != EVENTS_OPTION_NOEVENT) {
$i = 1;
foreach ($trigger['events'] as $enum => $row_event) {
$i++;
$eventStatusSpan = new CSpan(trigger_value2str($row_event['value']));
// add colors and blinking to span depending on configuration and trigger parameters
addTriggerValueStyle($eventStatusSpan, $row_event['value'], $row_event['clock'], $row_event['acknowledged']);
$statusSpan = new CCol($eventStatusSpan);
$statusSpan->setColSpan(2);
$ack = getEventAckState($row_event, true);
if ($row_event['acknowledged'] == 0 && $row_event['value'] == TRIGGER_VALUE_TRUE) {
$ack_cb = new CCheckBox('events[' . $row_event['eventid'] . ']', 'no', NULL, $row_event['eventid']);
} else {
$ack_cb = SPACE;
}
$clock = new CLink(zbx_date2str(_('d M Y H:i:s'), $row_event['clock']), 'tr_events.php?triggerid=' . $trigger['triggerid'] . '&eventid=' . $row_event['eventid']);
$next_clock = isset($trigger['events'][$enum - 1]) ? $trigger['events'][$enum - 1]['clock'] : time();
$empty_col = new CCol(SPACE);
$empty_col->setColSpan(3);
$ack_cb_col = new CCol($ack_cb);
示例12: get_history_of_discovery_events
function get_history_of_discovery_events($end_time, $limit, &$last_clock = null)
{
$table = new CTableInfo(S_NO_EVENTS_FOUND);
$table->setHeader(array(S_TIME, S_IP, S_DESCRIPTION, S_STATUS));
$col = 0;
$clock = array();
$dsc_events = array();
$sql = 'SELECT DISTINCT e.source,e.object,e.objectid,e.clock,e.value ' . ' FROM events e' . ' WHERE e.source=' . EVENT_SOURCE_DISCOVERY . ' AND e.clock<' . $end_time . ' ORDER BY e.clock DESC';
$db_events = DBselect($sql, $limit);
while ($event_data = DBfetch($db_events)) {
switch ($event_data['object']) {
case EVENT_OBJECT_DHOST:
$sql = 'SELECT ip FROM dhosts WHERE dhostid=' . $event_data['objectid'];
if ($object_data = DBfetch(DBselect($sql))) {
$event_data['object_data'] = $object_data;
} else {
$event_data['object_data']['ip'] = S_UNKNOWN;
}
$event_data['description'] = SPACE;
break;
case EVENT_OBJECT_DSERVICE:
$sql = 'SELECT h.ip,s.type,s.port ' . ' FROM dhosts h,dservices s ' . ' WHERE h.dhostid=s.dhostid ' . ' AND s.dserviceid=' . $event_data['objectid'];
if ($object_data = DBfetch(DBselect($sql))) {
$event_data['object_data'] = $object_data;
} else {
$event_data['object_data']['ip'] = S_UNKNOWN;
$event_data['object_data']['type'] = S_UNKNOWN;
$event_data['object_data']['port'] = S_UNKNOWN;
}
$event_data['description'] = S_SERVICE . ': ' . discovery_check_type2str($event_data['object_data']['type']) . '; ' . S_PORT . ': ' . $event_data['object_data']['port'];
break;
default:
continue;
}
if (!isset($event_data['object_data'])) {
continue;
}
$clock[] = $event_data['clock'];
$dsc_events[] = $event_data;
}
$last_clock = !empty($clock) ? min($clock) : null;
order_page_result($dsc_events, 'clock', ZBX_SORT_DOWN);
foreach ($dsc_events as $num => $event_data) {
$value = new CCol(trigger_value2str($event_data['value']), get_trigger_value_style($event_data['value']));
$table->addRow(array(date('Y.M.d H:i:s', $event_data['clock']), $event_data['object_data']['ip'], $event_data['description'], $value));
}
return $table;
}
示例13: get_history_of_discovery_events
function get_history_of_discovery_events($start, $end)
{
$sql_cond = ' AND e.clock>' . $start;
$sql_cond .= ' AND e.clock<' . $end;
$sql = 'SELECT DISTINCT e.source,e.object,e.objectid,e.clock,e.value ' . ' FROM events e' . ' WHERE e.source=' . EVENT_SOURCE_DISCOVERY . $sql_cond . order_by('e.clock');
$db_events = DBselect($sql);
$table = new CTableInfo(S_NO_EVENTS_FOUND);
$table->SetHeader(array(S_TIME, S_IP, S_DESCRIPTION, S_STATUS));
$col = 0;
while ($event_data = DBfetch($db_events)) {
$value = new CCol(trigger_value2str($event_data['value']), get_trigger_value_style($event_data['value']));
switch ($event_data['object']) {
case EVENT_OBJECT_DHOST:
$object_data = DBfetch(DBselect('SELECT ip FROM dhosts WHERE dhostid=' . $event_data['objectid']));
$description = SPACE;
break;
case EVENT_OBJECT_DSERVICE:
$object_data = DBfetch(DBselect('SELECT h.ip,s.type,s.port ' . ' FROM dhosts h,dservices s ' . ' WHERE h.dhostid=s.dhostid ' . ' AND s.dserviceid=' . $event_data['objectid']));
$description = S_SERVICE . ': ' . discovery_check_type2str($object_data['type']) . '; ' . S_PORT . ': ' . $object_data['port'];
break;
default:
continue;
}
if (!$object_data) {
continue;
}
$table->AddRow(array(date('Y.M.d H:i:s', $event_data['clock']), $object_data['ip'], $description, $value));
$col++;
}
return $table;
}
示例14: make_popup_eventlist
function make_popup_eventlist($eventid, $trigger_type, $triggerid)
{
$config = select_config();
$table = new CTableInfo();
//if acknowledges are turned on, we show 'ack' column
if ($config['event_ack_enable']) {
$table->setHeader(array(S_TIME, S_STATUS, S_DURATION, S_AGE, S_ACK));
} else {
$table->setHeader(array(S_TIME, S_STATUS, S_DURATION, S_AGE));
}
$table->setAttribute('style', 'width: 400px;');
$event_list = array();
$sql = 'SELECT * ' . ' FROM events ' . ' WHERE eventid<=' . $eventid . ' AND object=' . EVENT_OBJECT_TRIGGER . ' AND objectid=' . $triggerid . ' ORDER BY eventid DESC';
$db_events = DBselect($sql, ZBX_WIDGET_ROWS);
$count = 0;
while ($event = DBfetch($db_events)) {
if (!empty($event_list) && $event_list[$count]['value'] != $event['value']) {
$count++;
} else {
if (!empty($event_list) && $event_list[$count]['value'] == $event['value'] && $trigger_type == TRIGGER_MULT_EVENT_ENABLED && $event['value'] == TRIGGER_VALUE_TRUE) {
$count++;
}
}
$event_list[$count] = $event;
}
$lclock = time();
foreach ($event_list as $id => $event) {
$duration = zbx_date2age($lclock, $event['clock']);
$lclock = $event['clock'];
$value = new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value']));
// ack +++
$ack = new CSpan(S_NO, 'on');
if ($event['acknowledged']) {
$ack = new CSpan(S_YES, 'off');
}
// ---
$table->addRow(array(zbx_date2str(S_EVENTS_POPUP_EVENT_LIST_DATE_FORMAT, $event['clock']), $value, $duration, zbx_date2age($event['clock']), $config['event_ack_enable'] ? $ack : NULL));
}
return $table;
}
示例15: validate
/**
* Returns true if the given $value is valid, or set's an error and returns false otherwise.
*
*
* @param $condition
*
* @return bool
*/
public function validate($condition)
{
// build validators
$timePeriodValidator = new CTimePeriodValidator();
$discoveryCheckTypeValidator = new CLimitedSetValidator(array('values' => array_keys(discovery_check_type2str())));
$discoveryObjectStatusValidator = new CLimitedSetValidator(array('values' => array_keys(discovery_object_status2str())));
$triggerSeverityValidator = new CLimitedSetValidator(array('values' => array(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER)));
$discoveryObjectValidator = new CLimitedSetValidator(array('values' => array_keys(discovery_object2str())));
$triggerValueValidator = new CLimitedSetValidator(array('values' => array_keys(trigger_value2str())));
$eventTypeValidator = new CLimitedSetValidator(array('values' => array_keys(eventType())));
$conditionValue = $condition['value'];
// validate condition values depending on condition type
switch ($condition['conditiontype']) {
case CONDITION_TYPE_HOST_GROUP:
if (!$conditionValue) {
$this->setError(_('Empty action condition.'));
}
break;
case CONDITION_TYPE_TEMPLATE:
if (!$conditionValue) {
$this->setError(_('Empty action condition.'));
}
break;
case CONDITION_TYPE_TRIGGER:
if (!$conditionValue) {
$this->setError(_('Empty action condition.'));
}
break;
case CONDITION_TYPE_HOST:
if (!$conditionValue) {
$this->setError(_('Empty action condition.'));
}
break;
case CONDITION_TYPE_DRULE:
if (!$conditionValue) {
$this->setError(_('Empty action condition.'));
}
break;
case CONDITION_TYPE_DCHECK:
if (!$conditionValue) {
$this->setError(_('Empty action condition.'));
}
break;
case CONDITION_TYPE_PROXY:
if (!$conditionValue) {
$this->setError(_('Empty action condition.'));
}
break;
case CONDITION_TYPE_DOBJECT:
if (zbx_empty($conditionValue)) {
$this->setError(_('Empty action condition.'));
} elseif (!$discoveryObjectValidator->validate($conditionValue)) {
$this->setError(_('Incorrect action condition discovery object.'));
}
break;
case CONDITION_TYPE_TIME_PERIOD:
if (!$timePeriodValidator->validate($conditionValue)) {
$this->setError($timePeriodValidator->getError());
}
break;
case CONDITION_TYPE_DHOST_IP:
$ipRangeValidator = new CIPRangeValidator();
if (zbx_empty($conditionValue)) {
$this->setError(_('Empty action condition.'));
} elseif (!$ipRangeValidator->validate($conditionValue)) {
$this->setError($ipRangeValidator->getError());
}
break;
case CONDITION_TYPE_DSERVICE_TYPE:
if (zbx_empty($conditionValue)) {
$this->setError(_('Empty action condition.'));
} elseif (!$discoveryCheckTypeValidator->validate($conditionValue)) {
$this->setError(_('Incorrect action condition discovery check.'));
}
break;
case CONDITION_TYPE_DSERVICE_PORT:
if (zbx_empty($conditionValue)) {
$this->setError(_('Empty action condition.'));
} elseif (!validate_port_list($conditionValue)) {
$this->setError(_s('Incorrect action condition port "%1$s".', $conditionValue));
}
break;
case CONDITION_TYPE_DSTATUS:
if (zbx_empty($conditionValue)) {
$this->setError(_('Empty action condition.'));
} elseif (!$discoveryObjectStatusValidator->validate($conditionValue)) {
$this->setError(_('Incorrect action condition discovery status.'));
}
break;
case CONDITION_TYPE_MAINTENANCE:
if (!zbx_empty($conditionValue)) {
$this->setError(_('Maintenance action condition value must be empty.'));
//.........这里部分代码省略.........