if (!isset($sort) || empty($sort)) { $sort = 'time_logged DESC'; } $sql .= " ORDER BY {$sort}"; if (isset($current)) { $limit_low = $current * $rowCount - $rowCount; $limit_high = $rowCount; } if ($rowCount != -1) { $sql .= " LIMIT {$limit_low},{$limit_high}"; } $sql = "SELECT D.device_id,name AS alert,state,time_logged,DATE_FORMAT(time_logged, '" . $config['dateformat']['mysql']['compact'] . "') as humandate,details {$sql}"; $rulei = 0; foreach (dbFetchRows($sql, $param) as $alertlog) { $dev = device_by_id_cache($alertlog['device_id']); $fault_detail = alert_details($alertlog['details']); $alert_state = $alertlog['state']; if ($alert_state == '0') { $fa_icon = 'check'; $fa_color = 'success'; $text = 'Ok'; } elseif ($alert_state == '1') { $fa_icon = 'times'; $fa_color = 'danger'; $text = 'Alert'; } elseif ($alert_state == '2') { $fa_icon = 'info-circle'; $fa_color = 'muted'; $text = 'Ack'; } elseif ($alert_state == '3') { $fa_icon = 'arrow-down';
$sort = 'timestamp DESC'; } $sql .= " ORDER BY {$sort}"; if (isset($current)) { $limit_low = $current * $rowCount - $rowCount; $limit_high = $rowCount; } if ($rowCount != -1) { $sql .= " LIMIT {$limit_low},{$limit_high}"; } $sql = "SELECT `alerts`.*, `devices`.`hostname` AS `hostname`, `devices`.`sysName` AS `sysName`,`alert_rules`.`rule` AS `rule`, `alert_rules`.`name` AS `name`, `alert_rules`.`severity` AS `severity` {$sql}"; $rulei = 0; $format = $_POST['format']; foreach (dbFetchRows($sql, $param) as $alert) { $log = dbFetchCell('SELECT details FROM alert_log WHERE rule_id = ? AND device_id = ? ORDER BY id DESC LIMIT 1', array($alert['rule_id'], $alert['device_id'])); $fault_detail = alert_details($log); $ico = 'ok'; $col = 'green'; $extra = ''; $msg = ''; if ((int) $alert['state'] === 0) { $ico = 'ok'; $col = 'green'; $extra = 'success'; $msg = 'ok'; } else { if ((int) $alert['state'] === 1 || (int) $alert['state'] === 3 || (int) $alert['state'] === 4) { $ico = 'volume-up'; $col = 'red'; $extra = 'danger'; $msg = 'alert';