function make_system_summary($args = array()) { global $USER_DETAILS; $config = select_config(); $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY); $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY); if (isset($args['hosts']) && !empty($args['hosts'])) { $available_hosts = zbx_uint_array_intersect($args['hosts'], $available_hosts); } if (isset($args['groups']) && !empty($args['groups'])) { $available_groups = zbx_uint_array_intersect($args['groups'], $available_groups); } $sql_where = ''; if (isset($args['severity']) && ctype_digit($args['severity'])) { $sql_where = ' AND t.priority>=' . $args['severity']; } $table = new CTableInfo(); $table->setHeader(array(is_show_subnodes() ? S_NODE : null, S_HOST_GROUP, S_DISASTER, S_HIGH, S_AVERAGE, S_WARNING, S_INFORMATION, S_NOT_CLASSIFIED)); $sql = 'SELECT DISTINCT g.groupid,g.name ' . ' FROM groups g, hosts_groups hg, hosts h, items i, functions f, triggers t ' . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' AND ' . DBcondition('g.groupid', $available_groups) . ' AND hg.groupid=g.groupid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' ORDER BY g.name'; $gr_result = DBselect($sql); while ($group = DBFetch($gr_result)) { $group_row = new CRow(); if (is_show_subnodes()) { $group_row->addItem(get_node_name_by_elid($group['groupid'])); } $name = new CLink($group['name'], 'tr_status.php?groupid=' . $group['groupid'] . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE); $name->setTarget('blank'); $group_row->addItem($name); $tab_priority[TRIGGER_SEVERITY_DISASTER] = 0; $tab_priority[TRIGGER_SEVERITY_HIGH] = 0; $tab_priority[TRIGGER_SEVERITY_AVERAGE] = 0; $tab_priority[TRIGGER_SEVERITY_WARNING] = 0; $tab_priority[TRIGGER_SEVERITY_INFORMATION] = 0; $tab_priority[TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0; $sql = 'SELECT count(DISTINCT t.triggerid) as tr_cnt,t.priority ' . ' FROM hosts h,items i,hosts_groups hg, functions f, triggers t ' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND hg.groupid=' . $group['groupid'] . ' AND hg.hostid=h.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.value=' . TRIGGER_VALUE_TRUE . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' GROUP BY t.priority'; //SDI($sql); $tr_result = DBSelect($sql); while ($group_stat = DBFetch($tr_result)) { $tab_priority[$group_stat['priority']] = $group_stat['tr_cnt']; } foreach ($tab_priority as $key => $value) { $tr_count = 0; if ($value) { //* trigger list $table_inf = new CTableInfo(); $table_inf->addOption('style', 'width: 400px;'); $table_inf->setHeader(array(is_show_subnodes() ? S_NODE : null, S_HOST, S_ISSUE, 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 ' . ' FROM triggers t,hosts h,items i,functions f, hosts_groups hg ' . ' WHERE f.itemid=i.itemid ' . ' AND hg.groupid=' . $group['groupid'] . ' 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 . ' AND t.priority=' . $key . ' ORDER BY t.lastchange DESC'; $result = DBselect($sql, 30); while ($row_inf = DBfetch($result)) { // Check for dependencies if (trigger_dependent($row_inf["triggerid"])) { continue; } $tr_count++; $host = new CSpan($row_inf['host']); $event_sql = 'SELECT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type ' . ' FROM events e, triggers t ' . ' WHERE e.object=' . EVENT_SOURCE_TRIGGERS . ' AND e.objectid=' . $row_inf['triggerid'] . ' AND t.triggerid=e.objectid ' . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC'; if ($row_inf_event = DBfetch(DBselect($event_sql, 1))) { if ($config['event_ack_enable']) { if ($row_inf_event['acknowledged'] == 1) { $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_inf_event['eventid'], 'action'); } else { $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_inf_event['eventid'], 'on'); } } $description = expand_trigger_description_by_data(array_merge($row_inf, array('clock' => $row_inf_event['clock'])), ZBX_FLAG_EVENT); //actions $actions = get_event_actions_status($row_inf_event['eventid']); //-------- } else { $description = expand_trigger_description_by_data($row_inf, ZBX_FLAG_EVENT); $ack = '-'; $actions = S_NO_DATA_SMALL; $row_inf_event['clock'] = $row_inf['clock']; } $table_inf->addRow(array(get_node_name_by_elid($row_inf['triggerid']), $host, new CCol($description, get_severity_style($row_inf['priority'])), zbx_date2age($row_inf_event['clock']), $config['event_ack_enable'] ? new CCol($ack, 'center') : NULL, $actions)); unset($row_inf, $description, $actions); } $value = new CSpan($tr_count); $value->setHint($table_inf); //-------------*/ } $group_row->AddItem(new CCol($value, get_severity_style($key, $tr_count))); unset($table_inf); } $table->addRow($group_row); } $table->setFooter(new CCol(S_UPDATED . ': ' . date("H:i:s", time()))); return $table; }
function get_actions_hint_by_eventid($eventid, $status = NULL) { $hostids = array(); $sql = 'SELECT DISTINCT i.hostid ' . ' FROM events e, functions f, items i ' . ' WHERE e.eventid=' . $eventid . ' AND e.objectid=' . EVENT_SOURCE_TRIGGERS . ' AND f.triggerid=' . $_REQUEST['triggerid'] . ' AND i.itemid=f.itemid'; if ($host = DBfetch(DBselect($sql, 1))) { $hostids[$host['hostid']] = $host['hostid']; } $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $hostids); $tab_hint = new CTableInfo(S_NO_ACTIONS_FOUND); $tab_hint->addOption('style', 'width: 300px;'); $tab_hint->SetHeader(array(is_show_subnodes() ? S_NODES : null, S_USER, S_DETAILS, S_STATUS)); /* $sql = 'SELECT DISTINCT a.alertid,mt.description,a.sendto,a.status,u.alias,a.retries '. ' FROM events e,users u,alerts a'. ' left join media_type mt on mt.mediatypeid=a.mediatypeid'. ' WHERE a.eventid='.$eventid. (is_null($status)?'':' AND a.status='.$status). ' AND e.eventid = a.eventid'. ' AND a.alerttype IN ('.ALERT_TYPE_MESSAGE.','.ALERT_TYPE_COMMAND.')'. ' AND '.DBcondition('e.objectid',$available_triggers). ' AND '.DBin_node('a.alertid'). ' AND u.userid=a.userid '. ' ORDER BY mt.description'; //*/ $sql = 'SELECT DISTINCT a.alertid,mt.description,u.alias,a.subject,a.message,a.sendto,a.status,a.retries,a.alerttype ' . ' FROM events e,alerts a ' . ' LEFT JOIN users u ON u.userid=a.userid ' . ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid' . ' WHERE a.eventid=' . $eventid . (is_null($status) ? '' : ' AND a.status=' . $status) . ' AND e.eventid = a.eventid' . ' AND a.alerttype IN (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . ' AND ' . DBcondition('e.objectid', $available_triggers) . ' AND ' . DBin_node('a.alertid') . ' ORDER BY a.alertid'; $result = DBselect($sql, 30); while ($row = DBfetch($result)) { if ($row["status"] == ALERT_STATUS_SENT) { $status = new CSpan(S_SENT, "green"); $retries = new CSpan(SPACE, "green"); } else { if ($row["status"] == ALERT_STATUS_NOT_SENT) { $status = new CSpan(S_IN_PROGRESS, "orange"); $retries = new CSpan(ALERT_MAX_RETRIES - $row["retries"], "orange"); } else { $status = new CSpan(S_NOT_SENT, "red"); $retries = new CSpan(0, "red"); } } switch ($row['alerttype']) { case ALERT_TYPE_MESSAGE: $message = empty($row['description']) ? '-' : $row['description']; break; case ALERT_TYPE_COMMAND: $message = array(bold(S_COMMAND . ':')); $msg = explode("\n", $row['message']); foreach ($msg as $m) { array_push($message, BR(), $m); } break; default: $message = '-'; } $tab_hint->addRow(array(get_node_name_by_elid($row['alertid']), empty($row['alias']) ? ' - ' : $row['alias'], $message, $status)); } return $tab_hint; }
function get_act_operations_form($action = null) { $tblOper = new CTableInfo(S_NO_OPERATIONS_DEFINED); $tblOper->addOption('style', 'background-color: #CCC;'); if (isset($_REQUEST['actionid']) && empty($action)) { $action = get_action_by_actionid($_REQUEST['actionid']); } $operations = get_request('operations', array()); if (isset($_REQUEST['actionid']) && !isset($_REQUEST['form_refresh'])) { $eventsource = $action['eventsource']; $evaltype = $action['evaltype']; $esc_period = $action['esc_period']; /* prepate operations */ $db_operations = DBselect('SELECT * ' . ' FROM operations' . ' WHERE actionid=' . $_REQUEST['actionid'] . ' ORDER BY esc_step_from,operationtype,object,operationid'); while ($operation_data = DBfetch($db_operations)) { $operation_data = array('operationtype' => $operation_data['operationtype'], 'operationid' => $operation_data['operationid'], 'object' => $operation_data['object'], 'objectid' => $operation_data['objectid'], 'shortdata' => $operation_data['shortdata'], 'longdata' => $operation_data['longdata'], 'esc_period' => $operation_data['esc_period'], 'esc_step_from' => $operation_data['esc_step_from'], 'esc_step_to' => $operation_data['esc_step_to'], 'default_msg' => $operation_data['default_msg'], 'evaltype' => $operation_data['evaltype']); $operation_data['opconditions'] = array(); $sql = 'SELECT * FROM opconditions WHERE operationid=' . $operation_data['operationid']; $db_opconds = DBselect($sql); while ($db_opcond = DBfetch($db_opconds)) { $operation_data['opconditions'][] = $db_opcond; } if (str_in_array($operation_data, $operations)) { continue; } array_push($operations, $operation_data); } unset($db_operations, $operation_data); } else { $eventsource = get_request('eventsource'); $evaltype = get_request('evaltype'); $esc_period = get_request('esc_period'); } $esc_step_from = array(); foreach ($operations as $key => $operation) { $esc_step_from[$key] = $operation['esc_step_from']; } array_multisort($esc_step_from, SORT_ASC, $operations); $tblOper->SetHeader(array(new CCheckBox('all_operations', null, 'CheckAll("' . S_ACTION . '","all_operations","g_operationid");'), isset($_REQUEST['escalation']) ? S_STEPS : null, S_DETAILS, isset($_REQUEST['escalation']) ? S_PERIOD . ' (' . S_SEC_SMALL . ')' : null, isset($_REQUEST['escalation']) ? S_DELAY : null, S_ACTION)); $allowed_operations = get_operations_by_eventsource($eventsource); zbx_rksort($operations); $delay = count_operations_delay($operations, $esc_period); foreach ($operations as $id => $val) { if (!str_in_array($val['operationtype'], $allowed_operations)) { continue; } if (!isset($val['default_msg'])) { $val['default_msg'] = 0; } if (!isset($val['opconditions'])) { $val['opconditions'] = array(); } $oper_details = new CSpan(get_operation_desc(SHORT_DESCRITION, $val)); $oper_details->SetHint(nl2br(get_operation_desc(LONG_DESCRITION, $val))); $esc_steps_txt = null; $esc_period_txt = null; $esc_delay_txt = null; if ($val['esc_step_from'] < 1) { $val['esc_step_from'] = 1; } if (isset($_REQUEST['escalation'])) { $esc_steps_txt = $val['esc_step_from'] . ' - ' . $val['esc_step_to']; $esc_period_txt = $val['esc_period'] ? $val['esc_period'] : S_DEFAULT; $esc_delay_txt = $delay[$val['esc_step_from']] ? convert_units($delay[$val['esc_step_from']], 'uptime') : S_AT_MOMENT; } $tblOper->addRow(array(new CCheckBox("g_operationid[]", 'no', null, $id), $esc_steps_txt, $oper_details, $esc_period_txt, $esc_delay_txt, new CButton('edit_operationid[' . $id . ']', S_EDIT))); $tblOper->addItem(new CVar('operations[' . $id . '][operationtype]', $val['operationtype'])); $tblOper->addItem(new CVar('operations[' . $id . '][object]', $val['object'])); $tblOper->addItem(new CVar('operations[' . $id . '][objectid]', $val['objectid'])); $tblOper->addItem(new CVar('operations[' . $id . '][shortdata]', $val['shortdata'])); $tblOper->addItem(new CVar('operations[' . $id . '][longdata]', $val['longdata'])); $tblOper->addItem(new CVar('operations[' . $id . '][esc_period]', $val['esc_period'])); $tblOper->addItem(new CVar('operations[' . $id . '][esc_step_from]', $val['esc_step_from'])); $tblOper->addItem(new CVar('operations[' . $id . '][esc_step_to]', $val['esc_step_to'])); $tblOper->addItem(new CVar('operations[' . $id . '][default_msg]', $val['default_msg'])); $tblOper->addItem(new CVar('operations[' . $id . '][evaltype]', $val['evaltype'])); foreach ($val['opconditions'] as $opcondid => $opcond) { foreach ($opcond as $field => $value) { $tblOper->addItem(new CVar('operations[' . $id . '][opconditions][' . $opcondid . '][' . $field . ']', $value)); } } } unset($operations); $tblOperFooter = new CTableInfo(null); $oper_buttons = array(); if (!isset($_REQUEST['new_operation'])) { $oper_buttons[] = new CButton('new_operation', S_NEW); } if ($tblOper->ItemsCount() > 0) { $oper_buttons[] = new CButton('del_operation', S_DELETE_SELECTED); } $td = new CCol($oper_buttons); $td->addOption('colspan', isset($_REQUEST['escalation']) ? 6 : 3); $td->addOption('style', 'text-align: right;'); $tblOperFooter->SetFooter($td); // end of condition list preparation return array($tblOper, $tblOperFooter); }
$frmLcls->addRow(S_STEP . SPACE . '3:', array(S_NEW_LOCALE_STEP_3_1, BR(), S_NEW_LOCALE_STEP_3_2)); $frmLcls->addRow(S_STEP . SPACE . '4:', array(S_NEW_LOCALE_STEP_4_1, BR(), S_NEW_LOCALE_STEP_4_2, BR(), S_NEW_LOCALE_STEP_4_3, BR(), S_NEW_LOCALE_STEP_4_4, BR(), S_NEW_LOCALE_STEP_4_5)); } else { $frmLcls->addRow(S_STEP . SPACE . '1:', 'Download newly created locale file by pressing "Download".'); $frmLcls->addRow(S_STEP . SPACE . '2:', 'Place it to "/PATH_TO_ZABBIX_FRONTEND/include/locales".'); $frmLcls->addRow(S_STEP . SPACE . '3:', 'Replace previous locale file with one you have downloaded.'); } $lang = serialize($_REQUEST['langTo']); $frmLcls->addVar('lang', $lang); $frmLcls->addItemToBottomRow(new CButton('download', S_DOWNLOAD, 'PopUp("locales")')); $frmLcls->Show(); } else { if (isset($_REQUEST['next'])) { $help = new CHelp('web.view.php', 'left'); $help_table = new CTableInfo(); $help_table->addOption('style', 'width: 600px;'); if ($_REQUEST['extlang'] == 'new') { define('S_NEW_LOCALE_STEP_1', 'Download newly created locale file by pressing "Download".'); define('S_NEW_LOCALE_STEP_2', 'Place it to "/PATH_TO_ZABBIX_FRONTEND/include/locales".'); define('S_NEW_LOCALE_STEP_3_1', 'The locale file name must be made of a prefix: "ISO 639-1 language code"-"ISO 3166-1 alpha-2 country code". Like "en-gb"'); define('S_NEW_LOCALE_STEP_3_2', 'and a postfix ".inc.php". Like "en-gb.inc.php".'); define('S_NEW_LOCALE_STEP_4_1', 'To make new locale visible by ZABBIX frontend - extend the php script "/PATH_TO_ZABBIX_FRONTEND/include/locales.inc.php".'); define('S_NEW_LOCALE_STEP_4_2', 'There You will find an array containing "keys" => "values".'); define('S_NEW_LOCALE_STEP_4_3', 'Extend this array with Your locale like "your_prefix" => "display_like".'); define('S_NEW_LOCALE_STEP_4_4', 'You can set "display_like" value in new locale file by adding it or You may leave it as hardcoded string.'); define('S_NEW_LOCALE_STEP_4_5', 'For example see implementation of other locales.'); $help_table->addRow(array(S_STEP . SPACE . '1:', S_NEW_LOCALE_STEP_1)); $help_table->addRow(array(S_STEP . SPACE . '2:', S_NEW_LOCALE_STEP_2)); $help_table->addRow(array(S_STEP . SPACE . '3:', array(S_NEW_LOCALE_STEP_3_1, BR(), S_NEW_LOCALE_STEP_3_2))); $help_table->addRow(array(S_STEP . SPACE . '4:', array(S_NEW_LOCALE_STEP_4_1, BR(), S_NEW_LOCALE_STEP_4_2, BR(), S_NEW_LOCALE_STEP_4_3, BR(), S_NEW_LOCALE_STEP_4_4, BR(), S_NEW_LOCALE_STEP_4_5))); } else {
$discovery_info[$dhost['ip']]['services'][$service_name] = array('class' => $class, 'time' => $dservice[$time]); } } if ($druleid == 0 && !empty($discovery_info)) { $col = new CCol(array(bold($drule['name']), SPACE . "(" . count($discovery_info) . SPACE . S_ITEMS . ")")); $col->SetColSpan(count($services) + 2); $table->AddRow(array(get_node_name_by_elid($drule['druleid']), $col)); } foreach ($discovery_info as $ip => $h_data) { $table_row = array(get_node_name_by_elid($h_data['druleid']), new CSpan($ip, $h_data['class']), new CSpan($h_data['time'] == 0 ? '' : convert_units(time() - $h_data['time'], 'uptime'), $h_data['class'])); foreach ($services as $name => $foo) { $class = null; $time = SPACE; $hint = new CDiv(SPACE, $class); $hintTable = new CTableInfo(); $hintTable->addOption('border', 0); if (isset($h_data['services'][$name])) { $class = $h_data['services'][$name]['class']; $time = $h_data['services'][$name]['time']; if ($class == 'active') { $hintTable->setHeader(S_UP_TIME); } else { if ($class == 'inactive') { $hintTable->setHeader(S_DOWN_TIME); } } $timeColumn = new CCol(zbx_date2age($h_data['services'][$name]['time']), $class); $hintTable->addRow($timeColumn); $hint->setHint($hintTable); } $table_row[] = new CCol($hint, $class);
validate_group($PAGE_GROUPS, $PAGE_HOSTS); $form = new CForm(); $form->setMethod('get'); $available_groups = $PAGE_GROUPS['groupids']; $cmbGroups = new CComboBox('groupid', $PAGE_GROUPS['selected'], 'javascript: submit();'); foreach ($PAGE_GROUPS['groups'] as $groupid => $name) { $cmbGroups->addItem($groupid, get_node_name_by_elid($groupid) . $name); } $form->addItem(array(S_GROUP . SPACE, $cmbGroups, SPACE)); $cmbType = new CComboBox('type', $_REQUEST['type'], 'submit()'); $cmbType->addItem(SHOW_TRIGGERS, S_TRIGGERS); $cmbType->addItem(SHOW_DATA, S_DATA); $form->addItem(array(S_TYPE . SPACE, $cmbType)); $help = new CHelp('web.view.php', 'right'); $help_table = new CTableInfo(); $help_table->addOption('style', 'width: 200px'); if ($_REQUEST['type'] == SHOW_TRIGGERS) { $help_table->addRow(array(new CCol(SPACE, 'normal'), S_DISABLED)); } foreach (array(1, 2, 3, 4, 5) as $tr_severity) { $help_table->addRow(array(new CCol(get_severity_description($tr_severity), get_severity_style($tr_severity)), S_ENABLED)); } $help_table->addRow(array(new CCol(SPACE, 'unknown_trigger'), S_UNKNOWN)); if ($_REQUEST['type'] == SHOW_TRIGGERS) { $col = new CCol(SPACE, 'unknown_trigger'); $col->addOption('style', 'background-image: url(images/gradients/blink1.gif); ' . 'background-position: top left; background-repeat: repeate;'); $help_table->addRow(array($col, S_5_MIN)); $col = new CCol(SPACE, 'unknown_trigger'); $col->addOption('style', 'background-image: url(images/gradients/blink2.gif); ' . 'background-position: top left; background-repeat: repeate;'); $help_table->addRow(array($col, S_15_MIN)); $help_table->addRow(array(new CCol(SPACE), S_NO_TRIGGER));
$sql_dep = 'SELECT * FROM trigger_depends WHERE triggerid_down=' . $row['triggerid']; $dep_res = DBselect($sql_dep); while ($dep_row = DBfetch($dep_res)) { $dep_table->addRow(SPACE . '-' . SPACE . expand_trigger_description($dep_row['triggerid_up'])); $dependency = true; } if ($dependency) { $img = new Cimg('images/general/down_icon.png', 'DEP_DOWN'); $img->addOption('style', 'vertical-align: middle; border: 0px;'); $img->SetHint($dep_table); $description = array($img, SPACE, $description); } unset($img, $dep_table, $dependency); $dependency = false; $dep_table = new CTableInfo(); $dep_table->addOption('style', 'width: 200px;'); $dep_table->addRow(bold(S_DEPENDENT . ':')); $sql_dep = 'SELECT * FROM trigger_depends WHERE triggerid_up=' . $row['triggerid']; $dep_res = DBselect($sql_dep); while ($dep_row = DBfetch($dep_res)) { $dep_table->addRow(SPACE . '-' . SPACE . expand_trigger_description($dep_row['triggerid_down'])); $dependency = true; } if ($dependency) { $img = new Cimg('images/general/up_icon.png', 'DEP_UP'); $img->addOption('style', 'vertical-align: middle; border: 0px;'); $img->SetHint($dep_table); $description = array($img, SPACE, $description); } unset($img, $dep_table, $dependency); //------------------------