Пример #1
0
 /**
  * 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
0
 public function bodyToString()
 {
     $this->cleanItems();
     $config = select_config();
     // array of triggers (not classified, information, warning, average, high, disaster) in problem state
     $triggersProblemState = [];
     // number of triggers in OK state
     $triggersOkState = 0;
     $options = ['output' => ['triggerid', 'priority', 'value'], 'monitored' => true, 'skipDependent' => true];
     if ($this->groupid != 0) {
         $options['groupids'] = $this->groupid;
     }
     $triggers = API::Trigger()->get($options);
     foreach ($triggers as $trigger) {
         switch ($trigger['value']) {
             case TRIGGER_VALUE_TRUE:
                 if (!array_key_exists($trigger['priority'], $triggersProblemState)) {
                     $triggersProblemState[$trigger['priority']] = 0;
                 }
                 $triggersProblemState[$trigger['priority']]++;
                 break;
             case TRIGGER_VALUE_FALSE:
                 $triggersOkState++;
         }
     }
     $severityCells = [getSeverityCell(null, $config, $triggersOkState . SPACE . _('Ok'), true)];
     for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) {
         $severityCount = isset($triggersProblemState[$severity]) ? $triggersProblemState[$severity] : 0;
         $severityCells[] = getSeverityCell($severity, $config, $severityCount . SPACE . getSeverityName($severity, $config), !$severityCount);
     }
     if ($this->style == STYLE_HORIZONTAL) {
         $this->addRow($severityCells);
     } else {
         foreach ($severityCells as $severityCell) {
             $this->addRow($severityCell);
         }
     }
     return parent::bodyToString();
 }
Пример #3
0
function make_trigger_details($trigger)
{
    $hostNames = [];
    $config = select_config();
    $hostIds = zbx_objectValues($trigger['hosts'], 'hostid');
    $hosts = API::Host()->get(['output' => ['name', 'hostid', 'status'], 'hostids' => $hostIds, 'selectScreens' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT]);
    if (count($hosts) > 1) {
        order_result($hosts, 'name', ZBX_SORT_UP);
    }
    $scripts = API::Script()->getScriptsByHosts($hostIds);
    foreach ($hosts as $host) {
        $hostName = new CSpan($host['name'], ZBX_STYLE_LINK_ACTION);
        $hostName->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$host['hostid']]));
        $hostNames[] = $hostName;
        $hostNames[] = ', ';
    }
    array_pop($hostNames);
    $expression = CMacrosResolverHelper::resolveTriggerExpression($trigger['expression'], ['html' => true, 'resolve_usermacros' => true, 'resolve_macros' => true]);
    $table = (new CTableInfo())->addRow([new CCol(_n('Host', 'Hosts', count($hosts))), new CCol($hostNames)])->addRow([new CCol(_('Trigger')), new CCol(CMacrosResolverHelper::resolveTriggerName($trigger))])->addRow([_('Severity'), getSeverityCell($trigger['priority'], $config)])->addRow([new CCol(_('Expression')), new CCol($expression)])->addRow([_('Event generation'), _('Normal') . (TRIGGER_MULT_EVENT_ENABLED == $trigger['type'] ? SPACE . '+' . SPACE . _('Multiple PROBLEM events') : '')])->addRow([_('Disabled'), TRIGGER_STATUS_ENABLED == $trigger['status'] ? (new CCol(_('No')))->addClass(ZBX_STYLE_GREEN) : (new CCol(_('Yes')))->addClass(ZBX_STYLE_RED)]);
    return $table;
}
Пример #4
0
$overviewWidget = new CWidget();
$typeComboBox = new CComboBox('type', $this->data['type'], 'submit()');
$typeComboBox->addItem(SHOW_TRIGGERS, _('Triggers'));
$typeComboBox->addItem(SHOW_DATA, _('Data'));
$headerForm = new CForm('get');
$headerForm->addItem(array(_('Group'), SPACE, $this->data['pageFilter']->getGroupsCB(true)));
$headerForm->addItem(array(SPACE, _('Application'), SPACE, $this->data['pageFilter']->getApplicationsCB(true)));
$headerForm->addItem(array(SPACE, _('Type'), SPACE, $typeComboBox));
$overviewWidget->addHeader(_('Overview'), $headerForm);
$hintTable = new CTableInfo();
$hintTable->setAttribute('style', 'width: 200px');
if ($this->data['type'] == SHOW_TRIGGERS) {
    $hintTable->addRow(array(new CCol(SPACE, 'normal'), _('OK')));
}
for ($i = 0; $i < TRIGGER_SEVERITY_COUNT; $i++) {
    $hintTable->addRow(array(getSeverityCell($i), _('PROBLEM')));
}
$config = select_config();
if ($this->data['type'] == SHOW_TRIGGERS) {
    // blinking preview in help popup (only if blinking is enabled)
    if ($config['blink_period'] > 0) {
        $row = new CRow(null);
        $row->addItem(new CCol(SPACE, 'normal'));
        for ($i = 0; $i < TRIGGER_SEVERITY_COUNT; $i++) {
            $row->addItem(new CCol(SPACE, getSeverityStyle($i)));
        }
        $col = new CTable('', 'blink overview-mon-severities');
        $col->addRow($row);
        // double div necassary for FireFox
        $col = new CCol(new CDiv(new CDiv($col), 'overview-mon-severities-container'));
        $hintTable->addRow(array($col, _s('Age less than %s', convertUnitsS($config['blink_period']))));
Пример #5
0
    $severity_columns[$severity % 2][] = new CLabel([(new CCheckBox('severities[' . $severity . ']'))->setChecked(in_array($severity, $this->data['filter']['severities'])), getSeverityName($severity, $this->data['config'])], 'severities[' . $severity . ']');
}
$filterColumn1->addRow(_('Severity'), (new CTable())->addRow($severity_columns[0])->addRow($severity_columns[1]));
$filterForm->addColumn($filterColumn1)->addColumn($filterColumn2);
$topTriggers->addItem($filterForm);
// table
$table = (new CTableInfo())->setHeader([_('Host'), _('Trigger'), _('Severity'), _('Number of status changes')]);
foreach ($this->data['triggers'] as $trigger) {
    foreach ($trigger['hosts'] as $host) {
        if ($host['status'] == HOST_STATUS_MONITORED) {
            // Pass a monitored 'hostid' and corresponding first 'groupid' to menu pop-up "Events" link.
            $trigger['hostid'] = $host['hostid'];
            $trigger['groupid'] = $data['monitored_hosts'][$trigger['hostid']]['groups'][0]['groupid'];
            break;
        } else {
            // Unmonitored will have disabled "Events" link and there is no 'groupid' or 'hostid'.
            $trigger['hostid'] = 0;
            $trigger['groupid'] = 0;
        }
    }
    $hostId = $trigger['hosts'][0]['hostid'];
    $hostName = (new CSpan($trigger['hosts'][0]['name']))->addClass(ZBX_STYLE_LINK_ACTION);
    if ($this->data['hosts'][$hostId]['status'] == HOST_STATUS_NOT_MONITORED) {
        $hostName->addClass(ZBX_STYLE_RED);
    }
    $hostName->setMenuPopup(CMenuPopupHelper::getHost($this->data['hosts'][$hostId], $this->data['scripts'][$hostId]));
    $triggerDescription = (new CSpan($trigger['description']))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getTrigger($trigger));
    $table->addRow([$hostName, $triggerDescription, getSeverityCell($trigger['priority'], $this->data['config']), $trigger['cnt_event']]);
}
$topTriggers->addItem($table);
return $topTriggers;
Пример #6
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'])]);
    }
} elseif ($config == QUEUE_DETAILS) {
    $queueData = zbx_toHash($queueData, 'itemid');
    $items = API::Item()->get(['output' => ['itemid', 'hostid', 'name', 'key_'], 'selectHosts' => ['name'], 'itemids' => array_keys($queueData), 'webitems' => true, 'preservekeys' => true]);
    $items = CMacrosResolverHelper::resolveItemNames($items);
    // get hosts for queue items
    $hostIds = zbx_objectValues($items, 'hostid');
    $hostIds = array_keys(array_flip($hostIds));
    $hosts = API::Host()->get(['output' => ['hostid', 'proxy_hostid'], 'hostids' => $hostIds, 'preservekeys' => true]);
    // get proxies for those hosts
    $proxyHostIds = [];
    foreach ($hosts as $host) {
        if ($host['proxy_hostid']) {
            $proxyHostIds[$host['proxy_hostid']] = $host['proxy_hostid'];
        }
Пример #7
0
}
$sql .= ' AND ' . dbConditionInt('t.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . ' GROUP BY e.objectid' . ' ORDER BY cnt_event desc';
$result = DBselect($sql, 100);
while ($row = DBfetch($result)) {
    $triggersEventCount[$row['objectid']] = $row['cnt_event'];
}
$triggers = API::Trigger()->get(array('triggerids' => array_keys($triggersEventCount), 'output' => array('triggerid', 'description', 'expression', 'priority', 'flags', 'url', 'lastchange'), 'selectItems' => array('hostid', 'name', 'value_type', 'key_'), 'selectHosts' => array('hostid'), 'expandDescription' => true, 'expandData' => true, 'preservekeys' => true, 'nopermissions' => true));
$hostIds = array();
foreach ($triggers as $triggerId => $trigger) {
    $hostIds[$trigger['hostid']] = $trigger['hostid'];
    $triggerItems = array();
    foreach ($trigger['items'] as $item) {
        $triggerItems[] = array('name' => itemName($item), 'params' => array('itemid' => $item['itemid'], 'action' => in_array($item['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues'));
    }
    $triggers[$triggerId]['items'] = $triggerItems;
    $triggers[$triggerId]['cnt_event'] = $triggersEventCount[$triggerId];
}
CArrayHelper::sort($triggers, array(array('field' => 'cnt_event', 'order' => ZBX_SORT_DOWN), 'host', 'description', 'priority'));
$hosts = API::Host()->get(array('output' => array('hostid'), 'hostids' => $hostIds, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
$scripts = API::Script()->getScriptsByHosts($hostIds);
foreach ($triggers as $trigger) {
    $hostId = $trigger['hostid'];
    $hostName = new CSpan($trigger['hostname'], 'link_menu');
    $hostName->setMenuPopup(getMenuPopupHost($hosts[$hostId], $scripts[$hostId]));
    $triggerDescription = new CSpan($trigger['description'], 'link_menu');
    $triggerDescription->setMenuPopup(getMenuPopupTrigger($trigger, $trigger['items']));
    $table->addRow(array(get_node_name_by_elid($trigger['triggerid']), $hostName, $triggerDescription, getSeverityCell($trigger['priority']), $trigger['cnt_event']));
}
$rprt_wdgt->addItem($table);
$rprt_wdgt->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
             $triggerDescription[] = new CLink(CHtml::encode($realHost['name']), 'triggers.php?hostid=' . $realHost['hostid'], 'unknown');
             $triggerDescription[] = ':';
         }
     }
     $trigger['hosts'] = zbx_toHash($trigger['hosts'], 'hostid');
     if ($trigger['flags'] == ZBX_FLAG_DISCOVERY_CREATED) {
         $triggerDescription[] = new CSpan(CHtml::encode($trigger['description']));
     } else {
         $triggerDescription[] = new CLink(CHtml::encode($trigger['description']), 'triggers.php?form=update&hostid=' . key($trigger['hosts']) . '&triggerid=' . $trigger['triggerid']);
     }
     if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
         $trigger['error'] = '';
     }
     $trigger['items'] = zbx_toHash($trigger['items'], 'itemid');
     $trigger['functions'] = zbx_toHash($trigger['functions'], 'functionid');
     $triggerHintTable->addRow(array(getSeverityCell($trigger['priority']), $triggerDescription, triggerExpression($trigger, true), new CSpan(triggerIndicator($trigger['status'], $trigger['state']), triggerIndicatorStyle($trigger['status'], $trigger['state']))));
     $item['triggers'][$num] = $trigger;
 }
 unset($trigger);
 if (!empty($item['triggers'])) {
     $triggerInfo = new CSpan(_('Triggers'), 'link_menu');
     $triggerInfo->setHint($triggerHintTable);
     $triggerInfo = array($triggerInfo);
     $triggerInfo[] = ' (' . count($item['triggers']) . ')';
     $triggerHintTable = array();
 } else {
     $triggerInfo = SPACE;
 }
 // if item type is 'Log' we must show log menu
 if (in_array($item['value_type'], array(ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_TEXT))) {
     $triggers = array();
Пример #9
0
                $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);
            }
        }
    }
    if (!$csvExport) {
        $table = [$table, $paging];
    }
}
if ($csvExport) {
Пример #10
0
function make_trigger_details($trigger)
{
    $hostNames = array();
    $hostIds = zbx_objectValues($trigger['hosts'], 'hostid');
    $hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'hostids' => $hostIds, 'selectScreens' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT));
    if (count($hosts) > 1) {
        order_result($hosts, 'name', ZBX_SORT_UP);
    }
    $scripts = API::Script()->getScriptsByHosts($hostIds);
    foreach ($hosts as $host) {
        $hostName = new CSpan($host['name'], 'link_menu');
        $hostName->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$host['hostid']]));
        $hostNames[] = $hostName;
        $hostNames[] = ', ';
    }
    array_pop($hostNames);
    $table = new CTableInfo();
    $table->addRow(array(new CCol(_n('Host', 'Hosts', count($hosts))), new CCol($hostNames, 'wraptext')));
    $table->addRow(array(new CCol(_('Trigger')), new CCol(CMacrosResolverHelper::resolveTriggerName($trigger), 'wraptext')));
    $table->addRow(array(_('Severity'), getSeverityCell($trigger['priority'])));
    $table->addRow(array(new CCol(_('Expression')), new CCol(explode_exp($trigger['expression'], true, true), 'trigger-expression')));
    $table->addRow(array(_('Event generation'), _('Normal') . (TRIGGER_MULT_EVENT_ENABLED == $trigger['type'] ? SPACE . '+' . SPACE . _('Multiple PROBLEM events') : '')));
    $table->addRow(array(_('Disabled'), TRIGGER_STATUS_ENABLED == $trigger['status'] ? new CCol(_('No'), 'off') : new CCol(_('Yes'), 'on')));
    return $table;
}
 public function bodyToString()
 {
     $this->cleanItems();
     $ok = $uncl = $info = $warn = $avg = $high = $dis = 0;
     $options = array('monitored' => true, 'skipDependent' => true, 'output' => API_OUTPUT_SHORTEN);
     if ($this->hostid > 0) {
         $options['hostids'] = $this->hostid;
     } elseif ($this->groupid > 0) {
         $options['groupids'] = $this->groupid;
     }
     $triggers = API::Trigger()->get($options);
     $triggers = zbx_objectValues($triggers, 'triggerid');
     $db_priority = DBselect('SELECT t.priority,t.value,count(DISTINCT t.triggerid) AS cnt' . ' FROM triggers t' . ' WHERE ' . dbConditionInt('t.triggerid', $triggers) . ' GROUP BY t.priority,t.value');
     while ($row = DBfetch($db_priority)) {
         switch ($row['value']) {
             case TRIGGER_VALUE_TRUE:
                 switch ($row['priority']) {
                     case TRIGGER_SEVERITY_NOT_CLASSIFIED:
                         $uncl += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_INFORMATION:
                         $info += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_WARNING:
                         $warn += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_AVERAGE:
                         $avg += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_HIGH:
                         $high += $row['cnt'];
                         break;
                     case TRIGGER_SEVERITY_DISASTER:
                         $dis += $row['cnt'];
                         break;
                 }
                 break;
             case TRIGGER_VALUE_FALSE:
                 $ok += $row['cnt'];
                 break;
         }
     }
     if ($this->show_header) {
         $header_str = _('Triggers info') . SPACE;
         if (!is_null($this->nodeid)) {
             $node = get_node_by_nodeid($this->nodeid);
             if ($node > 0) {
                 $header_str .= '(' . $node['name'] . ')' . SPACE;
             }
         }
         if (remove_nodes_from_id($this->groupid) > 0) {
             $group = get_hostgroup_by_groupid($this->groupid);
             $header_str .= _('Group') . SPACE . '&quot;' . $group['name'] . '&quot;';
         } else {
             $header_str .= _('All groups');
         }
         $header = new CCol($header_str, 'header');
         if ($this->style == STYLE_HORISONTAL) {
             $header->setColspan(8);
         }
         $this->addRow($header);
     }
     $trok = getSeverityCell(null, $ok . SPACE . _('Ok'), true);
     $uncl = getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $uncl . SPACE . getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), !$uncl);
     $info = getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $info . SPACE . getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), !$info);
     $warn = getSeverityCell(TRIGGER_SEVERITY_WARNING, $warn . SPACE . getSeverityCaption(TRIGGER_SEVERITY_WARNING), !$warn);
     $avg = getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $avg . SPACE . getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), !$avg);
     $high = getSeverityCell(TRIGGER_SEVERITY_HIGH, $high . SPACE . getSeverityCaption(TRIGGER_SEVERITY_HIGH), !$high);
     $dis = getSeverityCell(TRIGGER_SEVERITY_DISASTER, $dis . SPACE . getSeverityCaption(TRIGGER_SEVERITY_DISASTER), !$dis);
     if (STYLE_HORISONTAL == $this->style) {
         $this->addRow(array($trok, $uncl, $info, $warn, $avg, $high, $dis));
     } else {
         $this->addRow($trok);
         $this->addRow($uncl);
         $this->addRow($info);
         $this->addRow($warn);
         $this->addRow($avg);
         $this->addRow($high);
         $this->addRow($dis);
     }
     return parent::bodyToString();
 }
function make_trigger_details($trigger)
{
    $table = new CTableInfo();
    if (is_show_all_nodes()) {
        $table->addRow(array(_('Node'), get_node_name_by_elid($trigger['triggerid'])));
    }
    $expression = explode_exp($trigger['expression'], true, true);
    $host = API::Host()->get(array('output' => array('name', 'hostid'), 'hostids' => $trigger['hosts'][0]['hostid'], 'selectScreens' => API_OUTPUT_COUNT, 'selectInventory' => array('hostid'), 'preservekeys' => true));
    $host = reset($host);
    $hostScripts = API::Script()->getScriptsByHosts($host['hostid']);
    // host js link
    $hostSpan = new CSpan($host['name'], 'link_menu menu-host');
    $scripts = $hostScripts[$host['hostid']];
    $hostSpan->attr('data-menu', hostMenuData($host, $scripts));
    // get visible name of the first host
    $table->addRow(array(_('Host'), $hostSpan));
    $table->addRow(array(_('Trigger'), CTriggerHelper::expandDescription($trigger)));
    $table->addRow(array(_('Severity'), getSeverityCell($trigger['priority'])));
    $table->addRow(array(_('Expression'), $expression));
    $table->addRow(array(_('Event generation'), _('Normal') . (TRIGGER_MULT_EVENT_ENABLED == $trigger['type'] ? SPACE . '+' . SPACE . _('Multiple PROBLEM events') : '')));
    $table->addRow(array(_('Disabled'), TRIGGER_STATUS_ENABLED == $trigger['status'] ? new CCol(_('No'), 'off') : new CCol(_('Yes'), 'on')));
    return $table;
}
Пример #13
0
        $description->setAttribute('onclick', $js_action . ' jQuery(this).removeAttr("onclick");');
        if (count($trigger['dependencies']) > 0) {
            $description = array($description, BR(), bold(_('Depends on')), BR());
            foreach ($trigger['dependencies'] as $val) {
                $description[] = array(CTriggerHelper::expandDescription($val), BR());
            }
        }
        switch ($trigger['status']) {
            case TRIGGER_STATUS_DISABLED:
                $status = new CSpan(_('Disabled'), 'disabled');
                break;
            case TRIGGER_STATUS_ENABLED:
                $status = new CSpan(_('Enabled'), 'enabled');
                break;
        }
        $table->addRow(array($multiselect ? new CCheckBox('triggers[' . zbx_jsValue($trigger[$srcfld1]) . ']', null, null, $trigger['triggerid']) : null, $description, getSeverityCell($trigger['priority']), $status));
        // made to save memmory usage
        if ($multiselect) {
            $jsTriggers[$trigger['triggerid']] = array('triggerid' => $trigger['triggerid'], 'description' => $trigger['description'], 'expression' => $trigger['expression'], 'priority' => $trigger['priority'], 'status' => $trigger['status'], 'host' => $trigger['hostname']);
        }
    }
    if ($multiselect) {
        $button = new CButton('select', _('Select'), "addSelectedValues('triggers', " . zbx_jsvalue($reference) . ');');
        $table->setFooter(new CCol($button, 'right'));
        insert_js('var popupReference = ' . zbx_jsValue($jsTriggers, true) . ';');
    }
    zbx_add_post_js('chkbxRange.pageGoName = "triggers";');
    $form->addItem($table);
    $form->show();
} elseif ($srctbl == 'items') {
    $form = new CForm();
Пример #14
0
                    $csvRows[] = array(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']), getRequest('hostid', 0) == 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 {
                    $triggerDescription = new CSpan($description, 'pointer link_menu');
                    $triggerDescription->setMenuPopup(CMenuPopupHelper::getTrigger($trigger, $triggerItems, null, $event['clock']));
                    // acknowledge
                    $ack = getEventAckState($event, true);
                    // 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 (getRequest('hostid', 0) == 0) {
                        $hostName = new CSpan($host['name'], 'link_menu');
                        $hostName->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$host['hostid']]));
                    }
                    $table->addRow(array(new CLink(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']), 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid'], 'action'), $hostName, $triggerDescription, $statusSpan, getSeverityCell($trigger['priority'], null, !$event['value']), $event['duration'], $config['event_ack_enable'] ? $ack : null, $action));
                }
            }
        } else {
            if (!$csvExport) {
                $events = array();
                $paging = getPagingLine($events);
            }
        }
    }
    if (!$csvExport) {
        $table = array($paging, $table, $paging);
    }
}
if ($csvExport) {
    echo zbx_toCSV($csvRows);
Пример #15
0
            if (isset($srcfld3)) {
                $values[$dstfld3] = $trigger[$srcfld3];
            }
            $js_action = 'addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); return false;';
        }
        $description->onClick($js_action . ' jQuery(this).removeAttr("onclick");');
        if ($trigger['dependencies']) {
            $description = [$description, BR(), bold(_('Depends on')), BR()];
            $dependencies = CMacrosResolverHelper::resolveTriggerNames(zbx_toHash($trigger['dependencies'], 'triggerid'));
            foreach ($dependencies as $dependency) {
                $description[] = $dependency['description'];
                $description[] = BR();
            }
            array_pop($description);
        }
        $table->addRow([$multiselect ? new CCheckBox('triggers[' . zbx_jsValue($trigger[$srcfld1]) . ']', $trigger['triggerid']) : null, $description, getSeverityCell($trigger['priority'], $config), (new CSpan(triggerIndicator($trigger['status'], $trigger['state'])))->addClass(triggerIndicatorStyle($trigger['status'], $trigger['state']))]);
        // made to save memory usage
        if ($multiselect) {
            $jsTriggers[$trigger['triggerid']] = ['id' => $trigger['triggerid'], 'name' => $trigger['description'], 'triggerid' => $trigger['triggerid'], 'description' => $trigger['description'], 'expression' => $trigger['expression'], 'priority' => $trigger['priority'], 'status' => $trigger['status'], 'host' => $trigger['hostname']];
        }
    }
    if ($multiselect) {
        $table->setFooter(new CCol((new CButton('select', _('Select')))->onClick("addSelectedValues('triggers', " . zbx_jsvalue($reference) . ', ' . $parentId . ');')));
        insert_js('var popupReference = ' . zbx_jsValue($jsTriggers, true) . ';');
    }
    $form->addItem($table);
    $widget->addItem($form)->show();
} elseif ($srctbl === 'items' || $srctbl === 'item_prototypes') {
    $form = (new CForm())->setName('itemform')->setId('items');
    $itemPrototypesPopup = $srctbl === 'item_prototypes';
    $table = (new CTableInfo())->setHeader([$pageFilter->hostsAll ? _('Host') : null, $multiselect ? (new CColHeader((new CCheckBox('all_items'))->onClick("javascript: checkAll('" . $form->getName() . "', 'all_items', 'items');")))->addClass(ZBX_STYLE_CELL_WIDTH) : null, _('Name'), _('Key'), _('Type'), _('Type of information'), _('Status')]);
Пример #16
0
            $js_action = 'addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($trigger['triggerid']) . ', ' . $parentId . ');';
        } else {
            $values = array($dstfld1 => $trigger[$srcfld1], $dstfld2 => $trigger[$srcfld2]);
            if (isset($srcfld3)) {
                $values[$dstfld3] = $trigger[$srcfld3];
            }
            $js_action = 'addValues(' . zbx_jsvalue($dstfrm) . ', ' . zbx_jsvalue($values) . '); return false;';
        }
        $description->setAttribute('onclick', $js_action . ' jQuery(this).removeAttr("onclick");');
        if (count($trigger['dependencies']) > 0) {
            $description = array($description, BR(), bold(_('Depends on')), BR());
            foreach ($trigger['dependencies'] as $dependentTrigger) {
                $description[] = array(CMacrosResolverHelper::resolveTriggerName($dependentTrigger), BR());
            }
        }
        $table->addRow(array($multiselect ? new CCheckBox('triggers[' . zbx_jsValue($trigger[$srcfld1]) . ']', null, null, $trigger['triggerid']) : null, $description, getSeverityCell($trigger['priority']), new CSpan(triggerIndicator($trigger['status'], $trigger['state']), triggerIndicatorStyle($trigger['status'], $trigger['state']))));
        // made to save memory usage
        if ($multiselect) {
            $jsTriggers[$trigger['triggerid']] = array('id' => $trigger['triggerid'], 'name' => $trigger['description'], 'prefix' => get_node_name_by_elid($trigger['triggerid'], null, NAME_DELIMITER), 'triggerid' => $trigger['triggerid'], 'description' => $trigger['description'], 'expression' => $trigger['expression'], 'priority' => $trigger['priority'], 'status' => $trigger['status'], 'host' => $trigger['hostname']);
        }
    }
    if ($multiselect) {
        $button = new CButton('select', _('Select'), "addSelectedValues('triggers', " . zbx_jsvalue($reference) . ', ' . $parentId . ');');
        $table->setFooter(new CCol($button, 'right'));
        insert_js('var popupReference = ' . zbx_jsValue($jsTriggers, true) . ';');
    }
    zbx_add_post_js('chkbxRange.pageGoName = "triggers";');
    $form->addItem($table);
    $form->show();
} elseif ($srctbl == 'items') {
    $form = new CForm();
Пример #17
0
         $ackColumn = new CCol(_('No events'), 'unknown');
     }
 } else {
     $ackColumn = null;
 }
 // open or close
 if ($showEvents != EVENTS_OPTION_NOEVENT && !empty($trigger['events'])) {
     $openOrCloseDiv = new CDiv(SPACE, 'filterclosed');
     $openOrCloseDiv->setAttribute('data-switcherid', $trigger['triggerid']);
 } elseif ($showEvents == EVENTS_OPTION_NOEVENT) {
     $openOrCloseDiv = null;
 } else {
     $openOrCloseDiv = SPACE;
 }
 // severity
 $severityColumn = getSeverityCell($trigger['priority'], null, !$trigger['value']);
 if ($showEventColumn) {
     $severityColumn->setColSpan(2);
 }
 // unknown triggers
 $unknown = SPACE;
 if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
     $unknown = new CDiv(SPACE, 'status_icon iconunknown');
     $unknown->setHint($trigger['error'], '', 'on');
 }
 // 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']);
 }
Пример #18
0
        $trigger['items'][$item['itemid']] = array('itemid' => $item['itemid'], 'action' => str_in_array($item['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues', 'name' => itemName($item), 'value_type' => $item['value_type']);
    }
    $triggers[$tid] = $trigger;
}
CArrayHelper::sort($triggers, array(array('field' => 'cnt_event', 'order' => ZBX_SORT_DOWN), 'host', 'description', 'priority'));
$scripts_by_hosts = API::Script()->getScriptsByHosts($hosts);
foreach ($triggers as $trigger) {
    $menus = '';
    $host_nodeid = id2nodeid($trigger['hostid']);
    foreach ($scripts_by_hosts[$trigger['hostid']] as $script) {
        $script_nodeid = id2nodeid($script['scriptid']);
        if (bccomp($host_nodeid, $script_nodeid) == 0) {
            $menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $trigger['hostid'] . "&scriptid=" . $script['scriptid'] . "','Global script',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],";
        }
    }
    $menus .= "['" . _('URLs') . "',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],";
    $menus .= "['" . _('Latest data') . "',\"javascript: redirect('latest.php?hostid=" . $trigger['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}]";
    $menus = "show_popup_menu(event,[['" . _('Scripts') . "',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus . "],180);";
    $hostSpan = new CSpan($trigger['hostname'], 'link_menu');
    $hostSpan->setAttribute('onclick', $menus);
    $tr_conf_link = 'null';
    if ($USER_DETAILS['type'] > USER_TYPE_ZABBIX_USER && $trigger['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
        $tr_conf_link = "['" . _('Configuration of trigger') . "',\"javascript: redirect('triggers.php?form=update&triggerid=" . $trigger['triggerid'] . "&hostid=" . $trigger['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}]";
    }
    $tr_desc = new CSpan($trigger['description'], 'link_menu');
    $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " [{'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $trigger['lastchange'] . "'}," . $tr_conf_link . "]," . zbx_jsvalue($trigger['items'], true) . ");");
    $table->addRow(array(get_node_name_by_elid($trigger['triggerid']), $hostSpan, $tr_desc, getSeverityCell($trigger['priority']), $trigger['cnt_event']));
}
$rprt_wdgt->addItem($table);
$rprt_wdgt->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
        $status = new CLink(triggerIndicator($trigger['status'], $trigger['state']), 'triggers.php?' . 'action=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'trigger.massenable' : 'trigger.massdisable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid, triggerIndicatorStyle($trigger['status'], $trigger['state']));
    }
    // hosts
    $hosts = null;
    if (empty($this->data['hostid'])) {
        foreach ($trigger['hosts'] as $hostid => $host) {
            if (!empty($hosts)) {
                $hosts[] = ', ';
            }
            $hosts[] = $host['name'];
        }
    }
    // checkbox
    $checkBox = new CCheckBox('g_triggerid[' . $triggerid . ']', null, null, $triggerid);
    $checkBox->setEnabled(empty($trigger['discoveryRule']));
    $triggersTable->addRow(array($checkBox, getSeverityCell($trigger['priority']), $hosts, $description, new CCol(triggerExpression($trigger, true), 'trigger-expression'), $status, $info));
}
// create go button
$actionObject = $this->data['parent_discoveryid'] ? 'triggerprototype' : 'trigger';
$goComboBox = new CComboBox('action');
$goOption = new CComboItem($actionObject . '.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Enable selected trigger prototypes?') : _('Enable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem($actionObject . '.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Disable selected trigger prototypes?') : _('Disable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem($actionObject . '.massupdateform', _('Mass update'));
$goComboBox->addItem($goOption);
if (empty($this->data['parent_discoveryid'])) {
    $goOption = new CComboItem($actionObject . '.masscopyto', _('Copy selected to ...'));
    $goComboBox->addItem($goOption);
     if ($trigger['flags'] == ZBX_FLAG_DISCOVERY_CREATED) {
         $triggerDescription[] = new CSpan($trigger['description']);
     } else {
         $triggerDescription[] = new CLink($trigger['description'], 'triggers.php?form=update&hostid=' . key($trigger['hosts']) . '&triggerid=' . $trigger['triggerid']);
     }
     if ($trigger['value_flags'] == TRIGGER_VALUE_FLAG_UNKNOWN) {
         $trigger['error'] = '';
     }
     if ($trigger['status'] == TRIGGER_STATUS_DISABLED) {
         $triggerStatus = new CSpan(_('Disabled'), 'disabled');
     } elseif ($trigger['status'] == TRIGGER_STATUS_ENABLED) {
         $triggerStatus = new CSpan(_('Enabled'), 'enabled');
     }
     $trigger['items'] = zbx_toHash($trigger['items'], 'itemid');
     $trigger['functions'] = zbx_toHash($trigger['functions'], 'functionid');
     $triggerHintTable->addRow(array(getSeverityCell($trigger['priority']), $triggerDescription, triggerExpression($trigger, true), $triggerStatus));
     $item['triggers'][$num] = $trigger;
 }
 unset($trigger);
 if (!empty($item['triggers'])) {
     $triggerInfo = new CSpan(_('Triggers'), 'link_menu');
     $triggerInfo->setHint($triggerHintTable);
     $triggerInfo = array($triggerInfo);
     $triggerInfo[] = ' (' . count($item['triggers']) . ')';
     $triggerHintTable = array();
 } else {
     $triggerInfo = SPACE;
 }
 // if item type is 'Log' we must show log menu
 if (in_array($item['value_type'], array(ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_TEXT))) {
     $triggersFlag = false;
Пример #21
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;
}
Пример #22
0
 public function bodyToString()
 {
     $this->cleanItems();
     $okCount = 0;
     $notClassifiedCount = 0;
     $informationCount = 0;
     $warningCount = 0;
     $averageCount = 0;
     $highCount = 0;
     $disasterCount = 0;
     $options = array('output' => array('triggerid', 'priority', 'value'), 'monitored' => true, 'skipDependent' => true);
     if ($this->hostid > 0) {
         $options['hostids'] = $this->hostid;
     } elseif ($this->groupid > 0) {
         $options['groupids'] = $this->groupid;
     }
     $triggers = API::Trigger()->get($options);
     foreach ($triggers as $trigger) {
         if ($trigger['value'] == TRIGGER_VALUE_TRUE) {
             switch ($trigger['priority']) {
                 case TRIGGER_SEVERITY_NOT_CLASSIFIED:
                     $notClassifiedCount++;
                     break;
                 case TRIGGER_SEVERITY_INFORMATION:
                     $informationCount++;
                     break;
                 case TRIGGER_SEVERITY_WARNING:
                     $warningCount++;
                     break;
                 case TRIGGER_SEVERITY_AVERAGE:
                     $averageCount++;
                     break;
                 case TRIGGER_SEVERITY_HIGH:
                     $highCount++;
                     break;
                 case TRIGGER_SEVERITY_DISASTER:
                     $disasterCount++;
                     break;
             }
         } elseif ($trigger['value'] == TRIGGER_VALUE_FALSE) {
             $okCount++;
         }
     }
     if ($this->show_header) {
         $header_str = _('Triggers info') . SPACE;
         if ($this->groupid != 0) {
             $group = get_hostgroup_by_groupid($this->groupid);
             $header_str .= _('Group') . SPACE . '&quot;' . $group['name'] . '&quot;';
         } else {
             $header_str .= _('All groups');
         }
         $header = new CCol($header_str, 'header');
         if ($this->style == STYLE_HORIZONTAL) {
             $header->setColspan(8);
         }
         $this->addRow($header);
     }
     $okCount = getSeverityCell(null, $okCount . SPACE . _('Ok'), true);
     $notClassifiedCount = getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $notClassifiedCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED), !$notClassifiedCount);
     $informationCount = getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $informationCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_INFORMATION), !$informationCount);
     $warningCount = getSeverityCell(TRIGGER_SEVERITY_WARNING, $warningCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_WARNING), !$warningCount);
     $averageCount = getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $averageCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_AVERAGE), !$averageCount);
     $highCount = getSeverityCell(TRIGGER_SEVERITY_HIGH, $highCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_HIGH), !$highCount);
     $disasterCount = getSeverityCell(TRIGGER_SEVERITY_DISASTER, $disasterCount . SPACE . getSeverityCaption(TRIGGER_SEVERITY_DISASTER), !$disasterCount);
     if (STYLE_HORIZONTAL == $this->style) {
         $this->addRow(array($okCount, $notClassifiedCount, $informationCount, $warningCount, $averageCount, $highCount, $disasterCount));
     } else {
         $this->addRow($okCount);
         $this->addRow($notClassifiedCount);
         $this->addRow($informationCount);
         $this->addRow($warningCount);
         $this->addRow($averageCount);
         $this->addRow($highCount);
         $this->addRow($disasterCount);
     }
     return parent::bodyToString();
 }
Пример #23
0
                             $sec_300[$row['proxy_hostid']]++;
                         } else {
                             if ($diff <= 600) {
                                 $sec_600[$row['proxy_hostid']]++;
                             } else {
                                 $sec_rest[$row['proxy_hostid']]++;
                             }
                         }
                     }
                 }
             }
         }
     }
     $table->setHeader(array(_('Proxy'), _('5 seconds'), _('10 seconds'), _('30 seconds'), _('1 minute'), _('5 minutes'), _('More than 10 minutes')));
     foreach ($proxies as $proxyid => $proxy) {
         $table->addRow(array($proxy['host'], getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $sec_10[$proxyid], !$sec_10[$proxyid]), getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $sec_30[$proxyid], !$sec_30[$proxyid]), getSeverityCell(TRIGGER_SEVERITY_WARNING, $sec_60[$proxyid], !$sec_60[$proxyid]), getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $sec_300[$proxyid], !$sec_300[$proxyid]), getSeverityCell(TRIGGER_SEVERITY_HIGH, $sec_600[$proxyid], !$sec_600[$proxyid]), getSeverityCell(TRIGGER_SEVERITY_DISASTER, $sec_rest[$proxyid], !$sec_rest[$proxyid])));
     }
 } else {
     if ($_REQUEST['config'] == 2) {
         $arr = array();
         $table->setHeader(array(_('Next check'), _('Delayed by'), is_show_all_nodes() ? _('Node') : null, _('Host'), _('Name')));
         while ($row = DBfetch($result)) {
             $res = calculateItemNextcheck($row['interfaceid'], $row['itemid'], $row['type'], $row['delay'], $row['delay_flex'], $row['lastclock']);
             if (0 != $row['proxy_hostid'] && 0 != $res['delay']) {
                 $res['nextcheck'] = $row['lastclock'] + $res['delay'];
             }
             $diff = $now - $res['nextcheck'];
             if ($diff <= 5) {
                 continue;
             }
             $arr[] = array($res['nextcheck'], $row['hostid'], $row['hostname'], itemName($row));
Пример #24
0
                } 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
                $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);
}
Пример #25
0
function make_trigger_details($trigger)
{
    $hosts = reset($trigger['hosts']);
    $hostId = $hosts['hostid'];
    $hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'hostids' => $hostId, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
    $host = reset($hosts);
    $scripts = API::Script()->getScriptsByHosts($hostId);
    $hostName = new CSpan($host['name'], 'link_menu');
    $hostName->setMenuPopup(getMenuPopupHost($host, $scripts ? reset($scripts) : null));
    $table = new CTableInfo();
    if (is_show_all_nodes()) {
        $table->addRow(array(_('Node'), get_node_name_by_elid($trigger['triggerid'])));
    }
    $table->addRow(array(_('Host'), $hostName));
    $table->addRow(array(_('Trigger'), CMacrosResolverHelper::resolveTriggerName($trigger)));
    $table->addRow(array(_('Severity'), getSeverityCell($trigger['priority'])));
    $table->addRow(array(_('Expression'), explode_exp($trigger['expression'], true, true)));
    $table->addRow(array(_('Event generation'), _('Normal') . (TRIGGER_MULT_EVENT_ENABLED == $trigger['type'] ? SPACE . '+' . SPACE . _('Multiple PROBLEM events') : '')));
    $table->addRow(array(_('Disabled'), TRIGGER_STATUS_ENABLED == $trigger['status'] ? new CCol(_('No'), 'off') : new CCol(_('Yes'), 'on')));
    return $table;
}
        $status = new CLink(triggerIndicator($trigger['status'], $trigger['state']), 'triggers.php?' . 'go=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'activate' : 'disable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid, triggerIndicatorStyle($trigger['status'], $trigger['state']));
    }
    $hosts = null;
    if (empty($this->data['hostid'])) {
        foreach ($trigger['hosts'] as $hostid => $host) {
            if (!empty($hosts)) {
                $hosts[] = ', ';
            }
            $hosts[] = $host['name'];
        }
    }
    $checkBox = new CCheckBox('g_triggerid[' . $triggerid . ']', null, null, $triggerid);
    $checkBox->setEnabled(empty($trigger['discoveryRule']));
    $expressionColumn = new CCol(triggerExpression($trigger, true));
    $expressionColumn->setAttribute('style', 'white-space: normal;');
    $triggersTable->addRow(array($checkBox, $this->data['displayNodes'] ? $trigger['nodename'] : null, getSeverityCell($trigger['priority']), $hosts, $description, $expressionColumn, $status, $data['showErrorColumn'] ? $error : null));
    $triggers[$tnum] = $trigger;
}
// create go button
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Enable selected trigger prototypes?') : _('Enable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Disable selected trigger prototypes?') : _('Disable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('massupdate', _('Mass update'));
$goComboBox->addItem($goOption);
if (empty($this->data['parent_discoveryid'])) {
    $goOption = new CComboItem('copy_to', _('Copy selected to ...'));
    $goComboBox->addItem($goOption);
Пример #27
0
        if ($host['status'] == HOST_STATUS_MONITORED) {
            $monitoredHostIds[$host['hostid']] = true;
        }
    }
}
if ($monitoredHostIds) {
    $monitoredHosts = API::Host()->get(array('output' => array('hostid'), 'selectGroups' => array('groupid'), 'hostids' => array_keys($monitoredHostIds), 'preservekeys' => true));
}
foreach ($triggers as $trigger) {
    foreach ($trigger['hosts'] as $host) {
        if ($host['status'] == HOST_STATUS_MONITORED) {
            // Pass a monitored 'hostid' and corresponding first 'groupid' to menu pop-up "Events" link.
            $trigger['hostid'] = $host['hostid'];
            $trigger['groupid'] = $monitoredHosts[$trigger['hostid']]['groups'][0]['groupid'];
            break;
        } else {
            // Unmonitored will have disabled "Events" link and there is no 'groupid' or 'hostid'.
            $trigger['hostid'] = 0;
            $trigger['groupid'] = 0;
        }
    }
    $hostId = $trigger['hosts'][0]['hostid'];
    $hostName = new CSpan($trigger['hosts'][0]['name'], 'link_menu menu-host' . ($hosts[$hostId]['status'] == HOST_STATUS_NOT_MONITORED ? ' not-monitored' : ''));
    $hostName->setMenuPopup(CMenuPopupHelper::getHost($hosts[$hostId], $scripts[$hostId]));
    $triggerDescription = new CSpan($trigger['description'], 'link_menu');
    $triggerDescription->setMenuPopup(CMenuPopupHelper::getTrigger($trigger));
    $table->addRow(array($hostName, $triggerDescription, getSeverityCell($trigger['priority']), $trigger['cnt_event']));
}
$rprt_wdgt->addItem($table);
$rprt_wdgt->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
        }
    }
    $description[] = new CLink(CHtml::encode($trigger['description']), 'trigger_prototypes.php?' . 'form=update' . '&parent_discoveryid=' . $this->data['parent_discoveryid'] . '&triggerid=' . $triggerid);
    if ($trigger['dependencies']) {
        $description[] = [BR(), bold(_('Depends on') . ':')];
        $triggerDependencies = [];
        foreach ($trigger['dependencies'] as $dependency) {
            $depTrigger = $data['dependencyTriggers'][$dependency['triggerid']];
            $depTriggerDescription = CHtml::encode(implode(', ', zbx_objectValues($depTrigger['hosts'], 'name')) . NAME_DELIMITER . $depTrigger['description']);
            if ($depTrigger['flags'] == ZBX_FLAG_DISCOVERY_PROTOTYPE) {
                $triggerDependencies[] = (new CLink($depTriggerDescription, 'trigger_prototypes.php?form=update' . url_param('parent_discoveryid') . '&triggerid=' . $depTrigger['triggerid']))->addClass(triggerIndicatorStyle($depTrigger['status']));
            } elseif ($depTrigger['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
                $triggerDependencies[] = (new CLink($depTriggerDescription, 'triggers.php?form=update&triggerid=' . $depTrigger['triggerid']))->addClass(triggerIndicatorStyle($depTrigger['status']));
            }
            $triggerDependencies[] = BR();
        }
        array_pop($triggerDependencies);
        $description = array_merge($description, [(new CDiv($triggerDependencies))->addClass('dependencies')]);
    }
    // status
    $status = (new CLink(triggerIndicator($trigger['status']), 'trigger_prototypes.php?' . 'action=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'triggerprototype.massenable' : 'triggerprototype.massdisable') . '&g_triggerid=' . $triggerid . '&parent_discoveryid=' . $this->data['parent_discoveryid']))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(triggerIndicatorStyle($trigger['status']))->addSID();
    // checkbox
    $checkBox = new CCheckBox('g_triggerid[' . $triggerid . ']', $triggerid);
    $triggersTable->addRow([$checkBox, getSeverityCell($trigger['priority'], $this->data['config']), $description, $trigger['expression'], $status]);
}
zbx_add_post_js('cookie.prefix = "' . $this->data['parent_discoveryid'] . '";');
// append table to form
$triggersForm->addItem([$triggersTable, $this->data['paging'], new CActionButtonList('action', 'g_triggerid', ['triggerprototype.massenable' => ['name' => _('Enable'), 'confirm' => _('Enable selected trigger prototypes?')], 'triggerprototype.massdisable' => ['name' => _('Disable'), 'confirm' => _('Disable selected trigger prototypes?')], 'triggerprototype.massupdateform' => ['name' => _('Mass update')], 'triggerprototype.massdelete' => ['name' => _('Delete'), 'confirm' => _('Delete selected trigger prototypes?')]], $this->data['parent_discoveryid'])]);
// append form to widget
$widget->addItem($triggersForm);
return $widget;
Пример #29
0
/**
 * Generate table for dashboard triggers popup.
 *
 * @see make_system_status
 *
 * @param array $triggers
 * @param array $ackParams
 * @param array $actions
 *
 * @return CTableInfo
 */
function makeTriggersPopup(array $triggers, array $ackParams, array $actions)
{
    $config = select_config();
    $popupTable = new CTableInfo();
    $popupTable->setAttribute('style', 'width: 400px;');
    $popupTable->setHeader(array(is_show_all_nodes() ? _('Node') : null, _('Host'), _('Issue'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
    CArrayHelper::sort($triggers, array(array('field' => 'lastchange', 'order' => ZBX_SORT_DOWN)));
    foreach ($triggers as $trigger) {
        // unknown triggers
        $unknown = SPACE;
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = new CDiv(SPACE, 'status_icon iconunknown');
            $unknown->setHint($trigger['error'], '', 'on');
        }
        // ack
        if ($config['event_ack_enable']) {
            $ack = isset($trigger['event']['eventid']) ? getEventAckState($trigger['event'], true, true, $ackParams) : _('No events');
        } else {
            $ack = null;
        }
        // action
        $action = isset($trigger['event']['eventid']) && isset($actions[$trigger['event']['eventid']]) ? $actions[$trigger['event']['eventid']] : _('-');
        $popupTable->addRow(array(get_node_name_by_elid($trigger['triggerid']), $trigger['hosts'][0]['name'], getSeverityCell($trigger['priority'], $trigger['description']), zbx_date2age($trigger['lastchange']), $unknown, $ack, $action));
    }
    return $popupTable;
}
require_once dirname(__FILE__) . '/js/general.script.confirm.js.php';
$overviewWidget = new CWidget();
$typeComboBox = new CComboBox('type', $this->data['type'], 'submit()');
$typeComboBox->addItem(SHOW_TRIGGERS, _('Triggers'));
$typeComboBox->addItem(SHOW_DATA, _('Data'));
$headerForm = new CForm('get');
$headerForm->addItem(array(_('Group'), SPACE, $this->data['pageFilter']->getGroupsCB(true)));
$headerForm->addItem(array(SPACE, _('Type'), SPACE, $typeComboBox));
$overviewWidget->addHeader(_('Overview'), $headerForm);
$hintTable = new CTableInfo();
$hintTable->setAttribute('style', 'width: 200px');
if ($this->data['type'] == SHOW_TRIGGERS) {
    $hintTable->addRow(array(new CCol(SPACE, 'normal'), _('Disabled')));
}
for ($i = 0; $i < TRIGGER_SEVERITY_COUNT; $i++) {
    $hintTable->addRow(array(getSeverityCell($i), _('Enabled')));
}
if ($this->data['type'] == SHOW_TRIGGERS) {
    // blinking preview in help popup (only if blinking is enabled)
    $config = select_config();
    if ($config['blink_period'] > 0) {
        $col = new CCol(SPACE, 'not_classified');
        $col->setAttribute('style', 'background-image: url(images/gradients/blink.gif); background-position: top left; background-repeat: repeat;');
        $hintTable->addRow(array($col, _s('Age less than %s', convertUnitsS($config['blink_period']))));
    }
    $hintTable->addRow(array(new CCol(SPACE), _('No trigger')));
} else {
    $hintTable->addRow(array(new CCol(SPACE), _('Disabled or no trigger')));
}
$help = new CHelp('web.view.php', 'right');
$help->setHint($hintTable, '', '', true, false);