Beispiel #1
0
/**
 * Generate table for dashboard triggers popup.
 *
 * @see make_system_status
 *
 * @param array $triggers
 * @param string $backurl
 * @param array $actions
 * @param array $config
 *
 * @return CTableInfo
 */
function makeTriggersPopup(array $triggers, $backurl, array $actions, array $config)
{
    $popupTable = (new CTableInfo())->setHeader([_('Host'), _('Issue'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')]);
    CArrayHelper::sort($triggers, [['field' => 'lastchange', 'order' => ZBX_SORT_DOWN]]);
    foreach ($triggers as $trigger) {
        $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['event']['clock'], 'ns' => $trigger['event']['ns'])));
        // unknown triggers
        $unknown = '';
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = makeUnknownIcon($trigger['error']);
        }
        // ack
        if ($config['event_ack_enable']) {
            $ack = isset($trigger['event']['eventid']) ? getEventAckState($trigger['event'], $backurl) : (new CSpan(_('No events')))->addClass(ZBX_STYLE_GREY);
        } else {
            $ack = null;
        }
        // action
        $action = isset($trigger['event']['eventid']) && isset($actions[$trigger['event']['eventid']]) ? $actions[$trigger['event']['eventid']] : '';
        $popupTable->addRow([$trigger['hosts'][0]['name'], getSeverityCell($trigger['priority'], $config, $description), zbx_date2age($trigger['lastchange']), $unknown, $ack, (new CCol($action))->addClass(ZBX_STYLE_NOWRAP)]);
    }
    return $popupTable;
}
Beispiel #2
0
 } else {
     $ack_checkbox = null;
     $ackColumn = null;
 }
 if ($showEvents == EVENTS_OPTION_ALL || $showEvents == EVENTS_OPTION_NOT_ACK) {
     $openOrCloseDiv = $trigger['events'] ? (new CDiv())->addClass(ZBX_STYLE_TREEVIEW)->setAttribute('data-switcherid', $trigger['triggerid'])->addItem((new CSpan())->addClass(ZBX_STYLE_ARROW_RIGHT)) : '';
 } else {
     $openOrCloseDiv = null;
 }
 // comments
 if (isset($triggerEditable[$trigger['triggerid']])) {
     $comments = new CLink(zbx_empty($trigger['comments']) ? _('Add') : _('Show'), 'tr_comments.php?triggerid=' . $trigger['triggerid']);
 } else {
     $comments = zbx_empty($trigger['comments']) ? new CSpan('') : new CLink(_('Show'), 'tr_comments.php?triggerid=' . $trigger['triggerid']);
 }
 $triggerTable->addRow([$openOrCloseDiv, $ack_checkbox, getSeverityCell($trigger['priority'], $config, null, !$trigger['value']), $statusSpan, $trigger['state'] == TRIGGER_STATE_UNKNOWN ? makeUnknownIcon($trigger['error']) : '', $trigger['lastchange'] == 0 ? _('Never') : new CLink(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $trigger['lastchange']), 'events.php?filter_set=1&triggerid=' . $trigger['triggerid'] . '&source=' . EVENT_SOURCE_TRIGGERS . '&stime=' . date(TIMESTAMP_FORMAT, $trigger['lastchange']) . '&period=' . ZBX_PERIOD_DEFAULT), $trigger['lastchange'] == 0 ? '' : zbx_date2age($trigger['lastchange']), $showEvents == EVENTS_OPTION_ALL || $showEvents == EVENTS_OPTION_NOT_ACK ? '' : null, $ackColumn, $hostList, $description, $comments]);
 if ($showEvents == EVENTS_OPTION_ALL || $showEvents == EVENTS_OPTION_NOT_ACK) {
     $next_event_clock = time();
     foreach (array_slice($trigger['events'], 0, $config['event_show_max']) as $enum => $event) {
         if ($showEvents == EVENTS_OPTION_NOT_ACK) {
             if ($event['acknowledged'] || $event['value'] != TRIGGER_VALUE_TRUE) {
                 continue;
             }
         }
         $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'], $config['event_ack_enable'] && $event['acknowledged']);
         $clock = new CLink(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']), 'tr_events.php?triggerid=' . $trigger['triggerid'] . '&eventid=' . $event['eventid']);
         if ($enum != 0) {
             $next_event_clock = $trigger['events'][$enum - 1]['clock'];
         }