/** * 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); }
$expandLink = new CLink(new CImg('images/general/minus.png'), '?close=1' . url_param('groupid') . url_param('hostid')); } else { $expandLink = new CLink(new CImg('images/general/plus.png'), '?open=1' . url_param('groupid') . url_param('hostid')); } $httpTable = new CTableInfo(_('No web scenarios defined.')); $httpTable->setHeader(array(new CCheckBox('all_httptests', null, "checkAll('" . $httpForm->getName() . "', 'all_httptests', 'group_httptestid');"), is_show_all_nodes() ? make_sorting_header(_('Node'), 'h.hostid') : null, $_REQUEST['hostid'] == 0 ? make_sorting_header(_('Host'), 'host') : null, make_sorting_header(array($expandLink, SPACE, _('Name')), 'name'), _('Number of steps'), _('Update interval'), make_sorting_header(_('Status'), 'status'))); $httpTableRows = array(); foreach ($this->data['db_httptests'] as $httptestid => $httptest_data) { $db_app = $this->data['db_apps'][$httptest_data['applicationid']]; if (!isset($httpTableRows[$db_app['applicationid']])) { $httpTableRows[$db_app['applicationid']] = array(); } if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($this->data['showAllApps'])) { continue; } $httpTableRows[$db_app['applicationid']][] = array(new CCheckBox('group_httptestid[' . $httptest_data['httptestid'] . ']', null, null, $httptest_data['httptestid']), is_show_all_nodes() ? SPACE : null, $_REQUEST['hostid'] > 0 ? null : $db_app['hostname'], new CLink($httptest_data['name'], '?form=update' . '&httptestid=' . $httptest_data['httptestid'] . '&hostid=' . $db_app['hostid'] . url_param('groupid')), $httptest_data['step_count'], $httptest_data['delay'], new CCol(new CLink(httptest_status2str($httptest_data['status']), '?group_httptestid[]=' . $httptest_data['httptestid'] . '&go=' . ($httptest_data['status'] ? 'activate' : 'disable'), httptest_status2style($httptest_data['status'])))); } foreach ($httpTableRows as $appid => $app_rows) { $db_app = $this->data['db_apps'][$appid]; if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($this->data['showAllApps'])) { $link = new CLink(new CImg('images/general/minus.png'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select')); } else { $link = new CLink(new CImg('images/general/plus.png'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select')); } $column = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . _n('%1$d scenario', '%1$d scenarios', $db_app['scenarios_cnt']) . ')')); $column->setColSpan(6); $httpTable->addRow(array(get_node_name_by_elid($db_app['applicationid']), $column)); foreach ($app_rows as $row) { $httpTable->addRow($row); } }
function make_latest_data() { global $USER_DETAILS; $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY); while ($db_app = DBfetch($db_applications)) { $db_items = DBselect('SELECT DISTINCT i.* ' . ' FROM items i,items_applications ia' . ' WHERE ia.applicationid=' . $db_app['applicationid'] . ' AND i.itemid=ia.itemid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . order_by('i.description,i.itemid,i.lastclock')); $app_rows = array(); $item_cnt = 0; while ($db_item = DBfetch($db_items)) { $description = item_description($db_item); if (!zbx_empty($_REQUEST['select']) && !zbx_stristr($description, $_REQUEST['select'])) { continue; } ++$item_cnt; if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) { continue; } if (isset($db_item['lastclock'])) { $lastclock = date(S_DATE_FORMAT_YMDHMS, $db_item['lastclock']); } else { $lastclock = new CCol('-', 'center'); } $lastvalue = format_lastvalue($db_item); if (isset($db_item['lastvalue']) && isset($db_item['prevvalue']) && $db_item['value_type'] == 0 && $db_item['lastvalue'] - $db_item['prevvalue'] != 0) { if ($db_item['lastvalue'] - $db_item['prevvalue'] < 0) { $change = convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']); } else { $change = '+' . convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']); } $change = nbsp($change); } else { $change = new CCol('-', 'center'); } if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) { $actions = new CLink(S_GRAPH, 'history.php?action=showgraph&itemid=' . $db_item['itemid'], 'action'); } else { $actions = new CLink(S_HISTORY, 'history.php?action=showvalues&period=3600&itemid=' . $db_item['itemid'], 'action'); } array_push($app_rows, new CRow(array(is_show_all_nodes() ? SPACE : null, $_REQUEST['hostid'] > 0 ? NULL : SPACE, str_repeat(SPACE, 6) . $description, $lastclock, new CCol($lastvalue, $lastvalue == '-' ? 'center' : null), $change, $actions))); } if ($item_cnt > 0) { if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) { $link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select')); } else { $link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select')); } $col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $item_cnt . SPACE . S_ITEMS . ')')); $col->setColSpan(5); $table->ShowRow(array(get_node_name_by_elid($db_app['hostid']), $_REQUEST['hostid'] > 0 ? NULL : $db_app['host'], $col)); $any_app_exist = true; foreach ($app_rows as $row) { $table->ShowRow($row); } } } }
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; }
$ack = new CLink(S_YES, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file']); } else { $ack = new CLink(S_NO, 'acknow.php?eventid=' . $event['eventid'] . '&backurl=' . $page['file'], 'on'); } } $description = expand_trigger_description_by_data(zbx_array_merge($trigger, array('clock' => $event['clock'])), ZBX_FLAG_EVENT); $tr_desc = new CSpan($description, 'pointer'); $tr_desc->addAction('onclick', "create_mon_trigger_menu(event, " . " new Array({'triggerid': '" . $trigger['triggerid'] . "', 'lastchange': '" . $event['clock'] . "'})," . zbx_jsvalue($items, true) . ");"); // Duration $tr_event = $event + $trigger; if ($next_event = get_next_event($tr_event, $events, $_REQUEST['hide_unknown'])) { $event['duration'] = zbx_date2age($tr_event['clock'], $next_event['clock']); } else { $event['duration'] = zbx_date2age($tr_event['clock']); } $table->addRow(array(new CLink(zbx_date2str(S_EVENTS_ACTION_TIME_FORMAT, $event['clock']), 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid'], 'action'), is_show_all_nodes() ? get_node_name_by_elid($event['objectid']) : null, $_REQUEST['hostid'] == 0 ? $host['host'] : null, new CSpan($tr_desc, 'link_menu'), new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value'])), new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'], $event['value'])), $event['duration'], $config['event_ack_enable'] ? $ack : NULL, $actions)); } } $table = array($paging, $table, $paging); $jsmenu = new CPUMenu(null, 170); $jsmenu->InsertJavaScript(); } $events_wdgt->addItem($table); // NAV BAR $timeline = array('period' => $effectiveperiod, 'starttime' => date('YmdHis', $starttime), 'usertime' => date('YmdHis', $till)); $dom_graph_id = 'scroll_events_id'; $objData = array('id' => 'timeline_1', 'loadSBox' => 0, 'loadImage' => 0, 'loadScroll' => 1, 'dynamic' => 0, 'mainObject' => 1); zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');'); zbx_add_post_js('timeControl.processObjects();'); $events_wdgt->show(); include_once 'include/page_footer.php';
$change = '+'; } // for 'unixtime' change should be calculated as uptime $change .= convert_units(bcsub($db_item['lastvalue'], $db_item['prevvalue'], $digits), $db_item['units'] == 'unixtime' ? 'uptime' : $db_item['units'], 0); $change = nbsp($change); } else { $change = ' - '; } // column "action" if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) { $actions = new CLink(_('Graph'), 'history.php?action=showgraph&itemid=' . $db_item['itemid']); } else { $actions = new CLink(_('History'), 'history.php?action=showvalues&itemid=' . $db_item['itemid']); } $item_status = $db_item['status'] == ITEM_STATUS_NOTSUPPORTED ? 'unknown' : null; array_push($app_rows, new CRow(array(SPACE, is_show_all_nodes() ? $db_host['item_cnt'] ? SPACE : get_node_name_by_elid($db_item['itemid']) : null, $_REQUEST['hostid'] ? null : SPACE, new CCol(SPACE . SPACE . $description, $item_status), new CCol($lastclock, $item_status), new CCol($lastvalue, $item_status), new CCol($change, $item_status), new CCol($actions, $item_status)))); } unset($app_rows); unset($db_host); foreach ($db_hosts as $hostid => $db_host) { $host = $hosts[$db_host['hostid']]; if (!isset($tab_rows[$hostid])) { continue; } $app_rows = $tab_rows[$hostid]; $tmp_apps = $apps; if (isset($apps[0])) { unset($tmp_apps[0]); $tmp_apps = array_values($tmp_apps); } if (isset($showAll)) {
$options['groupids'] = $_REQUEST['groupid']; } if ($_REQUEST['hostid'] > 0) { $options['hostids'] = $_REQUEST['hostid']; } } else { if ($_REQUEST['hostid'] > 0) { $hosts = CHost::get(array('templateids' => $_REQUEST['hostid'])); $options['hostids'] = zbx_objectValues($hosts, 'hostid'); } if (isset($_REQUEST['tpl_triggerid']) && $_REQUEST['tpl_triggerid'] > 0) { $options['filter']['templateid'] = $_REQUEST['tpl_triggerid']; } } $triggers = CTrigger::get($options); morder_result($triggers, array('host', 'description')); $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, $_REQUEST['hostid'] == 0 || 1 == $config ? S_HOST : NULL, S_NAME, S_PROBLEMS, S_OK, S_UNKNOWN, S_GRAPH)); foreach ($triggers as $trigger) { $availability = calculate_availability($trigger['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?filter_groupid=' . $_REQUEST['groupid'] . '&filter_hostid=' . $_REQUEST['hostid'] . '&triggerid=' . $trigger['triggerid']); $table->addRow(array(get_node_name_by_elid($trigger['hostid']), $_REQUEST['hostid'] == 0 || 1 == $config ? $trigger['host'] : NULL, new CLink($trigger['description'], 'events.php?triggerid=' . $trigger['triggerid']), $true, $false, $unknown, $actions)); } $rep2_wdgt->addItem($table); $rep2_wdgt->show(); } } include_once 'include/page_footer.php';
$hosts = API::Host()->get(array('templateids' => $_REQUEST['hostid'])); $options['hostids'] = zbx_objectValues($hosts, 'hostid'); } if (isset($_REQUEST['tpl_triggerid']) && $_REQUEST['tpl_triggerid'] > 0) { $options['filter']['templateid'] = $_REQUEST['tpl_triggerid']; } if (isset($_REQUEST['hostgroupid']) && $_REQUEST['hostgroupid'] > 0) { $options['groupids'] = $_REQUEST['hostgroupid']; } } // filter $filter = get_report2_filter($availabilityReportMode, $PAGE_GROUPS, $PAGE_HOSTS, $options); $rep2_wdgt->addFlicker($filter['form'], CProfile::get('web.avail_report.filter.state', 0)); $triggers = API::Trigger()->get($filter['options']); CArrayHelper::sort($triggers, array('host', 'description')); $table = new CTableInfo(_('No triggers defined.')); $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, $_REQUEST['hostid'] == 0 || $availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE ? _('Host') : null, _('Name'), _('Problems'), _('Ok'), _('Unknown'), _('Graph'))); foreach ($triggers as $trigger) { $availability = calculate_availability($trigger['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(_('Show'), 'report2.php?filter_groupid=' . $_REQUEST['groupid'] . '&filter_hostid=' . $_REQUEST['hostid'] . '&triggerid=' . $trigger['triggerid']); $table->addRow(array(get_node_name_by_elid($trigger['hostid']), $_REQUEST['hostid'] == 0 || $availabilityReportMode == AVAILABILITY_REPORT_BY_TEMPLATE ? $trigger['hosts'][0]['name'] : null, new CLink($trigger['description'], 'events.php?triggerid=' . $trigger['triggerid']), $true, $false, $unknown, $actions)); } $rep2_wdgt->addItem(BR()); $rep2_wdgt->addItem($table); $rep2_wdgt->show(); } } require_once dirname(__FILE__) . '/include/page_footer.php';
function make_vm_table($type, $instances) { $form_name = "{$type}_vms"; // Create Form $form = new CForm(); $form->setName($form_name); $form->setAttribute('id', $form_name); $form->addVar('driver', 'vsphere'); $form->setAction('#'); // Create Table Header $table = new CTableInfo(); switch ($type) { case 'poweron': $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, new CCheckBox('all_hosts', null, "checkAllHosts('" . $form_name . "','all_hosts','');"), _('Instance name'), _('Status'), _('CPU threads'), _('Memory(GB)'), _('Interface'), _('SSH Connect'))); break; case 'poweroff': case 'suspend': $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, new CCheckBox('all_hosts', null, "checkAllHosts('" . $form_name . "','all_hosts','');"), _('Instance name'), _('Status'), _('CPU threads'), _('Memory(GB)'), _('Interface'))); break; case 'other': $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, _('Instance name'), _('Status'), _('CPU thread'), _('Memory(GB)'), _('Interface'), _('Question'))); break; default: return null; } // Create Row foreach ($instances as $instance) { $table->addRow(make_hint_row($type, $instance)); } $hostids = array_map(function ($instance) { return $instance['hostid']; }, $instances); $footer = get_table_header(make_operation_box_footer($hostids, $form_name)); $form->addItem(array('', $table, '', $footer)); return $form; }
} /* * Page sorting */ validate_sort_and_sortorder('lastchange', ZBX_SORT_DOWN); /* * Play sound */ $mute = CProfile::get('web.tr_status.mute', 0); if (isset($audio) && !$mute) { play_sound($audio); } /* * Display */ $displayNodes = is_show_all_nodes() && $pageFilter->groupid == 0 && $pageFilter->hostid == 0; $showTriggers = $_REQUEST['show_triggers']; $showEvents = $_REQUEST['show_events']; $showSeverity = $_REQUEST['show_severity']; $ackStatus = $_REQUEST['ack_status']; $triggerWidget = new CWidget(); $rightForm = new CForm('get'); $rightForm->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB(true))); $rightForm->addItem(array(SPACE . _('Host') . SPACE, $pageFilter->getHostsCB(true))); $rightForm->addVar('fullscreen', $_REQUEST['fullscreen']); $triggerWidget->addPageHeader(_('STATUS OF TRIGGERS') . SPACE . '[' . zbx_date2str(_('d M Y H:i:s')) . ']', get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']))); $triggerWidget->addHeader(_('Triggers'), $rightForm); $triggerWidget->addHeaderRowNumber(); /* * Filter */
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { $sortfield = 'clock'; $sortorder = ZBX_SORT_DOWN; $sorttitle = _('Time'); switch ($this->screenitem['sort_triggers']) { case SCREEN_SORT_TRIGGERS_TIME_ASC: $sortfield = 'clock'; $sortorder = ZBX_SORT_UP; $sorttitle = _('Time'); break; case SCREEN_SORT_TRIGGERS_TIME_DESC: $sortfield = 'clock'; $sortorder = ZBX_SORT_DOWN; $sorttitle = _('Time'); break; case SCREEN_SORT_TRIGGERS_TYPE_ASC: $sortfield = 'description'; $sortorder = ZBX_SORT_UP; $sorttitle = _('Type'); break; case SCREEN_SORT_TRIGGERS_TYPE_DESC: $sortfield = 'description'; $sortorder = ZBX_SORT_DOWN; $sorttitle = _('Type'); break; case SCREEN_SORT_TRIGGERS_STATUS_ASC: $sortfield = 'status'; $sortorder = ZBX_SORT_UP; $sorttitle = _('Status'); break; case SCREEN_SORT_TRIGGERS_STATUS_DESC: $sortfield = 'status'; $sortorder = ZBX_SORT_DOWN; $sorttitle = _('Status'); break; case SCREEN_SORT_TRIGGERS_RETRIES_LEFT_ASC: $sortfield = 'retries'; $sortorder = ZBX_SORT_UP; $sorttitle = _('Retries left'); break; case SCREEN_SORT_TRIGGERS_RETRIES_LEFT_DESC: $sortfield = 'retries'; $sortorder = ZBX_SORT_DOWN; $sorttitle = _('Retries left'); break; case SCREEN_SORT_TRIGGERS_RECIPIENT_ASC: $sortfield = 'sendto'; $sortorder = ZBX_SORT_UP; $sorttitle = _('Recipient(s)'); break; case SCREEN_SORT_TRIGGERS_RECIPIENT_DESC: $sortfield = 'sendto'; $sortorder = ZBX_SORT_DOWN; $sorttitle = _('Recipient(s)'); break; } $sql = 'SELECT a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,a.status,a.retries,a.error' . ' FROM events e,alerts a' . ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid ' . ' WHERE e.eventid=a.eventid' . ' AND alerttype IN (' . ALERT_TYPE_MESSAGE . ')'; // editable + PERMISSION CHECK if (CWebUser::getType() != USER_TYPE_SUPER_ADMIN) { $userid = CWebUser::$data['userid']; $userGroups = getUserGroupsByUserId($userid); $sql .= ' AND EXISTS (' . 'SELECT NULL' . ' FROM functions f,items i,hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE e.objectid=f.triggerid' . ' AND f.itemid=i.itemid' . ' AND i.hostid=hgg.hostid' . ' GROUP BY f.triggerid' . ' HAVING MIN(r.permission)>=' . PERM_READ_ONLY . ')'; } $sql .= ' AND ' . DBin_node('a.alertid') . ' ' . ' ORDER BY ' . $sortfield . ' ' . $sortorder; $alerts = DBfetchArray(DBselect($sql, $this->screenitem['elements'])); order_result($alerts, $sortfield, $sortorder); // indicator of sort field $sortfieldSpan = new CSpan(array($sorttitle, SPACE)); $sortorderSpan = new CSpan(SPACE, $sortorder == ZBX_SORT_DOWN ? 'icon_sortdown default_cursor' : 'icon_sortup default_cursor'); // create alert table $actionTable = new CTableInfo(_('No actions found.')); $actionTable->setHeader(array(is_show_all_nodes() ? _('Nodes') : null, $sortfield == 'clock' ? array($sortfieldSpan, $sortorderSpan) : _('Time'), $sortfield == 'description' ? array($sortfieldSpan, $sortorderSpan) : _('Type'), $sortfield == 'status' ? array($sortfieldSpan, $sortorderSpan) : _('Status'), $sortfield == 'retries' ? array($sortfieldSpan, $sortorderSpan) : _('Retries left'), $sortfield == 'sendto' ? array($sortfieldSpan, $sortorderSpan) : _('Recipient(s)'), _('Message'), _('Error'))); foreach ($alerts as $alert) { if ($alert['status'] == ALERT_STATUS_SENT) { $status = new CSpan(_('sent'), 'green'); $retries = new CSpan(SPACE, 'green'); } elseif ($alert['status'] == ALERT_STATUS_NOT_SENT) { $status = new CSpan(_('In progress'), 'orange'); $retries = new CSpan(ALERT_MAX_RETRIES - $alert['retries'], 'orange'); } else { $status = new CSpan(_('not sent'), 'red'); $retries = new CSpan(0, 'red'); } $message = array(bold(_('Subject') . ': '), br(), $alert['subject'], br(), br(), bold(_('Message') . ': '), br(), $alert['message']); $error = empty($alert['error']) ? new CSpan(SPACE, 'off') : new CSpan($alert['error'], 'on'); $actionTable->addRow(array(get_node_name_by_elid($alert['alertid']), new CCol(zbx_date2str(HISTORY_OF_ACTIONS_DATE_FORMAT, $alert['clock']), 'top'), new CCol(!empty($alert['description']) ? $alert['description'] : '-', 'top'), new CCol($status, 'top'), new CCol($retries, 'top'), new CCol($alert['sendto'], 'top'), new CCol($message, 'top pre'), new CCol($error, 'wraptext top'))); } return $this->getOutput($actionTable); }
if ($db_item['lastvalue'] - $db_item['prevvalue'] < 0) { $change = convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']); $change = nbsp($change); } else { $change = '+' . convert_units($db_item['lastvalue'] - $db_item['prevvalue'], $db_item['units']); $change = nbsp($change); } } else { $change = new CCol(' - '); } if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) { $actions = new CLink(S_GRAPH, 'history.php?action=showgraph&itemid=' . $db_item['itemid'], 'action'); } else { $actions = new CLink(S_HISTORY, 'history.php?action=showvalues&period=3600&itemid=' . $db_item['itemid'], 'action'); } array_push($app_rows, new CRow(array(is_show_all_nodes() ? $db_host['item_cnt'] ? SPACE : get_node_name_by_elid($db_item['itemid']) : null, $_REQUEST['hostid'] ? NULL : ($db_host['item_cnt'] ? SPACE : $db_item['host']), str_repeat(SPACE, 6) . $description, $lastclock, new CCol($lastvalue), $change, $actions))); } unset($app_rows); unset($db_host); foreach ($db_hosts as $hostid => $db_host) { if (!isset($tab_rows[$hostid])) { continue; } $app_rows = $tab_rows[$hostid]; if (uint_in_array(0, $_REQUEST['applications']) || isset($show_all_apps)) { $url = '?close=1&applicationid=0' . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'); $link = new CLink(new CImg('images/general/opened.gif'), $url); // $link = new CLink(new CImg('images/general/opened.gif'),$url,null,"javascript: return updater.onetime_update('".ZBX_PAGE_MAIN_HAT."','".$url."');"); } else { $url = '?open=1&applicationid=0' . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'); $link = new CLink(new CImg('images/general/closed.gif'), $url);
function get_screen($screenid, $editmode, $effectiveperiod = NULL) { global $USER_DETAILS; if ($screenid == 0) { return new CTableInfo(S_NO_SCREENS_DEFINED); } $r = CScreen::get(array('screenids' => $screenid, 'editable' => $editmode == 1 ? 1 : null, 'output' => API_OUTPUT_SHORTEN)); if (empty($r)) { access_deny(); } if (is_null($effectiveperiod)) { $effectiveperiod = ZBX_MIN_PERIOD; } $result = DBselect('SELECT name,hsize,vsize FROM screens WHERE screenid=' . $screenid); $row = DBfetch($result); if (!$row) { return new CTableInfo(S_NO_SCREENS_DEFINED); } $sql = 'SELECT * FROM screens_items WHERE screenid=' . $screenid; $iresult = DBSelect($sql); $skip_field = array(); $irows = array(); while ($irow = DBfetch($iresult)) { $irows[] = $irow; for ($i = 0; $i < $irow['rowspan'] || $i == 0; $i++) { for ($j = 0; $j < $irow['colspan'] || $j == 0; $j++) { if ($i != 0 || $j != 0) { if (!isset($skip_field[$irow['y'] + $i])) { $skip_field[$irow['y'] + $i] = array(); } $skip_field[$irow['y'] + $i][$irow['x'] + $j] = 1; } } } } $table = new CTable(new CLink(S_NO_ROWS_IN_SCREEN . SPACE . $row['name'], 'screenconf.php?config=0&form=update&screenid=' . $screenid), $editmode == 0 || $editmode == 2 ? 'screen_view' : 'screen_edit'); $table->setAttribute('id', 'iframe'); if ($editmode == 1) { $new_cols = array(new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1))); for ($c = 0; $c < $row['hsize'] + 1; $c++) { $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer'); $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_col={$c}';"); array_push($new_cols, new Ccol($add_icon)); } $table->addRow($new_cols); } $empty_screen_col = array(); for ($r = 0; $r < $row['vsize']; $r++) { $new_cols = array(); $empty_screen_row = true; if ($editmode == 1) { $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer'); $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_row={$r}';"); array_push($new_cols, new Ccol($add_icon)); } for ($c = 0; $c < $row['hsize']; $c++) { $item = array(); if (isset($skip_field[$r][$c])) { continue; } $item_form = false; $irow = false; foreach ($irows as $tmprow) { if ($tmprow['x'] == $c && $tmprow['y'] == $r) { $irow = $tmprow; break; } } if ($irow) { $screenitemid = $irow['screenitemid']; $resourcetype = $irow['resourcetype']; $resourceid = $irow['resourceid']; $width = $irow['width']; $height = $irow['height']; $colspan = $irow['colspan']; $rowspan = $irow['rowspan']; $elements = $irow['elements']; $valign = $irow['valign']; $halign = $irow['halign']; $style = $irow['style']; $url = $irow['url']; $dynamic = $irow['dynamic']; } else { $screenitemid = 0; $resourcetype = 0; $resourceid = 0; $width = 0; $height = 0; $colspan = 0; $rowspan = 0; $elements = 0; $valign = VALIGN_DEFAULT; $halign = HALIGN_DEFAULT; $style = 0; $url = ''; $dynamic = 0; } if ($screenitemid > 0) { $empty_screen_row = false; $empty_screen_col[$c] = 1; } if ($editmode == 1 && $screenitemid != 0) { $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&screenitemid=' . $screenitemid . "#form');"; $action = 'screenedit.php?form=update' . url_param('screenid') . '&screenitemid=' . $screenitemid . '#form'; } else { if ($editmode == 1 && $screenitemid == 0) { $onclick_action = "ZBX_SCREENS['" . $_REQUEST['screenid'] . "'].screen.element_onclick('screenedit.php?form=update" . url_param('screenid') . '&x=' . $c . '&y=' . $r . "#form');"; $action = 'screenedit.php?form=update' . url_param('screenid') . '&x=' . $c . '&y=' . $r . '#form'; } else { $action = NULL; } } if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['x']) && $_REQUEST['x'] == $c && isset($_REQUEST['y']) && $_REQUEST['y'] == $r) { // click on empty field $item = get_screen_item_form(); $item_form = true; } else { if ($editmode == 1 && isset($_REQUEST['form']) && isset($_REQUEST['screenitemid']) && bccomp($_REQUEST['screenitemid'], $screenitemid) == 0) { // click on element $item = get_screen_item_form(); $item_form = true; } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_GRAPH) { if ($editmode == 0) { $action = 'charts.php?graphid=' . $resourceid . url_param('period') . url_param('stime'); } // GRAPH & ZOOM features $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid; $containerid = 'graph_cont_' . $screenitemid . '_' . $resourceid; $graphDims = getGraphDims($resourceid); $graphDims['graphHeight'] = $height; $graphDims['width'] = $width; $graph = get_graph_by_graphid($resourceid); $graphid = $graph['graphid']; $legend = $graph['show_legend']; $graph3d = $graph['show_3d']; //------------- // Host feature if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) { $options = array('hostids' => $_REQUEST['hostid'], 'output' => array('hostid', 'host')); $hosts = CHost::get($options); $host = reset($hosts); $options = array('graphids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'select_hosts' => API_OUTPUT_REFER, 'select_graph_items' => API_OUTPUT_EXTEND); $graph = CGraph::get($options); $graph = reset($graph); if (count($graph['hosts']) == 1) { // if items from one host we change them, or set calculated if not exist on that host if ($graph['ymax_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymax_itemid']) { $new_dinamic = get_same_graphitems_for_host(array(array('itemid' => $graph['ymax_itemid'])), $_REQUEST['hostid'], false); $new_dinamic = reset($new_dinamic); if (isset($new_dinamic['itemid']) && $new_dinamic['itemid'] > 0) { $graph['ymax_itemid'] = $new_dinamic['itemid']; } else { $graph['ymax_type'] = GRAPH_YAXIS_TYPE_CALCULATED; } } if ($graph['ymin_type'] == GRAPH_YAXIS_TYPE_ITEM_VALUE && $graph['ymin_itemid']) { $new_dinamic = get_same_graphitems_for_host(array(array('itemid' => $graph['ymin_itemid'])), $_REQUEST['hostid'], false); $new_dinamic = reset($new_dinamic); if (isset($new_dinamic['itemid']) && $new_dinamic['itemid'] > 0) { $graph['ymin_itemid'] = $new_dinamic['itemid']; } else { $graph['ymin_type'] = GRAPH_YAXIS_TYPE_CALCULATED; } } } $url = $graph['graphtype'] == GRAPH_TYPE_PIE || $graph['graphtype'] == GRAPH_TYPE_EXPLODED ? 'chart7.php' : 'chart3.php'; $url = new Curl($url); foreach ($graph as $name => $value) { if ($name == 'width' || $name == 'height') { continue; } $url->setArgument($name, $value); } $new_items = get_same_graphitems_for_host($graph['gitems'], $_REQUEST['hostid'], false); foreach ($new_items as $gitem) { unset($gitem['gitemid']); unset($gitem['graphid']); foreach ($gitem as $name => $value) { $url->setArgument('items[' . $gitem['itemid'] . '][' . $name . ']', $value); } } $url->setArgument('name', $host['host'] . ': ' . $graph['name']); $url = $url->getUrl(); } //------------- $objData = array('id' => $resourceid, 'domid' => $dom_graph_id, 'containerid' => $containerid, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'loadScroll' => 0, 'dynamic' => 0); $default = false; if ($graphDims['graphtype'] == GRAPH_TYPE_PIE || $graphDims['graphtype'] == GRAPH_TYPE_EXPLODED) { if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) { $url = 'chart6.php?graphid=' . $resourceid; $default = true; } $timeline = array(); $timeline['period'] = $effectiveperiod; $timeline['starttime'] = date('YmdHis', get_min_itemclock_by_graphid($resourceid)); if (isset($_REQUEST['stime'])) { $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']); } // $src = $url.'&width='.$width.'&height='.$height.'&legend='.$legend.'&graph3d='.$graph3d; $src = $url . '&width=' . $width . '&height=' . $height . '&legend=' . $legend . '&graph3d=' . $graph3d . '&period=' . $effectiveperiod . url_param('stime'); $objData['src'] = $src; } else { if ($dynamic == SCREEN_SIMPLE_ITEM || empty($url)) { $url = 'chart2.php?graphid=' . $resourceid; $default = true; } $src = $url . '&width=' . $width . '&height=' . $height . '&period=' . $effectiveperiod . url_param('stime'); $timeline = array(); if (isset($graphid) && !is_null($graphid) && $editmode != 1) { $timeline['period'] = $effectiveperiod; $timeline['starttime'] = date('YmdHis', time() - ZBX_MAX_PERIOD); //get_min_itemclock_by_graphid($graphid); if (isset($_REQUEST['stime'])) { $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']); } $objData['loadSBox'] = 1; } $objData['src'] = $src; } if ($editmode || !$default) { $item = new CDiv(); } else { $item = new CLink(null, $action); } $item->setAttribute('id', $containerid); $item = array($item); if ($editmode == 1) { $item[] = BR(); $item[] = new CLink(S_CHANGE, $action); } if ($editmode == 2) { insert_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');'); } else { zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');'); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH) { $dom_graph_id = 'graph_' . $screenitemid . '_' . $resourceid; $containerid = 'graph_cont_' . $screenitemid . '_' . $resourceid; $graphDims = getGraphDims(); $graphDims['graphHeight'] = $height; $graphDims['width'] = $width; $objData = array('id' => $resourceid, 'domid' => $dom_graph_id, 'containerid' => $containerid, 'objDims' => $graphDims, 'loadSBox' => 0, 'loadImage' => 1, 'loadScroll' => 0, 'dynamic' => 0); // Host feature if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) { if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) { $resourceid = $newitemid; } else { $resourceid = ''; } } //------------- if ($editmode == 0 && !empty($resourceid)) { $action = 'history.php?action=showgraph&itemid=' . $resourceid . url_param('period') . url_param('stime'); } $timeline = array(); $timeline['starttime'] = date('YmdHis', time() - ZBX_MAX_PERIOD); if (!zbx_empty($resourceid) && $editmode != 1) { $timeline['period'] = $effectiveperiod; if (isset($_REQUEST['stime'])) { $timeline['usertime'] = date('YmdHis', zbxDateToTime($_REQUEST['stime']) + $timeline['period']); } $objData['loadSBox'] = 1; } $src = zbx_empty($resourceid) ? 'chart3.php?' : 'chart.php?itemid=' . $resourceid . '&'; $src .= $url . 'width=' . $width . '&height=' . $height; $objData['src'] = $src; if ($editmode) { $item = new CDiv(); } else { $item = new CLink(null, $action); } $item->setAttribute('id', $containerid); $item = array($item); if ($editmode == 1) { $item[] = BR(); $item[] = new CLink(S_CHANGE, $action); } if ($editmode == 2) { insert_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');'); } else { zbx_add_post_js('timeControl.addObject("' . $dom_graph_id . '",' . zbx_jsvalue($timeline) . ',' . zbx_jsvalue($objData) . ');'); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_MAP) { $image_map = new CImg("map.php?noedit=1&sysmapid={$resourceid}" . "&width={$width}&height={$height}&curtime=" . time()); if ($editmode == 0) { $options = array('sysmapids' => $resourceid, 'output' => API_OUTPUT_EXTEND, 'select_selements' => API_OUTPUT_EXTEND, 'nopermissions' => 1); $sysmaps = CMap::get($options); $sysmap = reset($sysmaps); $action_map = getActionMapBySysmap($sysmap); $image_map->setMap($action_map->getName()); $item = array($action_map, $image_map); } else { $item = $image_map; // $item = new CLink($image_map, $action); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_PLAIN_TEXT) { // Host feature if ($dynamic == SCREEN_DYNAMIC_ITEM && isset($_REQUEST['hostid']) && $_REQUEST['hostid'] > 0) { if ($newitemid = get_same_item_for_host($resourceid, $_REQUEST['hostid'])) { $resourceid = $newitemid; } else { $resourceid = 0; } } //------------- $item = array(get_screen_plaintext($resourceid, $elements, $style)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTGROUP_TRIGGERS) { $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => $elements); $tr_form = S_ALL_S; if ($resourceid > 0) { $options = array('groupids' => $resourceid, 'output' => API_OUTPUT_EXTEND); $hostgroups = CHostgroup::get($options); $hostgroup = reset($hostgroups); $tr_form = new CSpan(S_GROUP . ': ' . $hostgroup['name'], 'white'); $params['groupids'] = $hostgroup['groupid']; } else { $groupid = get_request('tr_groupid', CProfile::get('web.screens.tr_groupid', 0)); $hostid = get_request('tr_hostid', CProfile::get('web.screens.tr_hostid', 0)); CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID); CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID); $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND); $groups = CHostGroup::get($options); order_result($groups, 'name'); $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND); if ($groupid > 0) { $options['groupids'] = $groupid; } $hosts = CHost::get($options); $hosts = zbx_toHash($hosts, 'hostid'); order_result($hosts, 'host'); if (!isset($hosts[$hostid])) { $hostid = 0; } $tr_form = new CForm(); $cmbGroup = new CComboBox('tr_groupid', $groupid, 'submit()'); $cmbHosts = new CComboBox('tr_hostid', $hostid, 'submit()'); $cmbGroup->addItem(0, S_ALL_SMALL); $cmbHosts->addItem(0, S_ALL_SMALL); foreach ($groups as $gnum => $group) { $cmbGroup->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']); } foreach ($hosts as $hnum => $host) { $cmbHosts->addItem($host['hostid'], get_node_name_by_elid($host['hostid'], null, ': ') . $host['host']); } $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup)); $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts)); if ($groupid > 0) { $params['groupids'] = $groupid; } if ($hostid > 0) { $params['hostids'] = $hostid; } } $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT)), $tr_form)); $item[] = make_latest_issues($params); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } ///----------------------- } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOST_TRIGGERS) { $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => $elements); $tr_form = S_ALL_S; if ($resourceid > 0) { $options = array('hostids' => $resourceid, 'output' => API_OUTPUT_EXTEND); $hosts = CHost::get($options); $host = reset($hosts); $tr_form = new CSpan(S_HOST . ': ' . $host['host'], 'white'); $params['hostids'] = $host['hostid']; } else { $groupid = get_request('tr_groupid', CProfile::get('web.screens.tr_groupid', 0)); $hostid = get_request('tr_hostid', CProfile::get('web.screens.tr_hostid', 0)); CProfile::update('web.screens.tr_groupid', $groupid, PROFILE_TYPE_ID); CProfile::update('web.screens.tr_hostid', $hostid, PROFILE_TYPE_ID); $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND); $groups = CHostGroup::get($options); order_result($groups, 'name'); $options = array('monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND); if ($groupid > 0) { $options['groupids'] = $groupid; } $hosts = CHost::get($options); $hosts = zbx_toHash($hosts, 'hostid'); order_result($hosts, 'host'); if (!isset($hosts[$hostid])) { $hostid = 0; } $tr_form = new CForm(); $cmbGroup = new CComboBox('tr_groupid', $groupid, 'submit()'); $cmbHosts = new CComboBox('tr_hostid', $hostid, 'submit()'); $cmbGroup->addItem(0, S_ALL_SMALL); $cmbHosts->addItem(0, S_ALL_SMALL); foreach ($groups as $gnum => $group) { $cmbGroup->addItem($group['groupid'], get_node_name_by_elid($group['groupid'], null, ': ') . $group['name']); } foreach ($hosts as $hnum => $host) { $cmbHosts->addItem($host['hostid'], get_node_name_by_elid($host['hostid'], null, ': ') . $host['host']); } $tr_form->addItem(array(S_GROUP . SPACE, $cmbGroup)); $tr_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts)); if ($groupid > 0) { $params['groupids'] = $groupid; } if ($hostid > 0) { $params['hostids'] = $hostid; } } ///----------------------- $item = array(get_table_header(array(S_STATUS_OF_TRIGGERS_BIG, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT)), $tr_form)); $item[] = make_latest_issues($params); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SYSTEM_STATUS) { $params = array('groupids' => null, 'hostids' => null, 'maintenance' => null, 'severity' => null, 'limit' => null, 'extAck' => 0); $item = array(get_table_header(array(S_SYSTEM_STATUS, SPACE, zbx_date2str(S_SCREENS_TRIGGER_FORM_DATE_FORMAT)))); $item[] = make_system_status($params); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_HOSTS_INFO) { $item = array(new CHostsInfo($resourceid, $style)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_INFO) { $item = new CTriggersInfo($resourceid, null, $style); $item = array($item); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SERVER_INFO) { // $item = array(get_table_header(S_STATUS_OF_ZABBIX_BIG),make_status_of_zbx()); $item = array(new CServerInfo()); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_CLOCK) { $item = new CFlashClock($width, $height, $style, $action); } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_SCREEN) { $item = array(get_screen($resourceid, 2, $effectiveperiod)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_TRIGGERS_OVERVIEW) { $hostids = array(); $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid); while ($tmp_host = DBfetch($res)) { $hostids[$tmp_host['hostid']] = $tmp_host['hostid']; } $item = array(get_triggers_overview($hostids, $style)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_DATA_OVERVIEW) { $hostids = array(); $res = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . $resourceid); while ($tmp_host = DBfetch($res)) { $hostids[$tmp_host['hostid']] = $tmp_host['hostid']; } $item = array(get_items_data_overview($hostids, $style)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_URL) { $item = array(new CIFrame($url, $width, $height, "auto")); if ($editmode == 1) { array_push($item, BR(), new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_ACTIONS) { $item = array(get_history_of_actions($elements)); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { if ($screenitemid != 0 && $resourcetype == SCREEN_RESOURCE_EVENTS) { $options = array('monitored' => 1, 'value' => array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE), 'limit' => $elements); $hide_unknown = CProfile::get('web.events.filter.hide_unknown', 0); if ($hide_unknown) { $options['value'] = array(TRIGGER_VALUE_TRUE, TRIGGER_VALUE_FALSE); } $item = new CTableInfo(S_NO_EVENTS_FOUND); $item->SetHeader(array(S_TIME, is_show_all_nodes() ? S_NODE : null, S_HOST, S_DESCRIPTION, S_VALUE, S_SEVERITY)); $events = getLastEvents($options); foreach ($events as $enum => $event) { $trigger = $event['trigger']; $host = $event['host']; $value = new CCol(trigger_value2str($event['value']), get_trigger_value_style($event['value'])); // $row = zbx_array_merge($triggers[$row['triggerid']],$row); // if((1 == $hide_unknown) && (!event_initial_time($row,$hide_unknown))) continue; $item->addRow(array(zbx_date2str(S_EVENTS_TRIGGERS_EVENTS_HISTORY_LIST_DATE_FORMAT, $event['clock']), get_node_name_by_elid($event['objectid']), $host['host'], new CLink($trigger['description'], 'tr_events.php?triggerid=' . $event['objectid'] . '&eventid=' . $event['eventid']), $value, new CCol(get_severity_description($trigger['priority']), get_severity_style($trigger['priority'])))); } $item = array($item); if ($editmode == 1) { array_push($item, new CLink(S_CHANGE, $action)); } } else { $item = array(SPACE); if ($editmode == 1) { array_push($item, BR(), new CLink(S_CHANGE, $action)); } } } } } } } } } } } } } } } } } } } } $str_halign = 'def'; if ($halign == HALIGN_CENTER) { $str_halign = 'cntr'; } if ($halign == HALIGN_LEFT) { $str_halign = 'left'; } if ($halign == HALIGN_RIGHT) { $str_halign = 'right'; } $str_valign = 'def'; if ($valign == VALIGN_MIDDLE) { $str_valign = 'mdl'; } if ($valign == VALIGN_TOP) { $str_valign = 'top'; } if ($valign == VALIGN_BOTTOM) { $str_valign = 'bttm'; } if ($editmode == 1 && !$item_form) { $item = new CDiv($item, 'draggable'); $item->setAttribute('id', 'position_' . $r . '_' . $c); if ($editmode == 1) { $item->setAttribute('onclick', 'javascript: ' . $onclick_action); } } $new_col = new CCol($item, $str_halign . '_' . $str_valign); if ($colspan) { $new_col->SetColSpan($colspan); } if ($rowspan) { $new_col->SetRowSpan($rowspan); } array_push($new_cols, $new_col); } if ($editmode == 1) { $rmv_icon = new Cimg('images/general/opened.gif', NULL, NULL, NULL, 'pointer'); if ($empty_screen_row) { $rmv_row_link = "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_row={$r}';"; } else { $rmv_row_link = "javascript: if(Confirm('" . S_THIS_SCREEN_ROW_NOT_EMPTY . '. ' . S_DELETE_IT_Q . "')){" . " location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_row={$r}';}"; } $rmv_icon->addAction('onclick', $rmv_row_link); array_push($new_cols, new Ccol($rmv_icon)); } $table->addRow(new CRow($new_cols)); } if ($editmode == 1) { $add_icon = new Cimg('images/general/closed.gif', NULL, NULL, NULL, 'pointer'); $add_icon->addAction('onclick', "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&add_row={$row['vsize']}';"); $new_cols = array(new Ccol($add_icon)); for ($c = 0; $c < $row['hsize']; $c++) { $rmv_icon = new Cimg('images/general/opened.gif', NULL, NULL, NULL, 'pointer'); if (isset($empty_screen_col[$c])) { $rmv_col_link = "javascript: if(Confirm('" . S_THIS_SCREEN_COLUMN_NOT_EMPTY . '. ' . S_DELETE_IT_Q . "')){" . " location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_col={$c}';}"; } else { $rmv_col_link = "javascript: location.href = 'screenedit.php?config=1&screenid={$screenid}&rmv_col={$c}';"; } $rmv_icon->addAction('onclick', $rmv_col_link); array_push($new_cols, new Ccol($rmv_icon)); } array_push($new_cols, new Ccol(new Cimg('images/general/zero.gif', 'zero', 1, 1))); $table->addRow($new_cols); } return $table; }
function make_awsstat_summary($preloading = false) { $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, _('Account name'), _('PoweredOn'), _('PoweredOff'), _('Billing/Month'))); $script_itemkey = 'push_message.py[{$HYCLOPS_SERVER},{$HYCLOPS_PORT},ec2,{HOST.HOST}]'; $aws_accounts = get_aws_accounts(); if (empty($aws_accounts)) { return null; } foreach ($aws_accounts as $host) { if (!$preloading) { if (is_script_success($host['hostid'], $script_itemkey)) { $instances = get_instances($host['hostid']); $instances = filter_instances($instances); $r = new CRow(); // Account name $col = new CCol($host['host']); $r->addItem($col); // Poweron (running + pending) $poweron_vms = array_merge($instances["running"], $instances["pending"]); $poweron_count = new CSpan(count($poweron_vms), 'pointer'); if (!empty($poweron_vms)) { $poweron_count->setHint(make_ec2_table('ec2_poweron', $poweron_vms)); } $r->addItem(new CCol($poweron_count)); // Poweroff (stopped + terminated + stopping + shutting-down) $poweroff_vms = $instances["stopped"]; $poweroff_count = new CSpan(count($poweroff_vms), 'pointer'); if (!empty($poweroff_vms)) { $poweroff_count->setHint(make_ec2_table('ec2_poweroff', $poweroff_vms)); } $r->addItem(new CCol($poweroff_count)); // AWS Charges $item = get_item_by_key('get_aws_charges.py[{$KEY},{$SECRET}]', $host["host"]); if (array_key_exists('lastvalue', $item)) { $r->addItem(new CLink($item["lastvalue"], "history.php?action=showgraph&itemid={$item["itemid"]}")); } else { $r->addItem(new CCol(_('No data'))); } $table->addRow($r); zbx_add_post_js('chkbxRange.pageGoName = "vms";'); } else { $r = new CRow(); $r->addItem($host['host']); $r->addItem(new CCol(_('script failed'), "high")); $r->addItem(array("-")); $table->addRow($r); } } else { $r = new CRow(); $r->addItem($host['host']); $r->addItem(new CCol(_('loading...'))); $r->addItem(array("-")); $table->addRow($r); } } $script = new CJSScript(get_js("jQuery('#hat_awsstat_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')")); return new CDiv(array($table, $script)); }
function make_discovery_status() { $options = array('filter' => array('status' => DHOST_STATUS_ACTIVE), 'selectDHosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND); $drules = CDRule::get($options); order_result($drules, 'name'); foreach ($drules as $drnum => $drule) { $drules[$drnum]['up'] = 0; $drules[$drnum]['down'] = 0; foreach ($drule['dhosts'] as $dhnum => $dhost) { if (DRULE_STATUS_DISABLED == $dhost['status']) { $drules[$drnum]['down']++; } else { $drules[$drnum]['up']++; } } } $header = array(is_show_all_nodes() ? new CCol(S_NODE, 'center') : null, new CCol(S_DISCOVERY_RULE, 'center'), new CCol(S_UP), new CCol(S_DOWN)); $table = new CTableInfo(); $table->setHeader($header, 'header'); foreach ($drules as $drnum => $drule) { $table->addRow(array(get_node_name_by_elid($drule['druleid']), new CLink(get_node_name_by_elid($drule['druleid'], null, ': ') . $drule['name'], 'discovery.php?druleid=' . $drule['druleid']), new CSpan($drule['up'], 'green'), new CSpan($drule['down'], $drule['down'] > 0 ? 'red' : 'green'))); } $table->setFooter(new CCol(S_UPDATED . ': ' . zbx_date2str(S_BLOCKS_DISCOVERY_STATUS_TIME_FORMAT))); return $table; }
$filterButton = new CButton('filter', _('Filter'), "javascript: create_var('zbx_filter', 'filter_set', '1', true);"); $filterButton->useJQueryStyle('main'); $resetButton = new CButton('filter_rst', _('Reset'), 'javascript: var uri = new Curl(location.href); uri.setArgument("filter_rst", 1); location.href = uri.getUrl();'); $resetButton->useJQueryStyle(); $buttonsDiv = new CDiv(array($filterButton, SPACE, $resetButton)); $buttonsDiv->setAttribute('style', 'padding: 4px 0px;'); $filterTable->addRow(new CCol($buttonsDiv, 'controls')); $filterForm->addItem($filterTable); $auditWidget->addFlicker($filterForm, CProfile::get('web.auditacts.filter.state', 1)); $auditWidget->addFlicker(new CDiv(null, null, 'scrollbar_cntr'), CProfile::get('web.auditacts.filter.state', 1)); // create form $auditForm = new CForm('get'); $auditForm->setName('auditForm'); // create table $auditTable = new CTableInfo(_('No actions defined.')); $auditTable->setHeader(array(is_show_all_nodes() ? _('Nodes') : null, _('Time'), _('Type'), _('Status'), _('Retries left'), _('Recipient(s)'), _('Message'), _('Error'))); foreach ($this->data['alerts'] as $alert) { $mediatype = array_pop($alert['mediatypes']); if ($mediatype['mediatypeid'] == 0) { $mediatype = array('description' => ''); } if ($alert['status'] == ALERT_STATUS_SENT) { if ($alert['alerttype'] == ALERT_TYPE_MESSAGE) { $status = new CSpan(_('sent'), 'green'); } else { $status = new CSpan(_('executed'), 'green'); } $retries = new CSpan(SPACE, 'green'); } elseif ($alert['status'] == ALERT_STATUS_NOT_SENT) { $status = new CSpan(_('In progress'), 'orange'); $retries = new CSpan(ALERT_MAX_RETRIES - $alert['retries'], 'orange');
check_fields($fields); $rprt_wdgt = new CWidget(); $_REQUEST['period'] = get_request('period', 'day'); $admin_links = CWebUser::$data['type'] == USER_TYPE_ZABBIX_ADMIN || CWebUser::$data['type'] == USER_TYPE_SUPER_ADMIN; $form = new CForm('get'); $cmbPeriod = new CComboBox('period', $_REQUEST['period'], 'submit()'); $cmbPeriod->addItem('day', _('Day')); $cmbPeriod->addItem('week', _('Week')); $cmbPeriod->addItem('month', _('Month')); $cmbPeriod->addItem('year', _('Year')); $form->addItem($cmbPeriod); $rprt_wdgt->addPageHeader(_('MOST BUSY TRIGGERS TOP 100')); $rprt_wdgt->addHeader(_('Report'), $form); $rprt_wdgt->addItem(BR()); $table = new CTableInfo(_('No triggers found.')); $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, _('Host'), _('Trigger'), _('Severity'), _('Number of status changes'))); switch ($_REQUEST['period']) { case 'week': $time_dif = SEC_PER_WEEK; break; case 'month': $time_dif = SEC_PER_MONTH; break; case 'year': $time_dif = SEC_PER_YEAR; break; case 'day': default: $time_dif = SEC_PER_DAY; break; }
$last_clock = !empty($clock) ? min($clock) : null; order_page_result($events, 'clock', ZBX_SORT_DOWN); foreach ($events as $num => $row) { // Actions $actions = get_event_actions_status($row['eventid']); //-------- if ($config['event_ack_enable']) { if ($row['acknowledged'] == 1) { $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($row['desc'], '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_all_nodes() ? get_node_name_by_elid($row['triggerid']) : null, $_REQUEST['hostid'] == 0 ? $row['host'] : null, $tr_desc, $row['value'], new CCol(get_severity_description($row['priority']), get_severity_style($row['priority'], $row['value'])), $row['duration'], $config['event_ack_enable'] ? $ack : NULL, $actions)); } } } // Navigation $next_clock = $last_clock; $navForm = new CForm('events.php'); $navForm->setMethod('get'); if (isset($_REQUEST['groupid'])) { $navForm->addVar('groupid', $_REQUEST['groupid']); } if (isset($_REQUEST['hostid'])) { $navForm->addVar('hostid', $_REQUEST['hostid']); } $navForm->addVar('fullscreen', $_REQUEST['fullscreen']); $navForm->addVar('prev_clock', $prev_clock);
** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ $discoveryWidget = new CWidget('hat_discovery'); // create header form $discoveryHeaderForm = new CForm('get'); $discoveryHeaderForm->setName('slideHeaderForm'); $discoveryHeaderForm->addVar('fullscreen', $this->data['fullscreen']); $discoveryWidget->addPageHeader(_('STATUS OF DISCOVERY'), get_icon('fullscreen', array('fullscreen' => $this->data['fullscreen']))); $discoveryRulesComboBox = $this->data['pageFilter']->getDiscoveryCB(); $discoveryHeaderForm->addItem(array(_('Discovery rule') . SPACE, $discoveryRulesComboBox)); $discoveryWidget->addHeader(_('Discovery rules'), $discoveryHeaderForm); // craete table $discoveryTable = new CTableInfo(_('No discovered devices found.')); $discoveryTable->makeVerticalRotation(); $header = array(is_show_all_nodes() ? new CCol(_('Node'), 'left') : null, make_sorting_header(_('Discovered device'), 'ip'), new CCol(_('Monitored host'), 'left'), new CCol(array(_('Uptime') . '/', _('Downtime')), 'left')); foreach ($this->data['services'] as $name => $foo) { $header[] = new CCol($name, 'vertical_rotation'); } $discoveryTable->setHeader($header, 'vertical_header'); foreach ($this->data['drules'] as $drule) { $discovery_info = array(); $dhosts = $drule['dhosts']; foreach ($dhosts as $dhost) { if ($dhost['status'] == DHOST_STATUS_DISABLED) { $hclass = 'disabled'; $htime = $dhost['lastdown']; } else { $hclass = 'enabled'; $htime = $dhost['lastup']; }
$filterForm->setAttribute('name', 'zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $row = new CRow(array(new CCol(S_RECIPIENT, 'form_row_l'), new CCol(array(new CTextBox('alias', $_REQUEST['alias'], 32), new CButton('btn1', S_SELECT, "return PopUp('popup.php?" . "dstfrm=" . $filterForm->getName() . "&dstfld1=alias&srctbl=users&srcfld1=alias&real_hosts=1');", 'T')), 'form_row_r'))); $filterForm->addRow($row); $reset = new CButton('filter_rst', S_RESET); $reset->setType('button'); $reset->setAction('javascript: var uri = new Curl(location.href); uri.setArgument("filter_rst",1); location.href = uri.getUrl();'); $filterForm->addItemToBottomRow(new CButton("filter_set", S_FILTER)); $filterForm->addItemToBottomRow($reset); $alerts_wdgt->addFlicker($filterForm, CProfile::get('web.auditacts.filter.state', 1)); $scroll_div = new CDiv(); $scroll_div->setAttribute('id', 'scrollbar_cntr'); $alerts_wdgt->addFlicker($scroll_div, CProfile::get('web.auditacts.filter.state', 1)); //------- $table = new CTableInfo(S_NO_ACTIONS_FOUND); $table->setHeader(array(is_show_all_nodes() ? S_NODES : null, S_TIME, S_TYPE, S_STATUS, S_RETRIES_LEFT, S_RECIPIENTS, S_MESSAGE, S_ERROR)); $effectiveperiod = navigation_bar_calc('web.auditacts.timeline', 0, true); $bstime = $_REQUEST['stime']; $from = zbxDateToTime($_REQUEST['stime']); $till = $from + $effectiveperiod; $options = array('time_from' => $from, 'time_till' => $till, 'output' => API_OUTPUT_EXTEND, 'select_mediatypes' => API_OUTPUT_EXTEND, 'sortfield' => 'alertid', 'sortorder' => ZBX_SORT_DOWN, 'limit' => $config['search_limit'] + 1); if ($_REQUEST['alias']) { $users = CUser::get(array('filter' => array('alias' => $_REQUEST['alias']))); $options['userids'] = zbx_objectValues($users, 'userid'); } $alerts = CAlert::get($options); // get first event for selected filters, to get starttime for timeline bar unset($options['userids']); unset($options['time_from']); unset($options['time_till']); unset($options['select_mediatypes']);
function get_actions_hint_by_eventid($eventid, $status = null) { $tab_hint = new CTableInfo(_('No actions found.')); $tab_hint->setAttribute('style', 'width: 300px;'); $tab_hint->setHeader(array(is_show_all_nodes() ? _('Nodes') : null, _('User'), _('Details'), _('Status'))); $sql = 'SELECT a.alertid,mt.description,u.alias,u.name,u.surname,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=' . zbx_dbstr($eventid) . (is_null($status) ? '' : ' AND a.status=' . $status) . ' AND e.eventid=a.eventid' . ' AND a.alerttype IN (' . ALERT_TYPE_MESSAGE . ',' . ALERT_TYPE_COMMAND . ')' . andDbNode('a.alertid') . ' ORDER BY a.alertid'; $result = DBselect($sql, 30); while ($row = DBfetch($result)) { if ($row['status'] == ALERT_STATUS_SENT) { $status = new CSpan(_('Sent'), 'green'); } elseif ($row['status'] == ALERT_STATUS_NOT_SENT) { $status = new CSpan(_('In progress'), 'orange'); } else { $status = new CSpan(_('not sent'), 'red'); } switch ($row['alerttype']) { case ALERT_TYPE_MESSAGE: $message = empty($row['description']) ? '-' : $row['description']; break; case ALERT_TYPE_COMMAND: $message = array(bold(_('Command') . NAME_DELIMITER)); $msg = explode("\n", $row['message']); foreach ($msg as $m) { array_push($message, BR(), $m); } break; default: $message = '-'; } if (!$row['alias']) { $row['alias'] = ' - '; } else { $fullname = ''; if ($row['name']) { $fullname = $row['name']; } if ($row['surname']) { $fullname .= $fullname ? ' ' . $row['surname'] : $row['surname']; } if ($fullname) { $row['alias'] .= ' (' . $fullname . ')'; } } $tab_hint->addRow(array(get_node_name_by_elid($row['alertid']), $row['alias'], $message, $status)); } return $tab_hint; }
// $filterForm = get_report2_filter($config, $PAGE_GROUPS, $PAGE_HOSTS); $rep2_wdgt->addFlicker($filter_form, true); if (isset($hostid)) { $sql_from = ''; $sql_where = ''; if (0 == $config) { if ($_REQUEST['groupid'] > 0) { $sql_from .= ',hosts_groups hg '; $sql_where .= ' AND hg.hostid=h.hostid AND hg.groupid=' . $_REQUEST['groupid']; } if ($_REQUEST['hostid'] > 0) { $sql_where .= ' AND h.hostid=' . $hostid; } } else { if ($hostid > 0) { $sql_from .= ',hosts_templates ht '; $sql_where .= ' AND ht.hostid=h.hostid AND ht.templateid=' . $hostid; } } $sql = 'select hos.host, ite.name, ite.itemid, hos.hostid, ite.error, ite.flags ' . ' from items ite ' . ' inner join hosts hos ' . ' on (hos.hostid = ite.hostid) and ' . $filtroSegHosts . ' where ite.state = 1 and ite.status = 0 ' . (count($hostids) > 0 ? ' and ' . dbConditionInt('hos.hostid', $hostids) : '') . ' order by hos.host, ite.name'; // var_dump($sql); $result = DBselect($sql); $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, $hostid == 0 || 1 == $config ? _('Host') : NULL, _('Name'), _('Error'))); while ($row = DBfetch($result)) { $table->addRow(array(get_node_name_by_elid($row['hostid']), $hostid == 0 || 1 == $config ? $row['host'] : NULL, $row['flags'] == 4 ? $row['name'] : new CLink($row['name'], 'items.php?form=update&itemid=' . $row['itemid']), $row['error'])); } $rep2_wdgt->addItem($table); } $rep2_wdgt->show(); include_once 'include/page_footer.php';
$filter = new CButton('filter', _('Filter'), "javascript: create_var('zbx_filter', 'filter_set', '1', true);"); $filter->useJQueryStyle('main'); $reset = new CButton('reset', _('Reset'), "javascript: clearAllForm('zbx_filter');"); $reset->useJQueryStyle(); $div_buttons = new CDiv(array($filter, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0px;'); $footer_col = new CCol($div_buttons, 'controls'); $filter_table->addRow($footer_col); $filter_form = new CForm('get'); $filter_form->setAttribute('name', 'zbx_filter'); $filter_form->setAttribute('id', 'zbx_filter'); $filter_form->addItem($filter_table); $hostinvent_wdgt->addFlicker($filter_form, CProfile::get('web.hostinventories.filter.state', 0)); $hostinvent_wdgt->addHeaderRowNumber(); $table = new CTableInfo(_('No hosts defined.')); $table->setHeader(array(is_show_all_nodes() ? make_sorting_header(_('Node'), 'hostid') : null, make_sorting_header(_('Host'), 'name'), _('Group'), make_sorting_header(_('Name'), 'pr_name'), make_sorting_header(_('Type'), 'pr_type'), make_sorting_header(_('OS'), 'pr_os'), make_sorting_header(_('Serial number A'), 'pr_serialno_a'), make_sorting_header(_('Tag'), 'pr_tag'), make_sorting_header(_('MAC address A'), 'pr_macaddress_a'))); $hosts = array(); $paging = getPagingLine($hosts); if ($pageFilter->groupsSelected) { // which inventory fields we will need for displaying $requiredInventoryFields = array('name', 'type', 'os', 'serialno_a', 'tag', 'macaddress_a'); // checking if correct inventory field is specified for filter $possibleInventoryFields = getHostInventories(); $possibleInventoryFields = zbx_toHash($possibleInventoryFields, 'db_field'); if (!empty($_REQUEST['filter_field']) && !empty($_REQUEST['filter_field_value']) && !isset($possibleInventoryFields[$_REQUEST['filter_field']])) { error(_s('Impossible to filter by inventory field "%s", which does not exist.', $_REQUEST['filter_field'])); } else { // if we are filtering by field, this field is also required if (!empty($_REQUEST['filter_field']) && !empty($_REQUEST['filter_field_value'])) { $requiredInventoryFields[] = $_REQUEST['filter_field']; }
$gMacros = CUserMacro::get(array('output' => API_OUTPUT_EXTEND, 'globalmacro' => 1)); $gMacros = zbx_toHash($gMacros, 'macro'); $services = array(); foreach ($dservices as $dsnum => $dservice) { $key_ = $dservice['key_']; if (!zbx_empty($key_)) { if (isset($gMacros[$key_])) { $key_ = $gMacros[$key_]['value']; } $key_ = ': ' . $key_; } $service_name = discovery_check_type2str($dservice['type']) . discovery_port2str($dservice['type'], $dservice['port']) . $key_; $services[$service_name] = 1; } ksort($services); $header = array(is_show_all_nodes() ? new CCol(S_NODE, 'left') : null, make_sorting_header(S_DISCOVERED_DEVICE, 'ip'), new CCol(S_MONITORED_HOST, 'left'), new CCol(array(S_UPTIME . '/', S_DOWNTIME), 'left')); $css = getUserTheme($USER_DETAILS); $vTextColor = $css == 'css_od.css' ? '&color=white' : ''; foreach ($services as $name => $foo) { $header[] = new CImg('vtext.php?text=' . $name . $vTextColor); } $table = new CTableInfo(); $table->setHeader($header, 'vertical_header'); $options = array('filter' => array('status' => DRULE_STATUS_ACTIVE), 'selectDHosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND); if ($druleid > 0) { $options['druleids'] = $druleid; } $drules = CDRule::get($options); order_result($drules, 'name'); $options = array('druleids' => zbx_objectValues($drules, 'druleid'), 'selectDServices' => API_OUTPUT_REFER, 'output' => API_OUTPUT_REFER); $db_dhosts = CDHost::get($options);
if ($admin) { $params = array('nodeid' => get_current_nodeid(), 'extendoutput' => 1, 'pattern' => $search, 'limit' => $rows_per_page, 'order' => 'host', 'editable' => 1); $db_templates = CTemplate::get($params); $templates = selectByPattern($db_templates, 'host', $search, $rows_per_page); $templateids = array_keys($templates); $hostsgroups = array(); $sql = 'SELECT * FROM hosts_groups hg WHERE ' . DBcondition('hg.hostid', $templateids); $res = DBselect($sql); while ($templategroup = DBfetch($res)) { $hostsgroups[$templategroup['hostid']] = $templategroup['groupid']; } $params = array('nodeids' => get_current_nodeid(), 'pattern' => $search, 'count' => 1, 'editable' => 1); $hosts_count = CTemplate::get($params); $overalCount = $hosts_count['rowscount']; $viewCount = count($templates); $header = array(is_show_all_nodes() ? new CCol(S_NODE) : null, new CCol(S_TEMPLATES), new CCol(S_ITEMS), new CCol(S_TRIGGERS), new CCol(S_GRAPHS)); $table = new CTableInfo(); $table->setHeader($header); foreach ($templates as $num => $template) { $templateid = $template['hostid']; $groupid = isset($hostsgroups[$templateid]) ? $hostsgroups[$templateid] : 0; $link = 'groupid=' . $groupid . '&hostid=' . $templateid; $caption = make_decoration($template['host'], $search); $table->addRow(array(get_node_name_by_elid($templateid), new CLink($caption, 'hosts.php?config=3&hostid=' . $templateid), new CLink(S_GO, 'items.php?' . $link), new CLink(S_GO, 'triggers.php?' . $link), new CLink(S_GO, 'graphs.php?' . $link))); } $table->setFooter(new CCol(S_DISPLAYING . SPACE . $viewCount . SPACE . S_OF_SMALL . SPACE . $overalCount . SPACE . S_FOUND_SMALL)); $wdgt_templates = new CWidget('search_templates', $table); $wdgt_templates->addHeader(S_TEMPLATES, SPACE); $right_tab->addRow($wdgt_templates); } //----------------
$filterForm->addItemToBottomRow($reset); $trigg_wdgt->addFlicker($filterForm, get_profile('web.tr_status.filter.state', 0)); /*************** FILTER END ******************/ if ($_REQUEST['fullscreen']) { $triggerInfo = new CTriggersInfo(); $triggerInfo->HideHeader(); $triggerInfo->show(); } $m_form = new CForm('acknow.php'); $m_form->setName('tr_status'); $admin_links = $USER_DETAILS['type'] == USER_TYPE_ZABBIX_ADMIN || $USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN; $table = new CTableInfo(); $table->showStart(); $header = array(); $show_event_col = $config['event_ack_enable'] && $show_events != EVENTS_OPTION_NOEVENT; $table->setHeader(array($show_event_col ? new CCheckBox('all_events', false, "checkAll('" . $m_form->GetName() . "','all_events','events');") : NULL, make_sorting_link(S_SEVERITY, 't.priority'), S_STATUS, make_sorting_link(S_LAST_CHANGE, 't.lastchange'), is_show_all_nodes() ? make_sorting_link(S_NODE, 'h.hostid') : null, $_REQUEST['hostid'] > 0 ? null : make_sorting_link(S_HOST, 'h.host'), make_sorting_link(S_NAME, 't.description'), $_REQUEST['show_actions'] ? S_ACTIONS : NULL, $show_event_col ? S_ACKNOWLEDGED : NULL, S_COMMENTS)); $cond = $_REQUEST['hostid'] > 0 ? ' AND h.hostid=' . $_REQUEST['hostid'] . ' ' : ''; switch ($show_triggers) { case TRIGGERS_OPTION_ALL: $cond .= ''; break; case TRIGGERS_OPTION_NOFALSEFORB: $cond .= ''; break; case TRIGGERS_OPTION_ONLYTRUE: default: $cond .= ' AND ((t.value=' . TRIGGER_VALUE_TRUE . ') OR ((t.value=' . TRIGGER_VALUE_FALSE . ') AND ((' . time() . '-t.lastchange)<' . TRIGGER_FALSE_PERIOD . ')))'; break; } if ($show_severity > -1) { $cond .= ' AND t.priority>=' . $show_severity;
} else { $ack = SPACE; } } if ($row_event['acknowledged'] == 0 && $row_event['value'] == TRIGGER_VALUE_TRUE) { $ack_cb = new CCheckBox('events[' . $row_event['eventid'] . ']', 'no', NULL, $row_event['eventid']); } else { $ack_cb = SPACE; } $clock = new CLink(zbx_date2str(S_DATE_FORMAT_YMDHMS, $row_event['clock']), 'tr_events.php?triggerid=' . $trigger['triggerid'] . '&eventid=' . $row_event['eventid']); $next_clock = isset($trigger['events'][$enum - 1]) ? $trigger['events'][$enum - 1]['clock'] : time(); $empty_col = new CCol(SPACE); $empty_col->setColSpan(3); $ack_cb_col = new CCol($ack_cb); $ack_cb_col->setColSpan(2); $row = new CRow(array(SPACE, $config['event_ack_enable'] ? $ack_cb_col : null, $status, $clock, zbx_date2age($row_event['clock']), zbx_date2age($next_clock, $row_event['clock']), $config['event_ack_enable'] ? $ack : NULL, is_show_all_nodes() ? SPACE : null, $empty_col), 'odd_row'); $row->setAttribute('data-parentid', $trigger['triggerid']); $row->addStyle('display: none;'); $table->addRow($row); if ($i > $config['event_show_max']) { break; } } } } //----- GO ------ $footer = null; if ($config['event_ack_enable']) { $goBox = new CComboBox('go'); $goBox->addItem('bulkacknowledge', S_BULK_ACKNOWLEDGE); // goButton name is necessary!!!
} } $r_form = new CForm(null, 'get'); $r_form->addVar('prof_type', $_REQUEST['prof_type']); $r_form->addItem(array(S_GROUP . SPACE, $pageFilter->getGroupsCB(true))); $hostprof_wdgt->addHeader(S_HOSTS_BIG, $r_form); $numrows = new CDiv(); $numrows->setAttribute('name', 'numrows'); $hostprof_wdgt->addHeader($numrows); order_result($hosts, $sortfield, $sortorder); $paging = getPagingLine($hosts); $table = new CTableInfo(); if (0 == $_REQUEST['prof_type']) { $table->setHeader(array(is_show_all_nodes() ? make_sorting_header(S_NODE, 'hostid') : null, make_sorting_header(S_HOST, 'host'), S_GROUP, make_sorting_header(S_NAME, 'pr_name'), make_sorting_header(S_OS, 'pr_os'), make_sorting_header(S_SERIALNO, 'pr_serialno'), make_sorting_header(S_TAG, 'pr_tag'), make_sorting_header(S_MACADDRESS, 'pr_macaddress'))); } else { $table->setHeader(array(is_show_all_nodes() ? make_sorting_header(S_NODE, 'hostid') : null, make_sorting_header(S_HOST, 'host'), S_GROUP, make_sorting_header(S_DEVICE_OS_SHORT, 'pre_device_os_short'), make_sorting_header(S_DEVICE_HW_ARCH, 'pre_device_hw_arch'), make_sorting_header(S_DEVICE_TYPE, 'pre_device_type'), make_sorting_header(S_DEVICE_STATUS, 'pre_device_status'))); } foreach ($hosts as $host) { $host_groups = array(); foreach ($host['groups'] as $group) { $host_groups[] = $group['name']; } natcasesort($host_groups); $host_groups = implode(', ', $host_groups); $row = array(get_node_name_by_elid($host['hostid']), new CLink($host['host'], '?hostid=' . $host['hostid'] . url_param('groupid') . '&prof_type=' . $_REQUEST['prof_type']), $host_groups); if (0 == $_REQUEST['prof_type']) { $row[] = zbx_str2links($host['profile']['name']); $row[] = zbx_str2links($host['profile']['os']); $row[] = zbx_str2links($host['profile']['serialno']); $row[] = zbx_str2links($host['profile']['tag']); $row[] = zbx_str2links($host['profile']['macaddress']);
/** * 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; }
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('period' => array(T_ZBX_STR, O_OPT, P_SYS | P_NZERO, IN('"day","week","month","year"'), NULL)); check_fields($fields); $_REQUEST['period'] = get_request('period', 'day'); $admin_links = $USER_DETAILS['type'] == USER_TYPE_ZABBIX_ADMIN || $USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN; $form = new CForm(); $form->SetMethod('get'); $cmbPeriod = new CComboBox('period', $_REQUEST['period'], 'submit()'); $cmbPeriod->addItem('day', S_DAY); $cmbPeriod->addItem('week', S_WEEK); $cmbPeriod->addItem('month', S_MONTH); $cmbPeriod->addItem('year', S_YEAR); $form->addItem($cmbPeriod); show_table_header(S_TRIGGERS_TOP_100_BIG, $form); $table = new CTableInfo(); $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST, S_TRIGGER, S_SEVERITY, S_NUMBER_OF_STATUS_CHANGES)); switch ($_REQUEST['period']) { case 'week': $time_dif = 7 * 86400; break; case 'month': $time_dif = 30 * 86400; break; case 'year': $time_dif = 365 * 86400; break; case 'day': default: $time_dif = 86400; break; }