コード例 #1
0
ファイル: CMbObject.class.php プロジェクト: fbone/mediboard4
 /**
  * Chargement des alertes non traitées
  *
  * @param string $level Niveau des alertes
  * @param string $tag   Tag des alertes
  * @param int    $perm  Permission
  *
  * @return CStoredObject[]
  */
 function loadAlertsNotHandled($level = null, $tag = null, $perm = PERM_READ)
 {
     $alert = new CAlert();
     $alert->handled = "0";
     $alert->setObject($this);
     $alert->level = $level;
     $alert->tag = $tag;
     $this->_refs_alerts_not_handled = $alert->loadMatchingList();
     self::filterByPerm($this->_refs_alerts_not_handled, $perm);
     return $this->_refs_alerts_not_handled;
 }
コード例 #2
0
ファイル: CSalle.class.php プロジェクト: fbone/mediboard4
 /**
  * Récupération des alertes sur les interventions de la salle
  *
  * @return CAlert[]
  */
 function loadRefsAlertesIntervs()
 {
     $alerte = new CAlert();
     $ljoin = array();
     $ljoin["operations"] = "operations.operation_id = alert.object_id";
     $ljoin["plagesop"] = "plagesop.plageop_id = operations.plageop_id";
     $where = array();
     $where["alert.object_class"] = "= 'COperation'";
     $where["alert.tag"] = "= 'mouvement_intervention'";
     $where["alert.handled"] = "= '0'";
     $where[] = "operations.salle_id = '{$this->salle_id}'\r\n      OR plagesop.salle_id = '{$this->salle_id}'\r\n      OR (plagesop.salle_id IS NULL AND operations.salle_id IS NULL)";
     $order = "operations.date, operations.chir_id";
     return $this->_alertes_intervs = $alerte->loadList($where, $order, null, null, $ljoin);
 }
コード例 #3
0
 /**
  * count the number of alerts for this bloc
  *
  * @param array $key_ids list of salle keys
  *
  * @return int
  */
 static function countAlertesIntervsForSalles($key_ids)
 {
     if (!count($key_ids)) {
         return 0;
     }
     $inSalles = CSQLDataSource::prepareIn($key_ids);
     $alerte = new CAlert();
     $ljoin = array();
     $ljoin["operations"] = "operations.operation_id = alert.object_id";
     $ljoin["plagesop"] = "plagesop.plageop_id = operations.plageop_id";
     $where = array();
     $where["alert.object_class"] = "= 'COperation'";
     $where["alert.tag"] = "= 'mouvement_intervention'";
     $where["alert.handled"] = "= '0'";
     $where[] = "operations.salle_id " . $inSalles . " OR plagesop.salle_id " . $inSalles . " OR (plagesop.salle_id IS NULL AND operations.salle_id IS NULL)";
     return $alerte->countList($where, null, $ljoin);
 }
コード例 #4
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');
コード例 #5
0
 static function massLoadRefAlerte(&$observations = array(), $handled = true)
 {
     $alerte = new CAlert();
     $where = array("object_class" => "= 'CObservationMedicale'", "object_id" => CSQLDataSource::prepareIn(CMbArray::pluck($observations, "_id")), "level" => "= 'medium'", "tag" => "= '" . self::$tag_alerte . "'");
     if (!$handled) {
         $where["handled"] = "= '0'";
     }
     $alertes = $alerte->loadList($where);
     CStoredObject::massLoadFwdRef($alertes, "handled_user_id");
     foreach ($alertes as $_alerte) {
         $observations[$_alerte->object_id]->_ref_alerte = $_alerte;
     }
     foreach ($observations as $_observation) {
         if (!$_observation->_ref_alerte) {
             $_observation->_ref_alerte = new CAlert();
         }
         $_observation->_ref_alerte->loadRefHandledUser();
     }
 }
コード例 #6
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;
}
コード例 #7
0
 private static function alert($action, $params)
 {
     CAlert::$error = array();
     switch ($action) {
         default:
             $result = call_user_func(array('CAlert', $action), $params);
     }
     self::$result = $result;
 }
コード例 #8
0
ファイル: CSejour.class.php プロジェクト: fbone/mediboard4
 function countAlertsNotHandled($level = null, $tag = null)
 {
     if ($tag == "observation") {
         $alert = new CAlert();
         $where = array("object_class" => "= 'CObservationMedicale'", "object_id" => CSQLDataSource::prepareIn($this->loadBackIds("observations")), "level" => "= 'medium'", "handled" => "= '0'", "tag" => "= '" . CObservationMedicale::$tag_alerte . "'");
         return $this->_count_alerts_not_handled = $alert->countList($where);
     }
     return parent::countAlertsNotHandled($level, $tag);
 }
コード例 #9
0
ファイル: report4.php プロジェクト: songyuanjie/zabbix-stats
 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']++;