当前位置: 首页>>代码示例>>PHP>>正文


PHP CEvent::get方法代码示例

本文整理汇总了PHP中CEvent::get方法的典型用法代码示例。如果您正苦于以下问题:PHP CEvent::get方法的具体用法?PHP CEvent::get怎么用?PHP CEvent::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CEvent的用法示例。


在下文中一共展示了CEvent::get方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: foreach

    foreach ($trigger['hosts'] as $tr_hosts) {
        $tr_hostids[$tr_hosts['hostid']] = $tr_hosts['hostid'];
    }
}
$scripts_by_hosts = Cscript::getScriptsByHosts($tr_hostids);
if ($show_events != EVENTS_OPTION_NOEVENT) {
    $ev_options = array('nodeids' => get_current_nodeid(), 'triggerids' => zbx_objectValues($triggers, 'triggerid'), 'nopermissions' => 1, 'output' => API_OUTPUT_EXTEND, 'time_from' => time() - $config['event_expire'] * 86400, 'time_till' => time(), 'sortfield' => 'eventid', 'sortorder' => ZBX_SORT_DOWN);
    switch ($show_events) {
        case EVENTS_OPTION_ALL:
            break;
        case EVENTS_OPTION_NOT_ACK:
            $ev_options['acknowledged'] = 0;
            $ev_options['value'] = TRIGGER_VALUE_TRUE;
            break;
    }
    $events = CEvent::get($ev_options);
    order_result($events, 'clock', ZBX_SORT_DOWN);
    foreach ($events as $enum => $event) {
        $triggers[$event['objectid']]['events'][] = $event;
    }
}
foreach ($triggers as $tnum => $trigger) {
    $trigger['desc'] = $description = expand_trigger_description($trigger['triggerid']);
    $items = array();
    $used_hosts = array();
    foreach ($trigger['hosts'] as $th) {
        $used_hosts[$th['hostid']] = $th['host'];
    }
    $used_host_count = count($used_hosts);
    foreach ($trigger['items'] as $inum => $item) {
        $item_description = item_description($item);
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:tr_status.php

示例2: reset

    $events = CEvent::get($options);
    $event = reset($events);
    $event_trigger = reset($event['triggers']);
    $event_acknowledged = $event['acknowledged'];
    $_REQUEST['events'] = $_REQUEST['eventid'];
}
if (isset($_REQUEST['save']) || isset($_REQUEST['saveandreturn'])) {
    if ($bulk) {
        $_REQUEST['message'] .= ($_REQUEST['message'] == '' ? '' : "\n\r") . S_SYS_BULK_ACKNOWLEDGE;
    }
    if (isset($_REQUEST['events'])) {
        $_REQUEST['events'] = zbx_toObject($_REQUEST['events'], 'eventid');
    } else {
        if (isset($_REQUEST['triggers'])) {
            $options = array('output' => API_OUTPUT_SHORTEN, 'acknowledged' => 0, 'triggerids' => $_REQUEST['triggers']);
            $_REQUEST['events'] = CEvent::get($options);
        }
    }
    $eventsData = array('eventids' => zbx_objectValues($_REQUEST['events'], 'eventid'), 'message' => $_REQUEST['message']);
    $result = CEvent::acknowledge($eventsData);
    show_messages($result, S_EVENT_ACKNOWLEDGED, S_CANNOT_ACKNOWLEDGE_EVENT);
    if ($result) {
        $event_acknowledged = true;
        add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, S_ACKNOWLEDGE_ADDED . ' [' . $bulk ? ' BULK ACKNOWLEDGE ' : expand_trigger_description_by_data($event_trigger) . ']' . ' [' . $_REQUEST['message'] . ']');
    }
    if (isset($_REQUEST['saveandreturn'])) {
        $url = new CUrl(urldecode($_REQUEST['backurl']));
        jsRedirect($url->getUrl());
        exit;
    }
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:31,代码来源:acknow.php

示例3: make_system_status

function make_system_status($filter)
{
    $config = select_config();
    $table = new CTableInfo();
    $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST_GROUP, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_DISASTER]) ? S_DISASTER : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_HIGH]) ? S_HIGH : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_AVERAGE]) ? S_AVERAGE : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_WARNING]) ? S_WARNING : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_INFORMATION]) ? S_INFORMATION : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_NOT_CLASSIFIED]) ? S_NOT_CLASSIFIED : null));
    // SELECT HOST GROUPS {{{
    $options = array('nodeids' => get_current_nodeid(), 'monitored_hosts' => 1, 'groupids' => $filter['groupids'], 'output' => API_OUTPUT_EXTEND);
    $groups = CHostGroup::get($options);
    $groups = zbx_toHash($groups, 'groupid');
    order_result($groups, 'name');
    $groupids = array();
    foreach ($groups as $gnum => $group) {
        $groupids[] = $group['groupid'];
        $group['tab_priority'] = array();
        $group['tab_priority'][TRIGGER_SEVERITY_DISASTER] = array('count' => 0, 'triggers' => array(), 'count_unack' => 0, 'triggers_unack' => array());
        $group['tab_priority'][TRIGGER_SEVERITY_HIGH] = array('count' => 0, 'triggers' => array(), 'count_unack' => 0, 'triggers_unack' => array());
        $group['tab_priority'][TRIGGER_SEVERITY_AVERAGE] = array('count' => 0, 'triggers' => array(), 'count_unack' => 0, 'triggers_unack' => array());
        $group['tab_priority'][TRIGGER_SEVERITY_WARNING] = array('count' => 0, 'triggers' => array(), 'count_unack' => 0, 'triggers_unack' => array());
        $group['tab_priority'][TRIGGER_SEVERITY_INFORMATION] = array('count' => 0, 'triggers' => array(), 'count_unack' => 0, 'triggers_unack' => array());
        $group['tab_priority'][TRIGGER_SEVERITY_NOT_CLASSIFIED] = array('count' => 0, 'triggers' => array(), 'count_unack' => 0, 'triggers_unack' => array());
        $groups[$group['groupid']] = $group;
    }
    // }}} SELECT HOST GROUPS
    // SELECT TRIGGERS {{{
    $options = array('nodeids' => get_current_nodeid(), 'groupids' => $groupids, 'monitored' => 1, 'maintenance' => $filter['maintenance'], 'expandData' => 1, 'skipDependent' => 1, 'expandDescription' => 1, 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE), 'output' => API_OUTPUT_EXTEND);
    if ($filter['extAck'] == EXTACK_OPTION_UNACK) {
        $options['withLastEventUnacknowledged'] = 1;
    }
    $triggers = CTrigger::get($options);
    order_result($triggers, 'lastchange', ZBX_SORT_DOWN);
    foreach ($triggers as $tnum => $trigger) {
        $options = array('nodeids' => get_current_nodeid(), 'triggerids' => $trigger['triggerid'], 'object' => EVENT_SOURCE_TRIGGERS, 'value' => TRIGGER_VALUE_TRUE, 'output' => API_OUTPUT_EXTEND, 'nopermissions' => 1, 'limit' => 1, 'sortfield' => 'eventid', 'sortorder' => ZBX_SORT_DOWN);
        $event = CEvent::get($options);
        if (empty($event)) {
            $trigger['event'] = array('acknowledged' => 1, 'clock' => $trigger['lastchange']);
        } else {
            $trigger['event'] = reset($event);
        }
        foreach ($trigger['groups'] as $group) {
            if ($groups[$group['groupid']]['tab_priority'][$trigger['priority']]['count'] < 30) {
                $groups[$group['groupid']]['tab_priority'][$trigger['priority']]['triggers'][] = $trigger;
            }
            if ($groups[$group['groupid']]['tab_priority'][$trigger['priority']]['count_unack'] < 30 && !$trigger['event']['acknowledged']) {
                $groups[$group['groupid']]['tab_priority'][$trigger['priority']]['triggers_unack'][] = $trigger;
            }
            $groups[$group['groupid']]['tab_priority'][$trigger['priority']]['count']++;
            if (!$trigger['event']['acknowledged']) {
                $groups[$group['groupid']]['tab_priority'][$trigger['priority']]['count_unack']++;
            }
        }
    }
    unset($triggers);
    order_result($groups, 'name');
    // }}} SELECT TRIGGERS
    foreach ($groups as $gnum => $group) {
        $group_row = new CRow();
        if (is_show_all_nodes()) {
            $group_row->addItem(get_node_name_by_elid($group['groupid']));
        }
        $name = new CLink($group['name'], 'tr_status.php?groupid=' . $group['groupid'] . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE);
        $group_row->addItem($name);
        foreach ($group['tab_priority'] as $severity => $data) {
            if (!is_null($filter['severity']) && !isset($filter['severity'][$severity])) {
                continue;
            }
            if ($data['count'] && in_array($filter['extAck'], array(EXTACK_OPTION_ALL, EXTACK_OPTION_BOTH))) {
                $table_inf = new CTableInfo();
                $table_inf->setAttribute('style', 'width: 400px;');
                $table_inf->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST, S_ISSUE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
                foreach ($data['triggers'] as $tnum => $trigger) {
                    $event = $trigger['event'];
                    if ($config['event_ack_enable'] && isset($event['eventid'])) {
                        $ack = $event['acknowledged'] ? new CLink(S_YES, 'acknow.php?eventid=' . $event['eventid'], 'off') : new CLink(S_NO, 'acknow.php?eventid=' . $event['eventid'], 'on');
                        $actions = get_event_actions_status($event['eventid']);
                    } else {
                        $ack = '-';
                        $actions = S_NO_DATA_SMALL;
                    }
                    $table_inf->addRow(array(get_node_name_by_elid($trigger['triggerid']), $trigger['host'], new CCol($trigger['description'], get_severity_style($trigger['priority'])), zbx_date2age($event['clock']), $config['event_ack_enable'] ? new CCol($ack, 'center') : NULL, $actions));
                }
            }
            if ($data['count_unack'] && in_array($filter['extAck'], array(EXTACK_OPTION_UNACK, EXTACK_OPTION_BOTH))) {
                $table_inf_unack = new CTableInfo();
                $table_inf_unack->setAttribute('style', 'width: 400px;');
                $table_inf_unack->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST, S_ISSUE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
                foreach ($data['triggers_unack'] as $tnum => $trigger) {
                    $event = $trigger['event'];
                    if ($config['event_ack_enable']) {
                        $ack = new CLink(S_NO, 'acknow.php?eventid=' . $event['eventid'], 'on');
                        $actions = get_event_actions_status($event['eventid']);
                    } else {
                        $ack = '-';
                        $actions = S_NO_DATA_SMALL;
                    }
                    $table_inf_unack->addRow(array(get_node_name_by_elid($trigger['triggerid']), $trigger['host'], new CCol($trigger['description'], get_severity_style($trigger['priority'])), zbx_date2age($event['clock']), $config['event_ack_enable'] ? new CCol($ack, 'center') : NULL, $actions));
                }
            }
            switch ($filter['extAck']) {
                case EXTACK_OPTION_ALL:
                    $trigger_count = new CSpan($data['count'], 'pointer');
//.........这里部分代码省略.........
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:101,代码来源:blocks.inc.php

示例4: getLastEvents

function getLastEvents($options)
{
    if (!isset($options['limit'])) {
        $options['limit'] = 15;
    }
    $triggerOptions = array('filter' => array(), 'skipDependent' => 1, 'select_hosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND, 'expandDescription' => 1, 'sortfield' => 'lastchange', 'sortorder' => ZBX_SORT_DOWN, 'limit' => $options['limit']);
    $eventOptions = array('object' => EVENT_OBJECT_TRIGGER, 'output' => API_OUTPUT_EXTEND, 'sortfield' => 'clock', 'sortorder' => ZBX_SORT_DOWN, 'limit' => $options['limit']);
    if (isset($options['nodeids'])) {
        $triggerOptions['nodeids'] = $options['nodeids'];
    }
    if (isset($options['priority'])) {
        $triggerOptions['filter']['priority'] = $options['priority'];
    }
    if (isset($options['monitored'])) {
        $triggerOptions['monitored'] = $options['monitored'];
    }
    if (isset($options['lastChangeSince'])) {
        $triggerOptions['lastChangeSince'] = $options['lastChangeSince'];
        $eventOptions['time_from'] = $options['lastChangeSince'];
    }
    if (isset($options['value'])) {
        $triggerOptions['filter']['value'] = $options['value'];
        $eventOptions['value'] = $options['value'];
    }
    // triggers
    $triggers = CTrigger::get($triggerOptions);
    $triggers = zbx_toHash($triggers, 'triggerid');
    // events
    $eventOptions['triggerids'] = zbx_objectValues($triggers, 'triggerid');
    $events = CEvent::get($eventOptions);
    $sortClock = array();
    $sortEvent = array();
    foreach ($events as $enum => $event) {
        if (!isset($triggers[$event['objectid']])) {
            continue;
        }
        $events[$enum]['trigger'] = $triggers[$event['objectid']];
        $events[$enum]['host'] = reset($events[$enum]['trigger']['hosts']);
        $sortClock[$enum] = $event['clock'];
        $sortEvent[$enum] = $event['eventid'];
    }
    array_multisort($sortClock, SORT_DESC, $sortEvent, SORT_DESC, $events);
    return $events;
}
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:44,代码来源:events.inc.php


注:本文中的CEvent::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。