Print alert state and a matching glyphic

- Print alert state on default front page and on alert-log page.
Prints the state and a matching glyphicon.
This commit is contained in:
Rosiak
2015-03-03 18:48:40 +01:00
parent 7c1b6f4fbc
commit d0997d09d4
3 changed files with 25 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
<?php
$hostname = gethostbyid($alert_entry['device_id']);
$alert_state = $alert_entry['state'];
echo('<tr>
<td>
@@ -14,8 +15,26 @@ if (!isset($alert_entry['device'])) {
</td>");
}
echo("<td>".htmlspecialchars($alert_entry['name']) . "</td>
echo("<td>".htmlspecialchars($alert_entry['name']) . "</td>");
</tr>");
if ($alert_state!='') {
if ($alert_state=='0') {
echo("<td><b><span class='glyphicon glyphicon-ok' style='color:green'></span> Ok</b></td>");
}
elseif ($alert_state=='1') {
echo("<td><b><span class='glyphicon glyphicon-remove' style='color:red'></span> Alert</b></td>");
}
elseif ($alert_state=='2') {
echo("<td><b><span class='glyphicon glyphicon-info-sign' style='color:lightgrey'></span> Ack</b></td>");
}
elseif ($alert_state=='3') {
echo("<td><b><span class='glyphicon glyphicon-arrow-down' style='color:orange'></span> Worse</b></td>");
}
elseif ($alert_state=='4') {
echo("<td><b><span class='glyphicon glyphicon-arrow-up' style='color:khaki'></span> Better</b></td>");
}
}
echo("</tr>");
?>

View File

@@ -60,7 +60,7 @@ if ($_SESSION['userlevel'] >= '5')
}
$count_query = "SELECT COUNT(time_logged) $query";
$count = dbFetchCell($count_query,$param);
$full_query = "SELECT D.device_id,name,time_logged,DATE_FORMAT(time_logged, '%D %b %Y %T') as humandate $query LIMIT $start,$numresults";
$full_query = "SELECT D.device_id,name,state,time_logged,DATE_FORMAT(time_logged, '%D %b %Y %T') as humandate $query LIMIT $start,$numresults";
echo('<div class="panel panel-default panel-condensed">
<div class="panel-heading">
<div class="row">
@@ -112,4 +112,4 @@ echo('</table>
$('#page_number').val(page);
$('#result_form').submit();
}
</script>
</script>

View File

@@ -199,10 +199,10 @@ if ($config['enable_syslog'])
if ($_SESSION['userlevel'] >= '10')
{
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` ORDER BY `datetime` DESC LIMIT 0,15";
$alertquery = "SELECT devices.device_id,name,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id RIGHT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15";
$alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id RIGHT JOIN alert_rules ON alert_log.rule_id=alert_rules.id ORDER BY `time_logged` DESC LIMIT 0,15";
} else {
$query = "SELECT *,DATE_FORMAT(datetime, '%D %b %T') as humandate FROM `eventlog` AS E, devices_perms AS P WHERE E.host = P.device_id AND P.user_id = " . $_SESSION['user_id'] . " ORDER BY `datetime` DESC LIMIT 0,15";
$alertquery = "SELECT devices.device_id,name,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id RIGHT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15";
$alertquery = "SELECT devices.device_id,name,state,time_logged FROM alert_log LEFT JOIN devices ON alert_log.device_id=devices.device_id RIGHT JOIN alert_rules ON alert_log.rule_id=alert_rules.id RIGHT JOIN devices_perms ON alert_log.device_id = devices_perms.device_id AND devices_perms.user_id = " . $_SESSION['user_id'] . " ORDER BY `time_logged` DESC LIMIT 0,15";
}
$data = mysql_query($query);