Beispiel #1
0
         $wd = date('w', $time);
         $wd = $wd == 0 ? 6 : $wd - 1;
         $minTime = $time - $wd * SEC_PER_DAY;
         $dateFormat = DATE_TIME_FORMAT;
         array_unshift($header, _('From'), _('Till'));
         $max = $year == $currentYear ? date('W') - 1 : 52;
         for ($i = 0; $i <= $max; $i++) {
             $intervals[strtotime('+' . $i . ' week', $minTime)] = strtotime('+' . ($i + 1) . ' week', $minTime);
         }
         break;
 }
 // time till
 $maxTime = $year == $currentYear ? time() : mktime(0, 0, 0, 1, 1, $year + 1);
 // fetch alerts
 $alerts = [];
 foreach (eventSourceObjects() as $sourceObject) {
     $alerts = array_merge($alerts, API::Alert()->get(['output' => ['mediatypeid', 'userid', 'clock'], 'eventsource' => $sourceObject['source'], 'eventobject' => $sourceObject['object'], 'mediatypeids' => getRequest('media_type') ? getRequest('media_type') : null, 'time_from' => $minTime, 'time_till' => $maxTime]));
 }
 // sort alerts in chronological order so we could easily iterate through them later
 CArrayHelper::sort($alerts, ['clock']);
 $table->setHeader($header);
 foreach ($intervals as $from => $till) {
     // interval start
     $row = [zbx_date2str($dateFormat, $from)];
     // interval end, displayed only for week intervals
     if ($period == 'weekly') {
         $row[] = zbx_date2str($dateFormat, min($till, time()));
     }
     // counting alert count for each user and media type
     $summary = [];
     foreach ($users as $userid) {
Beispiel #2
0
$from = zbxDateToTime($data['stime']);
$till = $from + $effectivePeriod;
$user = null;
$queryData = true;
$firstAlert = null;
if ($data['alias']) {
    $user = API::User()->get(array('output' => array('userid'), 'filter' => array('alias' => $data['alias'])));
    if ($user) {
        $user = reset($user);
    } else {
        $queryData = false;
    }
}
// fetch alerts for different objects and sources and combine them in a single stream
if ($queryData) {
    foreach (eventSourceObjects() as $eventSource) {
        $data['alerts'] = array_merge($data['alerts'], API::Alert()->get(array('output' => API_OUTPUT_EXTEND, 'selectMediatypes' => API_OUTPUT_EXTEND, 'userids' => $data['alias'] ? $user['userid'] : null, 'time_from' => $from, 'time_till' => $till, 'eventsource' => $eventSource['source'], 'eventobject' => $eventSource['object'], 'limit' => $config['search_limit'] + 1)));
    }
    CArrayHelper::sort($data['alerts'], array(array('field' => 'alertid', 'order' => ZBX_SORT_DOWN)));
    $data['alerts'] = array_slice($data['alerts'], 0, $config['search_limit'] + 1);
    // get first alert
    if ($user) {
        $firstAlert = DBfetch(DBselect('SELECT MIN(a.clock) AS clock' . ' FROM alerts a' . ' WHERE a.userid=' . zbx_dbstr($user['userid'])));
    }
}
// padding
$data['paging'] = getPagingLine($data['alerts']);
// timeline
$data['timeline'] = array('period' => $effectivePeriod, 'starttime' => date(TIMESTAMP_FORMAT, $firstAlert ? $firstAlert['clock'] : ZBX_MAX_PERIOD), 'usertime' => isset($data['stime']) ? date(TIMESTAMP_FORMAT, zbxDateToTime($data['stime']) + $effectivePeriod) : null);
// render view
$auditView = new CView('administration.auditacts.list', $data);