$action = S_ENABLED; break; case AUDIT_ACTION_DISABLE: $action = S_DISABLED; break; default: $action = S_UNKNOWN_ACTION; } $row['action'] = $action; $row['resourcetype'] = audit_resource2str($row['resourcetype']); $count++; $clock[] = $row['clock']; $actions[] = $row; } $last_clock = !empty($clock) ? min($clock) : null; order_page_result($actions, 'clock', ZBX_SORT_DOWN); foreach ($actions as $num => $row) { if (empty($row['details'])) { $details = array(); $sql = 'SELECT table_name,field_name,oldvalue,newvalue ' . ' FROM auditlog_details ' . ' WHERE auditid=' . $row['auditid']; $db_details = DBselect($sql); while ($db_detail = DBfetch($db_details)) { $details[] = array($db_detail['table_name'] . '.' . $db_detail['field_name'] . ': ' . $db_detail['oldvalue'] . ' => ' . $db_detail['newvalue'], BR()); } } else { $details = $row['details']; } $table->addRow(array(date('Y.M.d H:i:s', $row['clock']), $row['alias'], $row['ip'], $row['resourcetype'], $row['action'], $row['resourceid'], $row['resourcename'], new CCol($details, 'wraptext'))); } } else { if (1 == $config) {
$row = array_merge($triggers[$row['triggerid']], $row); if (0 == $show_unknown && !event_initial_time($row, $show_unknown)) { continue; } $row['desc'] = expand_trigger_description_by_data($row, ZBX_FLAG_EVENT); $row['duration'] = zbx_date2age($row['clock']); if ($next_event = get_next_event($row, $show_unknown)) { $row['duration'] = zbx_date2age($row['clock'], $next_event['clock']); } $row['value'] = new CCol(trigger_value2str($row['value']), get_trigger_value_style($row['value'])); $col++; $clock[] = $row['clock']; $events[] = $row; } $last_clock = !empty($clock) ? min($clock) : null; order_page_result($events, 'clock', ZBX_SORT_DOWN); foreach ($events as $num => $row) { // Actions $actions = get_event_actions_status($row['eventid']); //-------- 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)); }
echo SBR; insert_map_link_form(); } else { info('Not enough elements in this map'); } } else { show_table_header(S_DISPLAYED_ELEMENTS, new CButton('form', S_ADD_ELEMENT, "return redirect('" . $page['file'] . '?form=add_element' . url_param('sysmapid') . "');")); $table = new CTableInfo(); $table->setHeader(array(S_LABEL, S_TYPE, S_X, S_Y, S_ICON_OK, S_ICON_PROBLEM, S_ICON_UNKNOWN, S_ICON_DISABLED)); $map_elements = array(); $sql = 'select * ' . ' from sysmaps_elements ' . ' where sysmapid=' . $_REQUEST['sysmapid']; $db_elements = DBselect($sql); while ($db_element = DBfetch($db_elements)) { $map_elements[$db_element['selementid']] = $db_element; } order_page_result($map_elements, 'label'); foreach ($map_elements as $selementid => $db_element) { if ($db_element['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST) { $type = S_HOST; } elseif ($db_element['elementtype'] == SYSMAP_ELEMENT_TYPE_MAP) { $type = S_MAP; } elseif ($db_element['elementtype'] == SYSMAP_ELEMENT_TYPE_TRIGGER) { $type = S_TRIGGER; } elseif ($db_element['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST_GROUP) { $type = S_HOST_GROUP; } else { $type = 'Map element'; } $table->addRow(array(new CLink(expand_map_element_label_by_data($db_element), "sysmap.php?sysmapid=" . $db_element["sysmapid"] . "&form=update&selementid=" . $db_element["selementid"], "action"), nbsp($type), $db_element['x'], $db_element['y'], $db_element['iconid_off'] ? new CImg('image.php?height=24&imageid=' . $db_element['iconid_off'], 'no image', NULL) : '-', $db_element['iconid_on'] ? new CImg('image.php?height=24&imageid=' . $db_element['iconid_on'], 'no image', NULL) : '-', $db_element['iconid_unknown'] ? new CImg('image.php?height=24&imageid=' . $db_element['iconid_unknown'], 'no image', NULL) : '-', $db_element['iconid_disabled'] ? new CImg('image.php?height=24&imageid=' . $db_element['iconid_disabled'], 'no image', NULL) : '-')); } $table->show();
function get_history_of_actions($limit, &$last_clock = null, $sql_cond = '') { $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY); $alerts = array(); $clock = array(); $table = new CTableInfo(S_NO_ACTIONS_FOUND); $table->setHeader(array(is_show_all_nodes() ? make_sorting_link(S_NODES, 'a.alertid') : null, make_sorting_link(S_TIME, 'clock'), make_sorting_link(S_TYPE, 'description'), make_sorting_link(S_STATUS, 'status'), make_sorting_link(S_RETRIES_LEFT, 'retries'), make_sorting_link(S_RECIPIENTS, 'sendto'), S_MESSAGE, S_ERROR)); $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 . ') ' . $sql_cond . ' AND ' . DBcondition('e.objectid', $available_triggers) . ' AND ' . DBin_node('a.alertid') . ' ORDER BY a.clock DESC'; $result = DBselect($sql, $limit); while ($row = DBfetch($result)) { $alerts[] = $row; $clock[] = $row['clock']; } $last_clock = !empty($clock) ? min($clock) : null; order_page_result($alerts, 'clock', ZBX_SORT_DOWN); foreach ($alerts as $num => $row) { $time = date(S_DATE_FORMAT_YMDHMS, $row['clock']); 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'); } } $sendto = $row['sendto']; $message = array(bold(S_SUBJECT . ': '), br(), $row['subject'], br(), br(), bold(S_MESSAGE . ': '), br(), $row['message']); if (empty($row['error'])) { $error = new CSpan(SPACE, 'off'); } else { $error = new CSpan($row['error'], 'on'); } $table->addRow(array(get_node_name_by_elid($row['alertid']), new CCol($time, 'top'), new CCol($row['description'], 'top'), new CCol($status, 'top'), new CCol($retries, 'top'), new CCol($sendto, 'top'), new CCol($message, 'top'), new CCol($error, 'wraptext top'))); } return $table; }
function get_history_of_discovery_events($end_time, $limit, &$last_clock = null) { $table = new CTableInfo(S_NO_EVENTS_FOUND); $table->setHeader(array(S_TIME, S_IP, S_DESCRIPTION, S_STATUS)); $col = 0; $clock = array(); $dsc_events = array(); $sql = 'SELECT DISTINCT e.source,e.object,e.objectid,e.clock,e.value ' . ' FROM events e' . ' WHERE e.source=' . EVENT_SOURCE_DISCOVERY . ' AND e.clock<' . $end_time . ' ORDER BY e.clock DESC'; $db_events = DBselect($sql, $limit); while ($event_data = DBfetch($db_events)) { switch ($event_data['object']) { case EVENT_OBJECT_DHOST: $sql = 'SELECT ip FROM dhosts WHERE dhostid=' . $event_data['objectid']; if ($object_data = DBfetch(DBselect($sql))) { $event_data['object_data'] = $object_data; } else { $event_data['object_data']['ip'] = S_UNKNOWN; } $event_data['description'] = SPACE; break; case EVENT_OBJECT_DSERVICE: $sql = 'SELECT h.ip,s.type,s.port ' . ' FROM dhosts h,dservices s ' . ' WHERE h.dhostid=s.dhostid ' . ' AND s.dserviceid=' . $event_data['objectid']; if ($object_data = DBfetch(DBselect($sql))) { $event_data['object_data'] = $object_data; } else { $event_data['object_data']['ip'] = S_UNKNOWN; $event_data['object_data']['type'] = S_UNKNOWN; $event_data['object_data']['port'] = S_UNKNOWN; } $event_data['description'] = S_SERVICE . ': ' . discovery_check_type2str($event_data['object_data']['type']) . '; ' . S_PORT . ': ' . $event_data['object_data']['port']; break; default: continue; } if (!isset($event_data['object_data'])) { continue; } $clock[] = $event_data['clock']; $dsc_events[] = $event_data; } $last_clock = !empty($clock) ? min($clock) : null; order_page_result($dsc_events, 'clock', ZBX_SORT_DOWN); foreach ($dsc_events as $num => $event_data) { $value = new CCol(trigger_value2str($event_data['value']), get_trigger_value_style($event_data['value'])); $table->addRow(array(date('Y.M.d H:i:s', $event_data['clock']), $event_data['object_data']['ip'], $event_data['description'], $value)); } return $table; }