Esempio n. 1
0
function get_action_cmds_for_event($eventid)
{
    $table = new CTableInfo(S_NO_ACTIONS_FOUND);
    $table->setHeader(array(is_show_all_nodes() ? S_NODES : null, S_TIME, S_STATUS, S_COMMAND, S_ERROR));
    $alerts = CAlert::get(array('eventids' => $eventid, 'filter' => array('alerttype' => ALERT_TYPE_COMMAND), 'output' => API_OUTPUT_EXTEND, 'sortfield' => 'clock', 'sortorder' => ZBX_SORT_DOWN));
    foreach ($alerts as $alertid => $row) {
        $time = zbx_date2str(S_EVENT_ACTION_CMDS_DATE_FORMAT, $row['clock']);
        if ($row['esc_step'] > 0) {
            $time = array(bold(S_STEP . ': '), $row['esc_step'], br(), bold(S_TIME . ': '), br(), $time);
        }
        switch ($row['status']) {
            case ALERT_STATUS_SENT:
                $status = new CSpan(S_EXECUTED, 'green');
                break;
            case ALERT_STATUS_NOT_SENT:
                $status = new CSpan(S_IN_PROGRESS, 'orange');
                break;
            default:
                $status = new CSpan(S_NOT_SENT, 'red');
                break;
        }
        $message = array(bold(S_COMMAND . ':'));
        $msg = explode('\\n', $row['message']);
        foreach ($msg as $m) {
            array_push($message, BR(), $m);
        }
        $error = empty($row['error']) ? new CSpan(SPACE, 'off') : new CSpan($row['error'], 'on');
        $table->addRow(array(get_node_name_by_elid($row['alertid']), new CCol($time, 'top'), new CCol($status, 'top'), new CCol($message, 'wraptext top'), new CCol($error, 'wraptext top')));
    }
    return $table;
}
Esempio n. 2
0
$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']);
$options['limit'] = 1;
$options['sortorder'] = ZBX_SORT_UP;
$firstAlert = CAlert::get($options);
$firstAlert = reset($firstAlert);
$starttime = $firstAlert ? $firstAlert['clock'] : time() - 3600;
$paging = getPagingLine($alerts);
foreach ($alerts as $num => $row) {
    $mediatype = array_pop($row['mediatypes']);
    if ($mediatype['mediatypeid'] == 0) {
        $mediatype = array('description' => '');
    }
    if ($row['status'] == ALERT_STATUS_SENT) {
        if ($row['alerttype'] == ALERT_TYPE_MESSAGE) {
            $status = new CSpan(S_SENT, 'green');
        } else {
            $status = new CSpan(S_EXECUTED, 'green');
        }
        $retries = new CSpan(SPACE, 'green');
Esempio n. 3
0
 for ($t = $from; $t <= $to; $t++) {
     if (($start = get_time($t)) > time()) {
         break;
     }
     if (($end = get_time($t + 1)) > time()) {
         $end = time();
     }
     $table_row = array(format_time($start), format_time2($end));
     //getting all alerts in this period of time
     $options = array('output' => array('mediatypeid', 'userid'), 'time_from' => $start, 'time_till' => $end);
     //if we must get only specific media type, no need to select the other ones
     if ($media_type > 0) {
         $options['mediatypeids'] = $media_type;
     }
     //getting data through API
     $alert_info = CAlert::get($options);
     //counting alert count for each user and media type
     $summary = array();
     foreach ($users as $userid => $alias) {
         $summary[$userid] = array();
         $summary[$userid]['total'] = 0;
         $summary[$userid]['medias'] = array();
         foreach ($media_types as $media_type_nr => $mt) {
             $summary[$userid]['medias'][$media_type_nr] = 0;
         }
     }
     foreach ($alert_info as $ai) {
         if (!isset($summary[$ai['userid']])) {
             continue;
         }
         $summary[$ai['userid']]['total']++;