// We add 1 to event start url, so events would show it $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row['lastchange']), 'events.php?triggerid=' . $row['triggerid'] . '&nav_time=' . ($row['lastchange'] + 1), 'action'); //-- $table->addRow(array($show_event_col ? SPACE : NULL, new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'], $row['value'])), $value, $clock, get_node_name_by_elid($row['triggerid']), $host, $tr_desc, $actions, $show_event_col ? SPACE : NULL, new CLink(zbx_empty($row['comments']) ? S_ADD : S_SHOW, 'tr_comments.php?triggerid=' . $row['triggerid'], 'action'))); $event_limit = 0; foreach ($row['events'] as $eventid => $row_event) { $value = new CSpan(trigger_value2str($row_event['value']), get_trigger_value_style($row_event['value'])); if ($config['event_ack_enable']) { if ($row_event['acknowledged'] == 1) { $acks_cnt = DBfetch(DBselect('SELECT COUNT(*) as cnt FROM acknowledges WHERE eventid=' . $row_event['eventid'])); $ack = array(new CSpan(S_YES, 'off'), SPACE . '(' . $acks_cnt['cnt'] . SPACE, new CLink(S_SHOW, 'acknow.php?eventid=' . $row_event['eventid'], 'action'), ')'); } else { $ack = new CLink(S_NOT_ACKNOWLEDGED, 'acknow.php?eventid=' . $row_event['eventid'], 'on'); } } $description = expand_trigger_description_by_data(array_merge($row, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT); $font = new CTag('font', 'yes'); $font->setAttribute('color', '#808080'); $font->addItem(array(' - ', $description)); $description = $font; $description = new CCol($description); $description->setAttribute('style', 'white-space: normal; width: 90%;'); $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row_event['eventid'], 'action'); $table->addRow(array($config['event_ack_enable'] ? $row_event['acknowledged'] == 1 ? SPACE : new CCheckBox('events[' . $row_event['eventid'] . ']', 'no', NULL, $row_event['eventid']) : NULL, new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'], $row_event['value'])), $value, $clock, get_node_name_by_elid($row['triggerid']), $host, $description, $actions, $config['event_ack_enable'] ? new CCol($ack, 'center') : NULL, new CLink($row['comments'] == '' ? S_ADD : S_SHOW, 'tr_comments.php?triggerid=' . $row['triggerid'], 'action'))); $event_limit++; if ($event_limit >= $config['event_show_max']) { break; } } unset($row, $description, $actions); }
} $sql_cond = $show_unknown == 0 ? ' AND e.value<>' . TRIGGER_VALUE_UNKNOWN . ' ' : ''; $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']); //--------
function insert_map_element_form() { global $USER_DETAILS; $frmEl = new CFormTable('New map element', 'sysmap.php'); $frmEl->SetHelp('web.sysmap.host.php'); $frmEl->addVar('sysmapid', $_REQUEST['sysmapid']); if (isset($_REQUEST['selementid'])) { $frmEl->addVar('selementid', $_REQUEST['selementid']); $element = get_sysmaps_element_by_selementid($_REQUEST['selementid']); $frmEl->SetTitle('Map element "' . $element['label'] . '"'); } if (isset($_REQUEST['selementid']) && !isset($_REQUEST['form_refresh'])) { $elementid = $element['elementid']; $elementtype = $element['elementtype']; $label = $element['label']; $x = $element['x']; $y = $element['y']; $url = $element['url']; $iconid_off = $element['iconid_off']; $iconid_on = $element['iconid_on']; $iconid_unknown = $element['iconid_unknown']; $iconid_disabled = $element['iconid_disabled']; $label_location = $element['label_location']; if (is_null($label_location)) { $label_location = -1; } } else { $elementid = get_request('elementid', 0); $elementtype = get_request('elementtype', SYSMAP_ELEMENT_TYPE_HOST); $label = get_request('label', ''); $x = get_request('x', 0); $y = get_request('y', 0); $url = get_request('url', ''); $iconid_off = get_request('iconid_off', 0); $iconid_on = get_request('iconid_on', 0); $iconid_unknown = get_request('iconid_unknown', 0); $iconid_disabled = get_request('iconid_disabled', 0); $label_location = get_request('label_location', '-1'); } $cmbType = new CComboBox('elementtype', $elementtype, 'submit()'); $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true)); $sql = 'SELECT DISTINCT n.name as node_name,h.hostid,h.host ' . ' FROM hosts h' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('h.hostid') . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' ORDER BY node_name,h.host'; $db_hosts = DBselect($sql); if ($db_hosts) { $cmbType->addItem(SYSMAP_ELEMENT_TYPE_HOST, S_HOST); } $db_maps = DBselect('SELECT sysmapid FROM sysmaps WHERE sysmapid!=' . $_REQUEST['sysmapid']); if (DBfetch($db_maps)) { $cmbType->addItem(SYSMAP_ELEMENT_TYPE_MAP, S_MAP); } $cmbType->addItem(SYSMAP_ELEMENT_TYPE_TRIGGER, S_TRIGGER); $cmbType->addItem(SYSMAP_ELEMENT_TYPE_HOST_GROUP, S_HOST_GROUP); $cmbType->addItem(SYSMAP_ELEMENT_TYPE_IMAGE, S_IMAGE); $frmEl->addRow(S_TYPE, $cmbType); $frmEl->addRow(S_LABEL, new CTextArea('label', $label, 32, 4)); $cmbLocation = new CComboBox('label_location', $label_location); $cmbLocation->addItem(-1, '-'); $cmbLocation->addItem(0, S_BOTTOM); $cmbLocation->addItem(1, S_LEFT); $cmbLocation->addItem(2, S_RIGHT); $cmbLocation->addItem(3, S_TOP); $frmEl->addRow(S_LABEL_LOCATION, $cmbLocation); if ($elementtype == SYSMAP_ELEMENT_TYPE_HOST) { $host = ''; $host_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host ' . ' FROM hosts h ' . ' LEFT JOIN nodes n ON n.nodeid=' . DBid2nodeid('h.hostid') . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' AND hostid=' . $elementid . ' ORDER BY node_name,h.host')); if ($host_info) { $host = $host_info['host']; } else { $elementid = 0; } if ($elementid == 0) { $host = ''; $elementid = 0; } $frmEl->addVar('elementid', $elementid); $frmEl->addRow(S_HOST, array(new CTextBox('host', $host, 32, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmEl->GetName() . "&dstfld1=elementid&dstfld2=host&srctbl=hosts&srcfld1=hostid&srcfld2=host',450,450);", 'T'))); } else { if ($elementtype == SYSMAP_ELEMENT_TYPE_MAP) { $cmbMaps = new CComboBox('elementid', $elementid); $db_maps = DBselect('SELECT DISTINCT n.name as node_name,s.sysmapid,s.name ' . ' FROM sysmaps s' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('s.sysmapid') . ' ORDER BY node_name,s.name'); while ($db_map = DBfetch($db_maps)) { if (!sysmap_accessible($db_map['sysmapid'], PERM_READ_ONLY)) { continue; } $node_name = isset($db_map['node_name']) ? '(' . $db_map['node_name'] . ') ' : ''; $cmbMaps->addItem($db_map['sysmapid'], $node_name . $db_map['name']); } $frmEl->addRow(S_MAP, $cmbMaps); } else { if ($elementtype == SYSMAP_ELEMENT_TYPE_TRIGGER) { $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY, get_current_nodeid(true)); $trigger = ''; $trigger_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,h.hostid,h.host,t.*' . ' FROM triggers t ' . ' LEFT JOIN functions f on t.triggerid=f.triggerid ' . ' LEFT JOIN items i on i.itemid=f.itemid ' . ' LEFT JOIN hosts h on h.hostid=i.hostid ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('t.triggerid') . ' WHERE t.triggerid=' . $elementid . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' ORDER BY node_name,h.host,t.description')); if ($trigger_info) { $trigger = expand_trigger_description_by_data($trigger_info); } else { $elementid = 0; } if ($elementid == 0) { $trigger = ''; $elementid = 0; } $frmEl->addVar('elementid', $elementid); $frmEl->addRow(S_TRIGGER, array(new CTextBox('trigger', $trigger, 32, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmEl->GetName() . "&dstfld1=elementid&dstfld2=trigger&srctbl=triggers&srcfld1=triggerid&srcfld2=description');", 'T'))); } else { if ($elementtype == SYSMAP_ELEMENT_TYPE_HOST_GROUP) { $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY, null, get_current_nodeid(true)); $group = ''; $group_info = DBfetch(DBselect('SELECT DISTINCT n.name as node_name,g.groupid,g.name ' . ' FROM groups g ' . ' LEFT JOIN nodes n on n.nodeid=' . DBid2nodeid('g.groupid') . ' WHERE ' . DBcondition('g.groupid', $available_groups) . ' AND g.groupid=' . $elementid . ' ORDER BY node_name,g.name')); if ($group_info) { $group = $group_info['name']; } else { $elementid = 0; } if ($elementid == 0) { $group = ''; $elementid = 0; } $frmEl->addVar('elementid', $elementid); $frmEl->addRow(S_HOST_GROUP, array(new CTextBox('group', $group, 32, 'yes'), new CButton('btn1', S_SELECT, "return PopUp('popup.php?dstfrm=" . $frmEl->GetName() . "&dstfld1=elementid&dstfld2=group&srctbl=host_group&srcfld1=groupid&srcfld2=name',450,450);", 'T'))); } else { if ($elementtype == SYSMAP_ELEMENT_TYPE_IMAGE) { $frmEl->addVar('elementid', 0); } } } } } $cmbIconOff = new CComboBox('iconid_off', $iconid_off); $cmbIconOn = new CComboBox('iconid_on', $iconid_on); if ($elementtype != SYSMAP_ELEMENT_TYPE_MAP) { $cmbIconUnknown = new CComboBox('iconid_unknown', $iconid_unknown); } if ($elementtype != SYSMAP_ELEMENT_TYPE_HOST_GROUP && $elementtype != SYSMAP_ELEMENT_TYPE_MAP) { $cmbIconDisabled = new CComboBox('iconid_disabled', $iconid_disabled); } $result = DBselect('SELECT * FROM images WHERE imagetype=1 AND ' . DBin_node('imageid') . ' order by name'); while ($row = DBfetch($result)) { $row['name'] = get_node_name_by_elid($row['imageid']) . $row['name']; $cmbIconOff->addItem($row['imageid'], $row['name']); $cmbIconOn->addItem($row['imageid'], $row['name']); if ($elementtype != SYSMAP_ELEMENT_TYPE_MAP) { $cmbIconUnknown->addItem($row['imageid'], $row['name']); } if ($elementtype != SYSMAP_ELEMENT_TYPE_HOST_GROUP && $elementtype != SYSMAP_ELEMENT_TYPE_MAP) { $cmbIconDisabled->addItem($row['imageid'], $row['name']); } } $frmEl->addRow(S_ICON_OK, $cmbIconOff); if ($elementtype != SYSMAP_ELEMENT_TYPE_IMAGE) { $frmEl->addRow(S_ICON_PROBLEM, $cmbIconOn); } else { $frmEl->addVar('iconid_on', 0); } if ($elementtype != SYSMAP_ELEMENT_TYPE_MAP && $elementtype != SYSMAP_ELEMENT_TYPE_IMAGE) { $frmEl->addRow(S_ICON_UNKNOWN, $cmbIconUnknown); } else { $frmEl->addVar('iconid_unknown', 0); } if ($elementtype != SYSMAP_ELEMENT_TYPE_HOST_GROUP && $elementtype != SYSMAP_ELEMENT_TYPE_MAP && $elementtype != SYSMAP_ELEMENT_TYPE_IMAGE) { $frmEl->addRow(S_ICON_DISABLED, $cmbIconDisabled); } else { $frmEl->addVar('iconid_disabled', 0); } $frmEl->addRow(S_COORDINATE_X, new CNumericBox('x', $x, 5)); $frmEl->addRow(S_COORDINATE_Y, new CNumericBox('y', $y, 5)); $frmEl->addRow(S_URL, new CTextBox('url', $url, 64)); $frmEl->addItemToBottomRow(new CButton('save', S_SAVE)); if (isset($_REQUEST['selementid'])) { $frmEl->addItemToBottomRow(SPACE); $frmEl->addItemToBottomRow(new CButtonDelete('Delete element?', url_param('form') . url_param('selementid') . url_param('sysmapid'))); } $frmEl->addItemToBottomRow(SPACE); $frmEl->addItemToBottomRow(new CButtonCancel(url_param('sysmapid'))); $frmEl->Show(); }
$green = imagecolorallocate($im, 0, 255, 0); $darkgreen = imagecolorallocate($im, 0, 150, 0); $bluei = imagecolorallocate($im, 0, 0, 255); $darkblue = imagecolorallocate($im, 0, 0, 150); $yellow = imagecolorallocate($im, 255, 255, 0); $darkyellow = imagecolorallocate($im, 150, 150, 0); $cyan = imagecolorallocate($im, 0, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); $gray = imagecolorallocate($im, 150, 150, 150); $white = imagecolorallocate($im, 255, 255, 255); $bg = imagecolorallocate($im, 6 + 6 * 16, 7 + 7 * 16, 8 + 8 * 16); $x = imagesx($im); $y = imagesy($im); imagefilledrectangle($im, 0, 0, $x, $y, $white); imagerectangle($im, 0, 0, $x - 1, $y - 1, $black); $str = expand_trigger_description_by_data($db_data); $str = $str . ' (year ' . date('Y') . ')'; $x = imagesx($im) / 2 - imagefontwidth(4) * strlen($str) / 2; imagestring($im, 4, $x, 1, $str, $darkred); $now = time(NULL); $count_now = array(); $true = array(); $false = array(); $unknown = array(); $year = date('Y'); $start = mktime(0, 0, 0, 1, 1, $year); $wday = date('w', $start); if ($wday == 0) { $wday = 7; } $start = $start - ($wday - 1) * 24 * 3600;
$cmbType->addItem($i, $value); } //--- $btnSelect = new CButton('btn1', S_SELECT, "return PopUp('popup.php?srctbl=triggers" . '&srcfld1=triggerid' . '&real_hosts=1' . '&reference=linktrigger' . '&multiselect=1' . "&writeonly=1');", 'T'); $btnSelect->setType('button'); $btnRemove = new CButton('remove', S_REMOVE); // END preparation $trList = new CListBox('del_linktriggers[]', null, 15); if (empty($triggers)) { $trList->setAttribute('style', 'width: 300px;'); } foreach ($triggers as $tnum => $trigger) { $dbTriggers = CTrigger::get($options); order_result($dbTriggers, 'description'); $host = reset($trigger['hosts']); $trList->addItem($trigger['triggerid'], $host['host'] . ':' . expand_trigger_description_by_data($trigger)); } $frmCnct->addRow(S_TRIGGERS, array($trList, BR(), $btnSelect, $btnRemove)); $frmCnct->addRow(S_TYPE . ' (' . S_PROBLEM_BIG . ')', $cmbType); $frmCnct->addRow(S_COLOR . ' (' . S_PROBLEM_BIG . ')', new CColor('color', $color)); $frmCnct->addItemToBottomRow(new CButton('save', isset($_REQUEST['triggerid']) ? S_SAVE : S_ADD)); $frmCnct->addItemToBottomRow(SPACE); $frmCnct->addItemToBottomRow(new CButton('cancel', S_CANCEL, 'javascript: window.close();')); $frmCnct->show(); } ?> <script type="text/javascript"> //<!--<![CDATA[ function addPopupValues(list){ if(!isset('object', list)) return false;
$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['description'] = item_description($item); $items[] = $i; } // 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();
function expand_trigger_description_simple($triggerid) { $sql = 'SELECT DISTINCT t.description,h.host,t.expression,t.triggerid ' . ' FROM triggers t ' . ' LEFT JOIN functions f on t.triggerid=f.triggerid ' . ' LEFT JOIN items i on f.itemid=i.itemid ' . ' LEFT JOIN hosts h on i.hostid=h.hostid ' . ' WHERE t.triggerid=' . $triggerid; return expand_trigger_description_by_data(DBfetch(DBselect($sql))); }
foreach ($triggers as $tnum => $trigger) { $host = reset($trigger['hosts']); $trigger['host'] = $host['host']; $description = new CSpan($trigger['description'], 'link'); $trigger['description'] = $trigger['host'] . ':' . $trigger['description']; if ($multiselect) { $js_action = "javascript: addValue(" . zbx_jsvalue($reference) . ", " . zbx_jsvalue($trigger[$srcfld1]) . ");"; } else { $values = array($dstfld1 => $trigger[$srcfld1], $dstfld2 => $trigger[$srcfld2]); $js_action = 'javascript: addValues(' . zbx_jsvalue($dstfrm) . ',' . zbx_jsvalue($values) . '); return false;'; } $description->setAttribute('onclick', $js_action); if (count($trigger['dependencies']) > 0) { $description = array($description, BR(), bold(S_DEPENDS_ON), BR()); foreach ($trigger['dependencies'] as $val) { $description[] = array(expand_trigger_description_by_data($val), BR()); } } switch ($trigger['status']) { case TRIGGER_STATUS_DISABLED: $status = new CSpan(S_DISABLED, 'disabled'); break; case TRIGGER_STATUS_ENABLED: $status = new CSpan(S_ENABLED, 'enabled'); break; } $table->addRow(array($multiselect ? new CCheckBox('triggers[' . zbx_jsValue($trigger[$srcfld1]) . ']', NULL, NULL, $trigger['triggerid']) : null, $description, new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'])), $status)); } if ($multiselect) { $button = new CButton('select', S_SELECT, "javascript: addSelectedValues('triggers', " . zbx_jsvalue($reference) . ");"); $button->setType('button');
function make_latest_issues($filter = array()) { global $page; $config = select_config(); $limit = isset($filter['limit']) ? $filter['limit'] : 20; $options = array('groupids' => $filter['groupids'], 'monitored' => 1, 'maintenance' => $filter['maintenance'], 'skipDependent' => 1, 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE), 'select_groups' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND, 'sortfield' => 'lastchange', 'sortorder' => ZBX_SORT_DOWN, 'limit' => $limit); if (isset($filter['hostids'])) { $options['hostids'] = $filter['hostids']; } $triggers = CTrigger::get($options); // GATHER HOSTS FOR SELECTED TRIGGERS {{{ $triggers_hosts = array(); foreach ($triggers as $tnum => $trigger) { // if trigger is lost(broken expression) we skip it if (empty($trigger['hosts'])) { unset($triggers[$tnum]); continue; } $triggers_hosts = array_merge($triggers_hosts, $trigger['hosts']); } $triggers_hosts = zbx_toHash($triggers_hosts, 'hostid'); $triggers_hostids = array_keys($triggers_hosts); // }}} GATHER HOSTS FOR SELECTED TRIGGERS $scripts_by_hosts = CScript::getScriptsByHosts($triggers_hostids); $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST, S_ISSUE, S_LAST_CHANGE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS)); $thosts_cache = array(); foreach ($triggers as $tnum => $trigger) { // Check for dependencies $group = reset($trigger['groups']); $host = reset($trigger['hosts']); $trigger['hostid'] = $host['hostid']; $trigger['host'] = $host['host']; $host = null; $menus = ''; $host_nodeid = id2nodeid($trigger['hostid']); foreach ($scripts_by_hosts[$trigger['hostid']] as $id => $script) { $script_nodeid = id2nodeid($script['scriptid']); if (bccomp($host_nodeid, $script_nodeid) == 0) { $menus .= "[" . zbx_jsvalue($script['name']) . ",\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $trigger['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; } } if (!empty($scripts_by_hosts)) { $menus = "['" . S_TOOLS . "',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus; } if (isset($thosts_cache[$trigger['hostid']])) { $hprofile = $thosts_cache[$trigger['hostid']]; } else { $hprofile = CHost::get(array('hostids' => $trigger['hostid'], 'output' => API_OUTPUT_SHORTEN, 'select_profile' => API_OUTPUT_EXTEND)); $hprofile = reset($hprofile); $thosts_cache[$hprofile['hostid']] = $hprofile; } $menus .= "['" . S_LINKS . "',null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],"; $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?groupid=" . $group['groupid'] . '&hostid=' . $trigger['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; if (!empty($hprofile['profile'])) { $menus .= "['" . S_PROFILE . "',\"javascript: redirect('hostprofiles.php?hostid=" . $trigger['hostid'] . "&prof_type=0')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; } if (!empty($hprofile['profile_ext'])) { $menus .= "['" . S_EXTENDED_PROFILE . "',\"javascript: redirect('hostprofiles.php?hostid=" . $trigger['hostid'] . "&prof_type=1')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; } $menus = rtrim($menus, ','); $menus = 'show_popup_menu(event,[' . $menus . '],180);'; $host = new CSpan($trigger['host'], 'link_menu pointer'); $host->setAttribute('onclick', 'javascript: ' . $menus); //$host = new CSpan($trigger['host'],'link_menu pointer'); //$host->setAttribute('onclick','javascript: '.$menus); // Maintenance {{{ $trigger_host = $triggers_hosts[$trigger['hostid']]; $text = null; $style = 'link_menu'; if ($trigger_host['maintenance_status']) { $style .= ' orange'; $options = array('maintenanceids' => $trigger_host['maintenanceid'], 'output' => API_OUTPUT_EXTEND); $maintenances = CMaintenance::get($options); $maintenance = reset($maintenances); $text = $maintenance['name']; $text .= ' [' . ($trigger_host['maintenance_type'] ? S_NO_DATA_MAINTENANCE : S_NORMAL_MAINTENANCE) . ']'; } $host = new CSpan($trigger['host'], $style . ' pointer'); $host->setAttribute('onclick', 'javascript: ' . $menus); if (!is_null($text)) { $host->setHint($text, '', '', false); } // }}} Maintenance $event_sql = 'SELECT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged' . ' FROM events e' . ' WHERE e.object=' . EVENT_OBJECT_TRIGGER . ' AND e.objectid=' . $trigger['triggerid'] . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC'; $res_events = DBSelect($event_sql, 1); while ($row_event = DBfetch($res_events)) { $ack = NULL; if ($config['event_ack_enable']) { if ($row_event['acknowledged'] == 1) { $ack_info = make_acktab_by_eventid($row_event['eventid']); $ack_info->setAttribute('style', 'width: auto;'); $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_event['eventid'] . '&backurl=' . $page['file'], 'off'); $ack->setHint($ack_info, '', '', false); } else { $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_event['eventid'] . '&backurl=' . $page['file'], 'on'); } } // $description = expand_trigger_description($row['triggerid']); $description = expand_trigger_description_by_data(zbx_array_merge($trigger, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT); //actions $actions = get_event_actions_stat_hints($row_event['eventid']); $clock = new CLink(zbx_date2str(S_BLOCKS_LATEST_ISSUES_DATE_FORMAT, $row_event['clock']), 'events.php?triggerid=' . $trigger['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $row_event['clock']); if ($trigger['url']) { $description = new CLink($description, $trigger['url'], null, null, true); } else { $description = new CSpan($description, 'pointer'); } $description = new CCol($description, get_severity_style($trigger['priority'])); $description->setHint(make_popup_eventlist($row_event['eventid'], $trigger['type'], $trigger['triggerid']), '', '', false); $table->addRow(array(get_node_name_by_elid($trigger['triggerid']), $host, $description, $clock, zbx_date2age($row_event['clock']), $ack, $actions)); } unset($trigger, $description, $actions); } $table->setFooter(new CCol(S_UPDATED . ': ' . zbx_date2str(S_BLOCKS_LATEST_ISSUES_TIME_FORMAT))); return $table; }
} if ($_REQUEST['hostid'] > 0) { $sql_where .= ' AND h.hostid=' . $_REQUEST['hostid']; } } else { if ($_REQUEST['hostid'] > 0) { $sql_from .= ',hosts_templates ht '; $sql_where .= ' AND ht.hostid=h.hostid AND ht.templateid=' . $_REQUEST['hostid']; } if (isset($_REQUEST['tpl_triggerid']) && $_REQUEST['tpl_triggerid'] > 0) { $sql_where .= ' AND t.templateid=' . $_REQUEST['tpl_triggerid']; } } $result = DBselect('SELECT DISTINCT h.hostid,h.host,t.triggerid,t.expression,t.description,t.value ' . ' FROM triggers t,hosts h,items i,functions f ' . $sql_from . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND i.hostid=h.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND f.itemid=i.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . $sql_where . ' ORDER BY h.host, t.description'); $table = new CTableInfo(); $table->setHeader(array(is_show_subnodes() ? S_NODE : null, $_REQUEST['hostid'] == 0 || 1 == $config ? S_HOST : NULL, S_NAME, S_TRUE, S_FALSE, S_UNKNOWN, S_GRAPH)); while ($row = DBfetch($result)) { if (!check_right_on_trigger_by_triggerid(null, $row['triggerid'])) { continue; } $availability = calculate_availability($row['triggerid'], $_REQUEST['filter_timesince'], $_REQUEST['filter_timetill']); $true = new CSpan(sprintf("%.4f%%", $availability['true']), 'on'); $false = new CSpan(sprintf("%.4f%%", $availability['false']), 'off'); $unknown = new CSpan(sprintf("%.4f%%", $availability['unknown']), 'unknown'); $actions = new CLink(S_SHOW, 'report2.php?hostid=' . $_REQUEST['hostid'] . '&triggerid=' . $row['triggerid'], 'action'); $table->addRow(array(get_node_name_by_elid($row['hostid']), $_REQUEST['hostid'] == 0 || 1 == $config ? $row['host'] : NULL, new CLink(expand_trigger_description_by_data($row), 'events.php?triggerid=' . $row['triggerid'], 'action'), $true, $false, $unknown, $actions)); } $table->show(); } } include_once 'include/page_footer.php';
function getSelementsInfo($sysmap) { $config = select_config(); $show_unack = $config['event_ack_enable'] ? $sysmap['show_unack'] : EXTACK_OPTION_ALL; $triggers_map = array(); $triggers_map_submaps = array(); $hostgroups_map = array(); $hosts_map = array(); $selements = zbx_toHash($sysmap['selements'], 'selementid'); foreach ($selements as $selementid => $selement) { $selements[$selementid]['hosts'] = array(); $selements[$selementid]['triggers'] = array(); switch ($selement['elementtype']) { case SYSMAP_ELEMENT_TYPE_MAP: $mapids = array($selement['elementid']); while (!empty($mapids)) { $options = array('sysmapids' => $mapids, 'output' => API_OUTPUT_EXTEND, 'select_selements' => API_OUTPUT_EXTEND, 'nopermissions' => 1, 'nodeids' => get_current_nodeid(true)); $maps = CMap::get($options); $mapids = array(); foreach ($maps as $map) { foreach ($map['selements'] as $sel) { switch ($sel['elementtype']) { case SYSMAP_ELEMENT_TYPE_MAP: $mapids[] = $sel['elementid']; break; case SYSMAP_ELEMENT_TYPE_HOST_GROUP: $hostgroups_map[$sel['elementid']][$selementid] = $selementid; break; case SYSMAP_ELEMENT_TYPE_HOST: $hosts_map[$sel['elementid']][$selementid] = $selementid; break; case SYSMAP_ELEMENT_TYPE_TRIGGER: $triggers_map_submaps[$sel['elementid']][$selementid] = $selementid; break; } } } } break; case SYSMAP_ELEMENT_TYPE_HOST_GROUP: $hostgroups_map[$selement['elementid']][$selement['selementid']] = $selement['selementid']; break; case SYSMAP_ELEMENT_TYPE_HOST: $hosts_map[$selement['elementid']][$selement['selementid']] = $selement['selementid']; break; case SYSMAP_ELEMENT_TYPE_TRIGGER: $triggers_map[$selement['elementid']][$selement['selementid']] = $selement['selementid']; break; } } // get hosts data {{{ $all_hosts = array(); if (!empty($hosts_map)) { $options = array('hostids' => array_keys($hosts_map), 'output' => API_OUTPUT_EXTEND, 'nopermissions' => 1, 'nodeids' => get_current_nodeid(true)); $hosts = CHost::get($options); $all_hosts = array_merge($all_hosts, $hosts); foreach ($hosts as $host) { foreach ($hosts_map[$host['hostid']] as $belongs_to_sel) { $selements[$belongs_to_sel]['hosts'][$host['hostid']] = $host['hostid']; } } } if (!empty($hostgroups_map)) { $options = array('groupids' => array_keys($hostgroups_map), 'output' => API_OUTPUT_EXTEND, 'nopermissions' => 1, 'nodeids' => get_current_nodeid(true)); $hosts = CHost::get($options); $all_hosts = array_merge($all_hosts, $hosts); foreach ($hosts as $host) { foreach ($host['groups'] as $group) { foreach ($hostgroups_map[$group['groupid']] as $belongs_to_sel) { $selements[$belongs_to_sel]['hosts'][$host['hostid']] = $host['hostid']; // add hosts to hosts_map for trigger selection; if (!isset($hosts_map[$host['hostid']])) { $hosts_map[$host['hostid']] = array(); } $hosts_map[$host['hostid']][$belongs_to_sel] = $belongs_to_sel; } } } } $all_hosts = zbx_toHash($all_hosts, 'hostid'); $monitored_hostids = array(); foreach ($all_hosts as $hostid => $host) { if ($host['status'] == HOST_STATUS_MONITORED) { $monitored_hostids[$hostid] = $hostid; } } // }}} // get triggers data {{{ $all_triggers = array(); // triggers from current map, select all if (!empty($triggers_map)) { $options = array('nodeids' => get_current_nodeid(true), 'triggerids' => array_keys($triggers_map), 'output' => API_OUTPUT_EXTEND, 'nopermissions' => 1); $triggers = CTrigger::get($options); $all_triggers = array_merge($all_triggers, $triggers); foreach ($triggers as $trigger) { foreach ($triggers_map[$trigger['triggerid']] as $belongs_to_sel) { $selements[$belongs_to_sel]['triggers'][$trigger['triggerid']] = $trigger['triggerid']; } } } // triggers from submaps, skip dependent if (!empty($triggers_map_submaps)) { $options = array('nodeids' => get_current_nodeid(true), 'triggerids' => array_keys($triggers_map_submaps), 'filter' => array('value' => array(TRIGGER_VALUE_UNKNOWN, TRIGGER_VALUE_TRUE)), 'skipDependent' => 1, 'output' => API_OUTPUT_EXTEND, 'nopermissions' => 1); $triggers = CTrigger::get($options); $all_triggers = array_merge($all_triggers, $triggers); foreach ($triggers as $trigger) { foreach ($triggers_map_submaps[$trigger['triggerid']] as $belongs_to_sel) { $selements[$belongs_to_sel]['triggers'][$trigger['triggerid']] = $trigger['triggerid']; } } } // triggers from all hosts/hostgroups, skip dependent if (!empty($monitored_hostids)) { $options = array('hostids' => $monitored_hostids, 'output' => API_OUTPUT_EXTEND, 'nopermissions' => 1, 'filter' => array('value' => array(TRIGGER_VALUE_UNKNOWN, TRIGGER_VALUE_TRUE)), 'nodeids' => get_current_nodeid(true), 'monitored' => true, 'skipDependent' => 1); $triggers = CTrigger::get($options); $all_triggers = array_merge($all_triggers, $triggers); foreach ($triggers as $trigger) { foreach ($trigger['hosts'] as $host) { foreach ($hosts_map[$host['hostid']] as $belongs_to_sel) { $selements[$belongs_to_sel]['triggers'][$trigger['triggerid']] = $trigger['triggerid']; } } } } $all_triggers = zbx_toHash($all_triggers, 'triggerid'); $options = array('triggerids' => array_keys($all_triggers), 'withLastEventUnacknowledged' => true, 'output' => API_OUTPUT_SHORTEN, 'nodeids' => get_current_nodeid(true), 'nopermissions' => 1, 'monitored' => true, 'filter' => array('value' => TRIGGER_VALUE_TRUE)); $unack_triggerids = CTrigger::get($options); $unack_triggerids = zbx_toHash($unack_triggerids, 'triggerid'); // }}} $info = array(); foreach ($selements as $selementid => $selement) { $i = array('disabled' => 0, 'maintenance' => 0, 'problem' => 0, 'problem_unack' => 0, 'unknown' => 0, 'priority' => 0, 'trigger_disabled' => 0, 'latelyChanged' => false, 'ack' => true); foreach ($selement['hosts'] as $hostid) { $host = $all_hosts[$hostid]; $last_hostid = $hostid; if ($host['status'] == HOST_STATUS_NOT_MONITORED) { $i['disabled']++; } else { if ($host['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) { $i['maintenance']++; } } } foreach ($selement['triggers'] as $triggerid) { $trigger = $all_triggers[$triggerid]; if ($trigger['status'] == TRIGGER_STATUS_DISABLED) { $i['trigger_disabled']++; } else { if ($trigger['value'] == TRIGGER_VALUE_TRUE) { $i['problem']++; $last_problemid = $triggerid; if ($i['priority'] < $trigger['priority']) { $i['priority'] = $trigger['priority']; } } else { if ($trigger['value'] == TRIGGER_VALUE_UNKNOWN) { $i['unknown']++; } } if (isset($unack_triggerids[$triggerid])) { $i['problem_unack']++; } $i['latelyChanged'] |= time() - $trigger['lastchange'] < TRIGGER_BLINK_PERIOD; } } $i['ack'] = (bool) (!$i['problem_unack']); if ($sysmap['expandproblem'] && $i['problem'] == 1) { $i['problem_title'] = expand_trigger_description_by_data($all_triggers[$last_problemid]); } if ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST && $i['maintenance'] == 1) { $mnt = get_maintenance_by_maintenanceid($all_hosts[$last_hostid]['maintenanceid']); $i['maintenance_title'] = $mnt['name']; } switch ($selement['elementtype']) { case SYSMAP_ELEMENT_TYPE_MAP: $info[$selementid] = getMapsInfo($selement, $i, $show_unack); break; case SYSMAP_ELEMENT_TYPE_HOST_GROUP: $info[$selementid] = getHostGroupsInfo($selement, $i, $show_unack); break; case SYSMAP_ELEMENT_TYPE_HOST: $info[$selementid] = getHostsInfo($selement, $i, $show_unack); break; case SYSMAP_ELEMENT_TYPE_TRIGGER: $info[$selementid] = getTriggersInfo($selement, $i); break; case SYSMAP_ELEMENT_TYPE_IMAGE: $info[$selementid] = getImagesInfo($selement); break; } } // get names if is needed if ($sysmap['label_type'] == MAP_LABEL_TYPE_NAME) { $elems = separateMapElements($sysmap); if (!empty($elems['sysmaps'])) { $maps = CMap::get(array('sysmapids' => zbx_objectValues($elems['sysmaps'], 'elementid'), 'nopermissions' => 1, 'output' => API_OUTPUT_EXTEND)); $maps = zbx_toHash($maps, 'sysmapid'); foreach ($elems['sysmaps'] as $elem) { $info[$elem['selementid']]['name'] = $maps[$elem['elementid']]['name']; } } if (!empty($elems['hostgroups'])) { $hostgroups = CHostGroup::get(array('groupids' => zbx_objectValues($elems['hostgroups'], 'elementid'), 'nopermissions' => 1, 'output' => API_OUTPUT_EXTEND)); $hostgroups = zbx_toHash($hostgroups, 'groupid'); foreach ($elems['hostgroups'] as $elem) { $info[$elem['selementid']]['name'] = $hostgroups[$elem['elementid']]['name']; } } if (!empty($elems['triggers'])) { foreach ($elems['triggers'] as $elem) { $info[$elem['selementid']]['name'] = expand_trigger_description_by_data($all_triggers[$elem['elementid']]); } } if (!empty($elems['hosts'])) { foreach ($elems['hosts'] as $elem) { $info[$elem['selementid']]['name'] = $all_hosts[$elem['elementid']]['host']; } } } return $info; }
function get_info_by_selementid($selementid) { global $colors; $el_name = ''; $tr_info = array(); $db_element = get_sysmaps_element_by_selementid($selementid); $el_type =& $db_element["elementtype"]; $sql = array(SYSMAP_ELEMENT_TYPE_TRIGGER => 'SELECT DISTINCT t.triggerid,t.priority,t.value,t.description' . ',t.expression,h.host,h.status as h_status,i.status as i_status,t.status as t_status' . ' FROM triggers t, items i, functions f, hosts h ' . ' WHERE t.triggerid=' . $db_element['elementid'] . ' AND h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ', SYSMAP_ELEMENT_TYPE_HOST_GROUP => 'SELECT DISTINCT t.triggerid, t.priority, t.value, t.description, t.expression, h.host' . ' FROM items i,functions f,triggers t,hosts h,hosts_groups hg,groups g ' . ' WHERE h.hostid=i.hostid ' . ' AND hg.groupid=g.groupid ' . ' AND g.groupid=' . $db_element['elementid'] . ' AND hg.hostid=h.hostid ' . ' AND i.itemid=f.itemid' . ' AND f.triggerid=t.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE, SYSMAP_ELEMENT_TYPE_HOST => 'SELECT DISTINCT t.triggerid, t.priority, t.value, t.description, t.expression, h.host' . ' FROM items i,functions f,triggers t,hosts h WHERE h.hostid=i.hostid' . ' AND i.hostid=' . $db_element['elementid'] . ' AND i.itemid=f.itemid' . ' AND f.triggerid=t.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE); $out['triggers'] = array(); if (isset($sql[$el_type])) { $db_triggers = DBselect($sql[$el_type]); $trigger = DBfetch($db_triggers); if ($trigger) { if ($el_type == SYSMAP_ELEMENT_TYPE_TRIGGER) { $el_name = expand_trigger_description_by_data($trigger); } do { if ($el_type == SYSMAP_ELEMENT_TYPE_TRIGGER && ($trigger['h_status'] != HOST_STATUS_MONITORED || $trigger['i_status'] != ITEM_STATUS_ACTIVE || $trigger['t_status'] != TRIGGER_STATUS_ENABLED)) { $type = TRIGGER_VALUE_UNKNOWN; $out['disabled'] = 1; } else { $type =& $trigger['value']; } if (!isset($tr_info[$type])) { $tr_info[$type] = array('count' => 0); } $tr_info[$type]['count']++; if (!isset($tr_info[$type]['priority']) || $tr_info[$type]['priority'] < $trigger["priority"]) { $tr_info[$type]['priority'] = $trigger["priority"]; if ($el_type != SYSMAP_ELEMENT_TYPE_TRIGGER && $type != TRIGGER_VALUE_UNKNOWN) { $tr_info[$type]['info'] = expand_trigger_description_by_data($trigger); } } if ($type == TRIGGER_VALUE_TRUE) { array_push($out['triggers'], $trigger['triggerid']); } } while ($trigger = DBfetch($db_triggers)); } } else { if ($el_type == SYSMAP_ELEMENT_TYPE_MAP) { $triggers = array(); $db_subelements = DBselect("select selementid FROM sysmaps_elements" . " WHERE sysmapid=" . $db_element["elementid"]); while ($db_subelement = DBfetch($db_subelements)) { // recursion $inf = get_info_by_selementid($db_subelement["selementid"]); foreach ($inf['triggers'] as $id => $triggerid) { if (!in_array($triggerid, $triggers)) { array_push($triggers, $triggerid); } } $type = $inf['type']; if (!isset($tr_info[$type]['count'])) { $tr_info[$type]['count'] = 0; } $tr_info[$type]['count'] += isset($inf['count']) ? $inf['count'] : 1; if (!isset($tr_info[$type]['priority']) || $tr_info[$type]['priority'] < $inf["priority"]) { $tr_info[$type]['priority'] = $inf['priority']; $tr_info[$type]['info'] = $inf['info']; } } $count = count($triggers); if ($count > 0) { $tr_info[TRIGGER_VALUE_TRUE]['count'] = $count; if ($tr_info[TRIGGER_VALUE_TRUE]['count'] == 1) { $db_trigger = DBfetch(DBselect('SELECT DISTINCT t.triggerid,t.priority,t.value,t.description' . ',t.expression,h.host FROM triggers t, items i, functions f, hosts h' . ' WHERE t.triggerid=' . $triggers[0] . ' AND h.hostid=i.hostid' . ' AND i.itemid=f.itemid AND f.triggerid=t.triggerid')); $tr_info[TRIGGER_VALUE_TRUE]['info'] = expand_trigger_description_by_data($db_trigger); } } } } if ($el_type == SYSMAP_ELEMENT_TYPE_HOST) { $host = get_host_by_hostid($db_element["elementid"]); $el_name = $host['host']; if ($host["status"] == HOST_STATUS_TEMPLATE) { $tr_info[TRIGGER_VALUE_UNKNOWN]['count'] = 0; $tr_info[TRIGGER_VALUE_UNKNOWN]['priority'] = 0; $tr_info[TRIGGER_VALUE_UNKNOWN]['info'] = 'template'; } else { if ($host["status"] == HOST_STATUS_NOT_MONITORED) { $tr_info[TRIGGER_VALUE_UNKNOWN]['count'] = 0; $tr_info[TRIGGER_VALUE_UNKNOWN]['priority'] = 0; $out['disabled'] = 1; } else { if (!isset($tr_info[TRIGGER_VALUE_FALSE])) { $tr_info[TRIGGER_VALUE_FALSE]['count'] = 0; $tr_info[TRIGGER_VALUE_FALSE]['priority'] = 0; $tr_info[TRIGGER_VALUE_FALSE]['info'] = 'OK'; } } } } else { if ($el_type == SYSMAP_ELEMENT_TYPE_HOST_GROUP) { $group = get_hostgroup_by_groupid($db_element["elementid"]); $el_name = $group['name']; if (!isset($tr_info[TRIGGER_VALUE_FALSE])) { $tr_info[TRIGGER_VALUE_FALSE]['count'] = 0; $tr_info[TRIGGER_VALUE_FALSE]['priority'] = 0; $tr_info[TRIGGER_VALUE_FALSE]['info'] = 'OK'; } } else { if ($el_type == SYSMAP_ELEMENT_TYPE_MAP) { $db_map = DBfetch(DBselect('select name FROM sysmaps WHERE sysmapid=' . $db_element["elementid"])); $el_name = $db_map['name']; if (!isset($tr_info[TRIGGER_VALUE_FALSE])) { $tr_info[TRIGGER_VALUE_FALSE]['count'] = 0; $tr_info[TRIGGER_VALUE_FALSE]['priority'] = 0; $tr_info[TRIGGER_VALUE_FALSE]['info'] = 'OK'; } } } } if (isset($tr_info[TRIGGER_VALUE_TRUE])) { $inf =& $tr_info[TRIGGER_VALUE_TRUE]; $out['type'] = TRIGGER_VALUE_TRUE; $out['info'] = 'PROBLEM'; if ($inf['count'] > 1) { $out['info'] = $inf['count'] . ' problems'; } else { if (isset($inf['info'])) { $out['info'] = $inf['info']; } } if (isset($inf['priority']) && $inf['priority'] > 3) { $out['color'] = $colors['Red']; } else { $out['color'] = $colors['Dark Red']; } $out['iconid'] = $db_element['iconid_on']; } else { if (isset($tr_info[TRIGGER_VALUE_UNKNOWN]) && !isset($tr_info[TRIGGER_VALUE_FALSE])) { $inf =& $tr_info[TRIGGER_VALUE_UNKNOWN]; $out['type'] = TRIGGER_VALUE_UNKNOWN; $out['info'] = 'UNKNOWN'; $out['color'] = $colors['Gray']; if (isset($out['disabled']) && $out['disabled'] == 1) { $out['iconid'] = $db_element['iconid_disabled']; } else { $out['iconid'] = $db_element['iconid_unknown']; } if (isset($inf['info'])) { $out['info'] = $inf['info']; } } else { $inf =& $tr_info[TRIGGER_VALUE_FALSE]; $out['type'] = TRIGGER_VALUE_FALSE; $out['info'] = 'OK'; if (isset($inf['info'])) { $out['info'] = 'OK'; } $out['color'] = $colors['Dark Green']; $out['iconid'] = $db_element['iconid_off']; } } // No label for Images if ($el_type == SYSMAP_ELEMENT_TYPE_IMAGE) { $out['info'] = ''; } $out['count'] = $inf['count']; $out['priority'] = isset($inf['priority']) ? $inf['priority'] : 0; $out['name'] = $el_name; return $out; }
} } $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; } } $msg = $bulk ? ' BULK ACKNOWLEDGE ' : expand_trigger_description_by_data($event_trigger); show_table_header(array(S_ALARM_ACKNOWLEDGES_BIG . ': ', $msg)); print SBR; if ($bulk) { $title = S_ACKNOWLEDGE_ALARM_BY; $btn_txt2 = S_ACKNOWLEDGE . ' ' . S_AND_SYMB . ' ' . S_RETURN; } else { $db_acks = get_acknowledges_by_eventid($_REQUEST['eventid']); if ($db_acks) { $table = new CTable(null, 'ack_msgs'); $table->setAlign('center'); while ($db_ack = DBfetch($db_acks)) { //$db_users = CUser::get(array('userids' => $db_ack['userid'], 'output' => API_OUTPUT_EXTEND)); //$db_user = reset($db_users); $table->addRow(array(new CCol($db_ack['alias'], 'user'), new CCol(zbx_date2str(S_ACKNOWLEDGE_DATE_FORMAT, $db_ack['clock']), 'time')), 'title'); $msgCol = new CCol(zbx_nl2br($db_ack['message']));
function get_history_of_triggers_events($start, $num, $groupid = 0, $hostid = 0) { global $USER_DETAILS; $config = select_config(); $show_unknown = get_profile('web.events.filter.show_unknown', 0); $sql_from = $sql_cond = ''; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_LIST); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_DATA_ARRAY, get_current_nodeid()); if ($hostid > 0) { $sql_cond = ' AND h.hostid=' . $hostid; } else { if ($groupid > 0) { $sql_from = ', hosts_groups hg '; $sql_cond = ' AND h.hostid=hg.hostid AND hg.groupid=' . $groupid; } else { $sql_from = ''; $sql_cond = ' AND ' . DBcondition('h.hostid', $available_hosts); } } //--- $triggers = array(); $trigger_list = array(); $sql = 'SELECT DISTINCT t.triggerid,t.priority,t.description,t.expression,h.host,t.type ' . ' FROM triggers t, functions f, items i, hosts h ' . $sql_from . ' WHERE ' . DBcondition('t.triggerid', $available_triggers) . ' AND t.triggerid=f.triggerid ' . ' AND f.itemid=i.itemid ' . ' AND i.hostid=h.hostid ' . ' AND h.status=' . HOST_STATUS_MONITORED . $sql_cond; $rez = DBselect($sql); while ($rowz = DBfetch($rez)) { $triggers[$rowz['triggerid']] = $rowz; array_push($trigger_list, $rowz['triggerid']); } $sql_cond = $show_unknown == 0 ? ' AND e.value<>' . TRIGGER_VALUE_UNKNOWN . ' ' : ''; $table = new CTableInfo(S_NO_EVENTS_FOUND); $table->SetHeader(array(S_TIME, is_show_all_nodes() ? S_NODE : null, $hostid == 0 ? S_HOST : null, S_DESCRIPTION, S_VALUE, S_SEVERITY)); if (!empty($triggers)) { $sql = 'SELECT e.eventid, e.objectid as triggerid, e.clock, e.value, e.acknowledged ' . ' FROM events e ' . ' WHERE e.object=' . EVENT_OBJECT_TRIGGER . ' AND ' . DBcondition('e.objectid', $trigger_list) . $sql_cond . ' ORDER BY e.eventid DESC'; $result = DBselect($sql, 10 * ($start + $num)); } $col = 0; $skip = $start; while (!empty($triggers) && $col < $num && ($row = DBfetch($result))) { if ($skip > 0) { if ($show_unknown == 0 && $row['value'] == TRIGGER_VALUE_UNKNOWN) { continue; } $skip--; continue; } $value = new CCol(trigger_value2str($row['value']), get_trigger_value_style($row['value'])); $row = array_merge($triggers[$row['triggerid']], $row); if (0 == $show_unknown && !event_initial_time($row, $show_unknown)) { continue; } $table->AddRow(array(date("Y.M.d H:i:s", $row["clock"]), get_node_name_by_elid($row['triggerid']), $hostid == 0 ? $row['host'] : null, new CLink(expand_trigger_description_by_data($row, ZBX_FLAG_EVENT), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row['eventid'], 'action'), $value, new CCol(get_severity_description($row["priority"]), get_severity_style($row["priority"])))); $col++; } return $table; }
function add_host_to_services($hostid, $serviceid) { $result = DBselect('SELECT distinct h.host,t.triggerid,t.description,t.expression ' . ' FROM triggers t,hosts h,items i,functions f ' . ' WHERE h.hostid=' . $hostid . ' AND h.hostid=i.hostid ' . ' AND i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND ' . DBin_node('t.triggerid', get_current_nodeid(false))); while ($row = DBfetch($result)) { $serviceid2 = add_service(expand_trigger_description_by_data($row), $row["triggerid"], "on", 0, "off", 99); add_service_link($serviceid2, $serviceid, 0); } return 1; }
} $description[] = new CLink($trigger['description'], 'triggers.php?form=update&triggerid=' . $triggerid); //add dependencies { $deps = $trigger['dependencies']; if (count($deps) > 0) { $description[] = array(BR(), bold(S_DEPENDS_ON . ' : ')); foreach ($deps as $dnum => $dep_trigger) { $description[] = BR(); $hosts = get_hosts_by_triggerid($dep_trigger['triggerid']); while ($host = DBfetch($hosts)) { $description[] = $host['host']; $description[] = ', '; } array_pop($description); $description[] = ' : '; $description[] = expand_trigger_description_by_data($dep_trigger); } } // } add dependencies if ($trigger['value'] != TRIGGER_VALUE_UNKNOWN) { $trigger['error'] = ''; } $templated = false; foreach ($trigger['hosts'] as $hostid => $host) { $templated |= HOST_STATUS_TEMPLATE == $host['status']; } if (!zbx_empty($trigger['error']) && !$templated) { $error = new CDiv(SPACE, 'iconerror'); $error->setHint($trigger['error'], '', 'on'); } else { $error = new CDiv(SPACE, 'iconok');
$rep2_wdgt->addPageHeader(S_AVAILABILITY_REPORT_BIG); // show_report2_header($config, $PAGE_GROUPS, $PAGE_HOSTS); if (isset($_REQUEST['triggerid'])) { $options = array('triggerids' => $_REQUEST['triggerid'], 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_EXTEND, 'nodeids' => get_current_nodeid(true)); $trigger_data = CTrigger::get($options); if (empty($trigger_data)) { unset($_REQUEST['triggerid']); } else { $trigger_data = reset($trigger_data); $host = reset($trigger_data['hosts']); $trigger_data['hostid'] = $host['hostid']; $trigger_data['host'] = $host['host']; } } if (isset($_REQUEST['triggerid'])) { $rep2_wdgt->addHeader(array(new CLink($trigger_data['host'], '?filter_groupid=' . $_REQUEST['groupid'] . '&filter_hostid=' . $trigger_data['hostid']), ' : ', expand_trigger_description_by_data($trigger_data)), SPACE); $table = new CTableInfo(null, 'graph'); $table->addRow(new CImg('chart4.php?triggerid=' . $_REQUEST['triggerid'])); $rep2_wdgt->addItem($table); $rep2_wdgt->show(); } else { if (isset($_REQUEST['hostid'])) { $r_form = new CForm(); $r_form->setMethod('get'); $cmbConf = new CComboBox('config', $config, 'submit()'); $cmbConf->addItem(0, S_BY_HOST); $cmbConf->addItem(1, S_BY_TRIGGER_TEMPLATE); $r_form->addItem($cmbConf); $rep2_wdgt->addHeader(S_REPORT_BIG, array(S_MODE . SPACE, $r_form)); // FILTER $filterForm = get_report2_filter($config, $PAGE_GROUPS, $PAGE_HOSTS);
$result = DBselect($sql, 100); while ($row = DBfetch($result)) { $row['items'] = array(); $triggers[$row['triggerid']] = $row; $triggerids[$row['triggerid']] = $row['triggerid']; } $sql = 'SELECT f.triggerid, i.* ' . ' FROM functions f, items i ' . ' WHERE ' . DBcondition('f.triggerid', $triggerids) . ' AND i.itemid=f.itemid'; $result = DBselect($sql); while ($row = DBfetch($result)) { $item['itemid'] = $row['itemid']; $item['action'] = str_in_array($row['value_type'], array(ITEM_VALUE_TYPE_FLOAT, ITEM_VALUE_TYPE_UINT64)) ? 'showgraph' : 'showvalues'; $item['description'] = item_description($row); $triggers[$row['triggerid']]['items'][$row['itemid']] = $item; } foreach ($triggers as $triggerid => $row) { $description = expand_trigger_description_by_data($row); $menus = ''; $host_nodeid = id2nodeid($row['hostid']); foreach ($scripts_by_hosts[$row['hostid']] as $id => $script) { $script_nodeid = id2nodeid($script['scriptid']); if (bccomp($host_nodeid, $script_nodeid) == 0) { $menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $row['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; } } $menus .= "[" . zbx_jsvalue(S_LINKS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],"; $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?hostid=" . $row['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; $menus = rtrim($menus, ','); $menus = "show_popup_menu(event,[[" . zbx_jsvalue(S_TOOLS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus . "],180);"; $host = new CSpan($row['host']); $host->addOption('onclick', 'javascript: ' . $menus); $host->addOption('onmouseover', "javascript: this.style.cursor = 'pointer';");
if ('hat' == $_REQUEST['favobj']) { update_profile('web.tr_events.hats.' . $_REQUEST['favid'] . '.state', $_REQUEST['state'], PROFILE_TYPE_INT); } } if (PAGE_TYPE_JS == $page['type'] || PAGE_TYPE_HTML_BLOCK == $page['type']) { exit; } //-------- if (!check_right_on_trigger_by_triggerid(PERM_READ_ONLY, $_REQUEST["triggerid"])) { access_deny(); } $trigger_data = DBfetch(DBselect('SELECT h.host, t.* ' . ' FROM hosts h, items i, functions f, triggers t ' . ' WHERE i.itemid=f.itemid ' . ' AND f.triggerid=t.triggerid ' . ' AND t.triggerid=' . $_REQUEST["triggerid"] . ' AND h.hostid=i.hostid ' . ' AND ' . DBin_node('t.triggerid'))); $p_elements = array(); //Header $trigger_data['exp_expr'] = explode_exp($trigger_data["expression"], 1); $trigger_data['exp_desc'] = expand_trigger_description_by_data($trigger_data); $text = array(S_EVENTS_BIG . ': "' . $trigger_data['exp_desc'] . '"'); $url = '?fullscreen=' . ($_REQUEST['fullscreen'] ? '0' : '1') . url_param('triggerid') . url_param('eventid'); $fs_icon = new CDiv(SPACE, 'fullscreen'); $fs_icon->addOption('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN); $fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url . "';")); //------- $left_tab = new CTable(); $left_tab->setCellPadding(3); $left_tab->setCellSpacing(3); $left_tab->addOption('border', 0); $left_tab->addRow(create_hat(S_EVENT . SPACE . S_SOURCE . SPACE . S_DETAILS, make_trigger_details($_REQUEST['triggerid'], $trigger_data), null, 'hat_triggerdetails')); $left_tab->addRow(create_hat(S_EVENT_DETAILS, make_event_details($_REQUEST['eventid']), null, 'hat_eventdetails')); $right_tab = new CTable(); $right_tab->setCellPadding(3); $right_tab->setCellSpacing(3);
} $duration = zbx_date2age($row['clock']); if ($next_event = get_next_event($row, $show_unknown)) { $duration = zbx_date2age($row['clock'], $next_event['clock']); } // Actions $actions = get_event_actions_status($row['eventid']); //-------- if ($config['event_ack_enable']) { if ($row['acknowledged'] == 1) { $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row['eventid'], 'action'); } else { $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row['eventid'], 'on'); } } $tr_desc = new CSpan(expand_trigger_description_by_data($row, ZBX_FLAG_EVENT), 'pointer'); $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $row['triggerid'] . "', 'lastchange': '" . $row['clock'] . "'})," . zbx_jsvalue($row['items']) . ");"); $table->AddRow(array(new CLink(date('Y.M.d H:i:s', $row['clock']), 'tr_events.php?triggerid=' . $row['triggerid'] . '&eventid=' . $row['eventid'], 'action'), is_show_subnodes() ? get_node_name_by_elid($row['triggerid']) : null, $_REQUEST['hostid'] == 0 ? $row['host'] : null, $tr_desc, $value, new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'], $row['value'])), $duration, $config['event_ack_enable'] ? $ack : NULL, $actions)); $col++; } } } /************************* FILTER **************************/ /***********************************************************/ // Navigation $nav_time = get_request('nav_time', time()); $navForm = new CForm('events.php'); if (isset($_REQUEST['groupid'])) { $navForm->AddVar('groupid', $_REQUEST['groupid']); } if (isset($_REQUEST['hostid'])) {
function make_latest_issues($params = array()) { global $USER_DETAILS; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array()); $scripts_by_hosts = get_accessible_scripts_by_hosts($available_hosts); $config = select_config(); $sql_select = ''; $sql_from = ''; $sql_where = ''; $limit = 20; if (!empty($params)) { if (isset($params['limit'])) { $limit = $params['limit']; } if (isset($params['groupid']) && $params['groupid'] > 0) { $sql_select .= ',g.name '; $sql_from .= ',groups g '; $sql_where .= ' AND g.groupid=hg.groupid ' . ' AND hg.groupid=' . $params['groupid']; } if (isset($params['hostid']) && $params['hostid'] > 0) { $sql_where .= ' AND h.hostid=' . $params['hostid']; } } $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, isset($params['groupid']) && $params['groupid'] > 0 ? S_GROUP : null, S_HOST, S_ISSUE, S_LAST_CHANGE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS)); $sql = 'SELECT DISTINCT t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.value,h.host,h.hostid ' . $sql_select . ' FROM triggers t,hosts h,items i,functions f,hosts_groups hg ' . $sql_from . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.value=' . TRIGGER_VALUE_TRUE . $sql_where . ' ORDER BY t.lastchange DESC'; $result = DBselect($sql, $limit); while ($row = DBfetch($result)) { // Check for dependencies if (trigger_dependent($row["triggerid"])) { continue; } $host = null; $menus = ''; $host_nodeid = id2nodeid($row['hostid']); foreach ($scripts_by_hosts[$row['hostid']] as $id => $script) { $script_nodeid = id2nodeid($script['scriptid']); if (bccomp($host_nodeid, $script_nodeid) == 0) { $menus .= "['" . $script['name'] . "',\"javascript: openWinCentered('scripts_exec.php?execute=1&hostid=" . $row['hostid'] . "&scriptid=" . $script['scriptid'] . "','" . S_TOOLS . "',760,540,'titlebar=no, resizable=yes, scrollbars=yes, dialog=no');\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; } } $menus .= "[" . zbx_jsvalue(S_LINKS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}],"; $menus .= "['" . S_LATEST_DATA . "',\"javascript: redirect('latest.php?groupid=0&hostid=" . $row['hostid'] . "')\", null,{'outer' : ['pum_o_item'],'inner' : ['pum_i_item']}],"; $menus = rtrim($menus, ','); $menus = "show_popup_menu(event,[[" . zbx_jsvalue(S_TOOLS) . ",null,null,{'outer' : ['pum_oheader'],'inner' : ['pum_iheader']}]," . $menus . "],180);"; $host = new CSpan($row['host'], 'link'); $host->setAttribute('onclick', 'javascript: ' . $menus); $host->setAttribute('onmouseover', "javascript: this.style.cursor = 'pointer';"); $event_sql = 'SELECT DISTINCT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type, t.url ' . ' FROM events e, triggers t ' . ' WHERE e.object=' . EVENT_SOURCE_TRIGGERS . ' AND e.objectid=' . $row['triggerid'] . ' AND t.triggerid=e.objectid ' . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC'; $res_events = DBSelect($event_sql, 1); while ($row_event = DBfetch($res_events)) { $ack = NULL; if ($config['event_ack_enable']) { if ($row_event['acknowledged'] == 1) { $ack_info = make_acktab_by_eventid($row_event['eventid']); $ack_info->setAttribute('style', 'width: auto;'); $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_event['eventid'], 'action'); $ack->setHint($ack_info); } else { $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_event['eventid'], 'on'); } } // $description = expand_trigger_description($row['triggerid']); $description = expand_trigger_description_by_data(array_merge($row, array('clock' => $row_event['clock'])), ZBX_FLAG_EVENT); //actions $actions = get_event_actions_stat_hints($row_event['eventid']); $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'events.php?triggerid=' . $row['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $row_event['clock'], 'action'); if ($row_event['url']) { $description = new CLink($description, $row_event['url'], 'action', null, true); } else { $description = new CSpan($description, 'pointer'); } $description = new CCol($description, get_severity_style($row["priority"])); $description->setHint(make_popup_eventlist($row_event['eventid'], $row['type'])); $table->addRow(array(get_node_name_by_elid($row['triggerid']), $host, $description, $clock, zbx_date2age($row_event['clock']), $ack, $actions)); } unset($row, $description, $actions, $alerts, $hint); } $table->setFooter(new CCol(S_UPDATED . ': ' . date("H:i:s", time()))); return $table; }
$last_page['url'] = 'tr_status.php?hostid=' . get_profile('web.tr_status.hostid', 0); } redirect($last_page['url']); exit; } else { if (isset($_REQUEST['cancel'])) { $last_page = get_last_history_page(); if (!$last_page) { $last_page['url'] = 'tr_status.php?hostid=' . get_profile('web.tr_status.hostid', 0); } redirect($last_page['url']); exit; } } } $msg = $bulk ? ' BULK ACKNOWLEDGE ' : array('"' . expand_trigger_description_by_data($db_data) . '"', BR(), explode_exp($db_data["expression"], 1)); show_table_header(array(S_ALARM_ACKNOWLEDGES_BIG, ' : ', $msg)); echo SBR; if (!$bulk) { $table = new CTable(NULL, "ack_msgs"); $table->SetAlign("center"); $db_acks = get_acknowledges_by_eventid($db_data["eventid"]); while ($db_ack = DBfetch($db_acks)) { $db_user = get_user_by_userid($db_ack["userid"]); $table->AddRow(array(new CCol($db_user["alias"], "user"), new CCol(date("d-m-Y h:i:s A", $db_ack["clock"]), "time")), "title"); $msgCol = new CCol(zbx_nl2br($db_ack['message'])); $msgCol->SetColspan(2); $table->AddRow($msgCol, "msg"); } /**/ if ($table->GetNumRows() > 0) {
protected function calcTriggers() { $this->triggers = array(); if ($this->m_showTriggers != 1) { return; } $max = 3; $cnt = 0; foreach ($this->items as $inum => $item) { $sql = 'SELECT DISTINCT h.host, tr.description, tr.triggerid, tr.expression, tr.priority, tr.value ' . ' FROM triggers tr,functions f,items i, hosts h ' . ' WHERE tr.triggerid=f.triggerid ' . " AND f.function IN ('last','min','avg','max') " . ' AND tr.status=' . TRIGGER_STATUS_ENABLED . ' AND i.itemid=f.itemid ' . ' AND h.hostid=i.hostid ' . ' AND f.itemid=' . $item['itemid'] . ' ORDER BY tr.priority'; $db_triggers = DBselect($sql); while (($trigger = DBfetch($db_triggers)) && $cnt < $max) { $db_fnc_cnt = DBselect('SELECT count(*) as cnt FROM functions f WHERE f.triggerid=' . $trigger['triggerid']); $fnc_cnt = DBfetch($db_fnc_cnt); if ($fnc_cnt['cnt'] != 1) { continue; } CUserMacro::resolveTrigger($trigger); if (!preg_match('/\\{([0-9]{1,})\\}([\\<\\>\\=]{1})([0-9\\.]{1,})([K|M|G]{0,1})/i', $trigger['expression'], $arr)) { continue; } $val = $arr[3]; if (strcasecmp($arr[4], 'K') == 0) { $val *= 1024; } else { if (strcasecmp($arr[4], 'M') == 0) { $val *= 1048576; } else { if (strcasecmp($arr[4], 'G') == 0) { $val *= 1073741824; } } } //1024*1024*1024; $minY = $this->m_minY[$this->items[$inum]['axisside']]; $maxY = $this->m_maxY[$this->items[$inum]['axisside']]; switch ($trigger['priority']) { case TRIGGER_SEVERITY_DISASTER: $color = 'Priority Disaster'; break; case TRIGGER_SEVERITY_HIGH: $color = 'Priority High'; break; case TRIGGER_SEVERITY_AVERAGE: $color = 'Priority Average'; break; case TRIGGER_SEVERITY_WARNING: $color = 'Priority Warning'; break; case TRIGGER_SEVERITY_INFORMATION: $color = 'Priority Information'; break; default: $color = 'Priority'; } array_push($this->triggers, array('skipdraw' => $val <= $minY || $val >= $maxY, 'y' => $this->sizeY - ($val - $minY) / ($maxY - $minY) * $this->sizeY + $this->shiftY, 'color' => $color, 'description' => S_TRIGGER . ': ' . expand_trigger_description_by_data($trigger), 'constant' => '[' . $arr[2] . ' ' . $arr[3] . $arr[4] . ']')); ++$cnt; } } }
function expand_trigger_description_simple($triggerid) { $sql = 'SELECT DISTINCT h.host,t.description,t.expression,t.triggerid ' . ' FROM triggers t, functions f, items i, hosts h ' . ' WHERE f.triggerid=t.triggerid ' . ' AND i.itemid=f.itemid ' . ' AND h.hostid=i.hostid ' . ' AND t.triggerid=' . $triggerid; $trigger = DBfetch(DBselect($sql)); return expand_trigger_description_by_data($trigger); }