Example #1
0
function make_small_eventlist($startEvent)
{
    $config = select_config();
    $table = new CTableInfo(_('No events found.'));
    $table->setHeader(array(_('Time'), _('Status'), _('Duration'), _('Age'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
    $clock = $startEvent['clock'];
    $events = API::Event()->get(array('source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'objectids' => $startEvent['objectid'], 'eventid_till' => $startEvent['eventid'], 'output' => API_OUTPUT_EXTEND, 'select_acknowledges' => API_OUTPUT_COUNT, 'sortfield' => array('clock', 'eventid'), 'sortorder' => ZBX_SORT_DOWN, 'limit' => 20));
    $sortFields = array(array('field' => 'clock', 'order' => ZBX_SORT_DOWN), array('field' => 'eventid', 'order' => ZBX_SORT_DOWN));
    CArrayHelper::sort($events, $sortFields);
    $actions = getEventActionsStatHints(zbx_objectValues($events, 'eventid'));
    foreach ($events as $event) {
        $lclock = $clock;
        $duration = zbx_date2age($lclock, $event['clock']);
        $clock = $event['clock'];
        if (bccomp($startEvent['eventid'], $event['eventid']) == 0 && ($nextevent = get_next_event($event, $events))) {
            $duration = zbx_date2age($nextevent['clock'], $clock);
        } elseif (bccomp($startEvent['eventid'], $event['eventid']) == 0) {
            $duration = zbx_date2age($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']);
        $ack = getEventAckState($event, true);
        $table->addRow(array(new CLink(zbx_date2str(_('d M Y H:i:s'), $event['clock']), 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid'], 'action'), $eventStatusSpan, $duration, zbx_date2age($event['clock']), $config['event_ack_enable'] ? $ack : null, isset($actions[$event['eventid']]) ? $actions[$event['eventid']] : SPACE));
    }
    return $table;
}
Example #2
0
            }
            // Actions
            $actions = get_event_actions_status($event['eventid']);
            if ($config['event_ack_enable']) {
                if ($event['acknowledged'] == 1) {
                    $ack = new CLink(S_YES, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file']);
                } else {
                    $ack = new CLink(S_NO, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file'], 'on');
                }
            }
            $description = expand_trigger_description_by_data(zbx_array_merge($trigger, array('clock' => $event['clock'])), ZBX_FLAG_EVENT);
            $tr_desc = new CSpan($description, 'pointer');
            $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $event['clock'] . "'})," . zbx_jsvalue($items, true) . ");");
            // Duration
            $tr_event = $event + $trigger;
            if ($next_event = get_next_event($tr_event, $events, $_REQUEST['hide_unknown'])) {
                $event['duration'] = zbx_date2age($tr_event['clock'], $next_event['clock']);
            } else {
                $event['duration'] = zbx_date2age($tr_event['clock']);
            }
            $table->addRow(array(new CLink(zbx_date2str(S_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, $_REQUEST['hostid'] == 0 ? $host['host'] : null, new CSpan($tr_desc, 'link_menu'), new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value'])), new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'], $event['value'])), $event['duration'], $config['event_ack_enable'] ? $ack : NULL, $actions));
        }
    }
    $table = array($paging, $table, $paging);
    $jsmenu = new CPUMenu(null, 170);
    $jsmenu->InsertJavaScript();
}
$events_wdgt->addItem($table);
// NAV BAR
$timeline = array('period' => $effectiveperiod, 'starttime' => date('YmdHis', $starttime), 'usertime' => date('YmdHis', $till));
$dom_graph_id = 'scroll_events_id';
Example #3
0
 $sql_cond .= ' AND e.clock<' . $time_end;
 $table = new CTableInfo(S_NO_EVENTS_FOUND);
 $table->setHeader(array(make_sorting_link(S_TIME, 'clock'), is_show_all_nodes() ? S_NODE : null, $_REQUEST['hostid'] == 0 ? S_HOST : null, make_sorting_link(S_DESCRIPTION, 'desc'), make_sorting_link(S_STATUS, 'status'), make_sorting_link(S_SEVERITY, 'priority'), S_DURATION, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
 if (!empty($triggers)) {
     $clock = array();
     $events = array();
     $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged ' . ' FROM events e ' . ' WHERE ' . DBcondition('e.objectid', $triggerids) . ' AND (e.object+0)=' . EVENT_OBJECT_TRIGGER . $sql_cond . ' ORDER BY e.clock DESC';
     $result = DBselect($sql, 0 == $show_unknown ? $limit * 50 : $limit);
     while (($row = DBfetch($result)) && $col < $limit) {
         $row = array_merge($triggers[$row['triggerid']], $row);
         if (0 == $show_unknown && !event_initial_time($row, $show_unknown)) {
             continue;
         }
         $row['desc'] = expand_trigger_description_by_data($row, ZBX_FLAG_EVENT);
         $row['duration'] = zbx_date2age($row['clock']);
         if ($next_event = get_next_event($row, $show_unknown)) {
             $row['duration'] = zbx_date2age($row['clock'], $next_event['clock']);
         }
         $row['value'] = new CCol(trigger_value2str($row['value']), get_trigger_value_style($row['value']));
         $col++;
         $clock[] = $row['clock'];
         $events[] = $row;
     }
     $last_clock = !empty($clock) ? min($clock) : null;
     order_page_result($events, 'clock', ZBX_SORT_DOWN);
     foreach ($events as $num => $row) {
         // Actions
         $actions = get_event_actions_status($row['eventid']);
         //--------
         if ($config['event_ack_enable']) {
             if ($row['acknowledged'] == 1) {
Example #4
0
 $hostids = zbx_objectValues($hosts, 'hostid');
 $hosts = API::Host()->get(['output' => ['name', 'hostid', 'status'], 'hostids' => $hostids, 'selectGraphs' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true]);
 // fetch scripts for the host JS menu
 if (!$csvExport && $pageFilter->hostid == 0) {
     $scripts = API::Script()->getScriptsByHosts($hostids);
 }
 // actions
 $actions = makeEventsActions(zbx_objectValues($events, 'eventid'));
 // 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)]);
 $items = array();
 foreach ($trigger['items'] as $item) {
     $i = array();
     $i['itemid'] = $item['itemid'];
     $i['value_type'] = $item['value_type'];
     // ZBX-3059: So it would be possible to show different caption for history for chars and numbers (KB)
     $i['action'] = str_in_array($item['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues';
     $i['name'] = itemName($item);
     $items[] = $i;
 }
 $ack = getEventAckState($event, true);
 $description = CEventHelper::expandDescription(zbx_array_merge($trigger, array('clock' => $event['clock'], 'ns' => $event['ns'])));
 $tr_desc = new CSpan($description, 'pointer');
 $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " [{'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $event['clock'] . "'}]," . zbx_jsvalue($items, true) . ");");
 // duration
 if ($nextEvent = get_next_event($event, $events, $_REQUEST['showUnknown'])) {
     $event['duration'] = zbx_date2age($event['clock'], $nextEvent['clock']);
 } else {
     $event['duration'] = zbx_date2age($event['clock']);
 }
 $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
        foreach ($triggers as $trigger) {
            $hosts[] = reset($trigger['hosts']);
        }
        $hostids = zbx_objectValues($hosts, 'hostid');
        $hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'hostids' => $hostids, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
        // fetch scripts for the host JS menu
        if ($_REQUEST['hostid'] == 0) {
            $scripts = API::Script()->getScriptsByHosts($hostids);
        }
        // events
        foreach ($events as $event) {
            $trigger = $triggers[$event['objectid']];
            $host = reset($trigger['hosts']);
            $host = $hosts[$host['hostid']];
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $event['clock'], 'ns' => $event['ns'])));
            $endclock = ($nextEvent = get_next_event($event, $events)) ? $nextEvent['clock'] : time();
            if ($event['value'] == 1) {
                array_push($content, array('content' => $description, 'group' => $host['name'], 'start' => $event['clock'] * 1000, 'end' => $endclock * 1000));
            }
        }
    } else {
        $events = array();
    }
}
$chart = new CDiv();
$chart->setAttribute('id', 'tlchart');
$eventsWidget->addItem($chart);
$timeline = array('period' => $effectiveperiod, 'starttime' => date(TIMESTAMP_FORMAT, $starttime), 'usertime' => date(TIMESTAMP_FORMAT, $till));
$objData = array('id' => 'timeline_1', 'loadSBox' => 0, 'loadImage' => 0, 'loadScroll' => 1, 'dynamic' => 0, 'mainObject' => 1, 'periodFixed' => CProfile::get('web.events.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD);
zbx_add_post_js('jqBlink.blink();');
zbx_add_post_js('timeControl.addObject("scroll_events_id", ' . zbx_jsvalue($timeline) . ', ' . zbx_jsvalue($objData) . ');');
Example #7
0
function make_small_eventlist($startEvent, $backurl)
{
    $config = select_config();
    $table = (new CTableInfo())->setHeader([_('Time'), _('Status'), _('Duration'), _('Age'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')]);
    $clock = $startEvent['clock'];
    $events = API::Event()->get(['source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'objectids' => $startEvent['objectid'], 'eventid_till' => $startEvent['eventid'], 'output' => API_OUTPUT_EXTEND, 'select_acknowledges' => API_OUTPUT_COUNT, 'sortfield' => ['clock', 'eventid'], 'sortorder' => ZBX_SORT_DOWN, 'limit' => 20]);
    $sortFields = [['field' => 'clock', 'order' => ZBX_SORT_DOWN], ['field' => 'eventid', 'order' => ZBX_SORT_DOWN]];
    CArrayHelper::sort($events, $sortFields);
    $actions = makeEventsActions(zbx_objectValues($events, 'eventid'));
    foreach ($events as $event) {
        $lclock = $clock;
        $duration = zbx_date2age($lclock, $event['clock']);
        $clock = $event['clock'];
        if (bccomp($startEvent['eventid'], $event['eventid']) == 0 && ($nextevent = get_next_event($event, $events))) {
            $duration = zbx_date2age($nextevent['clock'], $clock);
        } elseif (bccomp($startEvent['eventid'], $event['eventid']) == 0) {
            $duration = zbx_date2age($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([(new CLink(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']), 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid']))->addClass('action'), $eventStatusSpan, $duration, zbx_date2age($event['clock']), $config['event_ack_enable'] ? getEventAckState($event, $backurl) : null, (new CCol(isset($actions[$event['eventid']]) ? $actions[$event['eventid']] : ''))->addClass(ZBX_STYLE_NOWRAP)]);
    }
    return $table;
}
Example #8
0
function make_event_details($eventid)
{
    $event = get_tr_event_by_eventid($eventid);
    $table = new CTableInfo();
    $table->AddRow(array(S_EVENT, expand_trigger_description($event['triggerid'])));
    $table->AddRow(array(S_TIME, date('Y.M.d H:i:s', $event['clock'])));
    $duration = zbx_date2age($event['clock']);
    if ($next_event = get_next_event($event, 1)) {
        $duration = zbx_date2age($event['clock'], $next_event['clock']);
    }
    if ($event["value"] == TRIGGER_VALUE_FALSE) {
        $value = new CCol(S_OK_BIG, "off");
    } elseif ($event["value"] == TRIGGER_VALUE_TRUE) {
        $value = new CCol(S_PROBLEM_BIG, "on");
    } else {
        $value = new CCol(S_UNKNOWN_BIG, "unknown");
    }
    $ack = '-';
    if ($event["value"] == 1 && $event["acknowledged"] == 1) {
        $db_acks = get_acknowledges_by_eventid($event["eventid"]);
        $rows = 0;
        while ($a = DBfetch($db_acks)) {
            $rows++;
        }
        $ack = array(new CLink(new CSpan(S_YES, 'off'), 'acknow.php?eventid=' . $event['eventid'], 'action'), SPACE . '(' . $rows . ')');
    }
    $table->AddRow(array(S_STATUS, $value));
    $table->AddRow(array(S_DURATION, $duration));
    $table->AddRow(array(S_ACKNOWLEDGED, $ack));
    return $table;
}
Example #9
0
function make_small_eventlist($eventid, $trigger_data)
{
    $config = select_config();
    $table = new CTableInfo();
    $table->setHeader(array(S_TIME, S_STATUS, S_DURATION, S_AGE, $config['event_ack_enable'] ? S_ACK : null, S_ACTIONS));
    $options = array('eventids' => $eventid, 'output' => API_OUTPUT_EXTEND);
    $curevent = CEvent::get($options);
    $curevent = reset($curevent);
    $clock = $curevent['clock'];
    $options = array('triggerids' => $trigger_data['triggerid'], 'eventid_till' => $curevent['eventid'], 'select_triggers' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND, 'sortfield' => 'clock', 'sortorder' => ZBX_SORT_DOWN, 'limit' => 20);
    $events = CEvent::get($options);
    foreach ($events as $enum => $event) {
        $trigger = reset($event['triggers']);
        $event['type'] = $trigger['type'];
        $lclock = $clock;
        $clock = $event['clock'];
        $duration = zbx_date2age($lclock, $clock);
        if ($curevent['eventid'] == $event['eventid'] && ($nextevent = get_next_event($event))) {
            $duration = zbx_date2age($nextevent['clock'], $clock);
        } else {
            if ($curevent['eventid'] == $event['eventid']) {
                $duration = zbx_date2age($clock);
            }
        }
        $value = new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value']));
        // if acknowledges are not disabled in configuration, let's show them
        if ($config['event_ack_enable']) {
            global $page;
            $backurl = urlencode(urlencode($page['file'] . '?eventid=' . $curevent['eventid'] . '&triggerid=' . $trigger_data['triggerid']));
            if ($event['acknowledged'] == 1) {
                $rows = 0;
                $db_acks = get_acknowledges_by_eventid($event['eventid']);
                while ($a = DBfetch($db_acks)) {
                    $rows++;
                }
                $ack = array(new CLink(S_YES, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $backurl, 'off'), ' (' . $rows . ')');
            } else {
                $ack = array(new CLink(S_NO, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $backurl, 'on'));
            }
        }
        //actions
        $actions = get_event_actions_stat_hints($event['eventid']);
        //--------
        $table->addRow(array(new CLink(zbx_date2str(S_EVENTS_SMALL_EVENT_LIST_DATE_FORMAT, $event['clock']), 'tr_events.php?triggerid=' . $trigger_data['triggerid'] . '&eventid=' . $event['eventid'], 'action'), $value, $duration, zbx_date2age($event['clock']), $config['event_ack_enable'] ? $ack : null, $actions));
    }
    return $table;
}