mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add filter by priority to syslog
This commit is contained in:
@ -17,6 +17,11 @@ if (is_numeric($_POST['device'])) {
|
||||
$param[] = $_POST['device'];
|
||||
}
|
||||
|
||||
if ($_POST['priority']) {
|
||||
$where .= ' AND S.priority = ?';
|
||||
$param[] = $_POST['priority'];
|
||||
}
|
||||
|
||||
if (!empty($_POST['from'])) {
|
||||
$where .= ' AND timestamp >= ?';
|
||||
$param[] = $_POST['from'];
|
||||
@ -64,7 +69,8 @@ $sql = "SELECT S.*, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['co
|
||||
foreach (dbFetchRows($sql, $param) as $syslog) {
|
||||
$dev = device_by_id_cache($syslog['device_id']);
|
||||
$response[] = array(
|
||||
'timestamp' => $syslog['date'],
|
||||
'priority' => generate_priority_icon($syslog['priority']),
|
||||
'timestamp' => '<div style="white-space:nowrap;">'.$syslog['date'].'</div>',
|
||||
'device_id' => generate_device_link($dev, shorthost($dev['hostname'])),
|
||||
'program' => $syslog['program'],
|
||||
'msg' => htmlspecialchars($syslog['msg']),
|
||||
|
@ -16,6 +16,7 @@ $pagetitle[] = 'Syslog';
|
||||
<table id="syslog" class="table table-hover table-condensed table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="priority"> </th>
|
||||
<th data-column-id="timestamp" data-order="desc">Datetime</th>
|
||||
<th data-column-id="device_id">Hostname</th>
|
||||
<th data-column-id="program">Program</th>
|
||||
@ -67,6 +68,21 @@ var grid = $("#syslog").bootgrid({
|
||||
"</select>"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<select name=\"priority\" id=\"priority\" class=\"form-control input-sm\">"+
|
||||
"<option value=\"\">All Priorities</option>"+
|
||||
<?php
|
||||
foreach (dbFetchRows('SELECT DISTINCT `priority` FROM `syslog` ORDER BY `level`') as $data) {
|
||||
echo '"<option value=\"'.$data['priority'].'\"';
|
||||
if ($data['priority'] == $vars['priority']) {
|
||||
echo ' selected';
|
||||
}
|
||||
|
||||
echo '>'.$data['priority'].'</option>"+';
|
||||
}
|
||||
?>
|
||||
"</select>"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
"<input name=\"from\" type=\"text\" class=\"form-control input-sm\" id=\"dtpickerfrom\" maxlength=\"16\" value=\"<?php echo $vars['from']; ?>\" placeholder=\"From\" data-date-format=\"YYYY-MM-DD HH:mm\">"+
|
||||
"</div>"+
|
||||
"<div class=\"form-group\">"+
|
||||
@ -83,6 +99,7 @@ var grid = $("#syslog").bootgrid({
|
||||
id: "syslog",
|
||||
device: '<?php echo htmlspecialchars($vars['device']); ?>',
|
||||
program: '<?php echo htmlspecialchars($vars['program']); ?>',
|
||||
priority: '<?php echo htmlspecialchars($vars['priority']); ?>',
|
||||
to: '<?php echo htmlspecialchars($vars['to']); ?>',
|
||||
from: '<?php echo htmlspecialchars($vars['from']); ?>',
|
||||
};
|
||||
|
@ -16,6 +16,21 @@
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
function generate_priority_icon($priority) {
|
||||
$map = array(
|
||||
"emerg" => "server_delete",
|
||||
"alert" => "cancel",
|
||||
"crit" => "application_lightning",
|
||||
"err" => "application_delete",
|
||||
"warning" => "application_error",
|
||||
"notice" => "application_edit",
|
||||
"info" => "application",
|
||||
"debug" => "bug",
|
||||
);
|
||||
|
||||
return '<img src="images/16/' . $map[$priority] .'.png" title="' . $priority . '">';
|
||||
}
|
||||
|
||||
function format_number_short($number, $sf) {
|
||||
// This formats a number so that we only send back three digits plus an optional decimal point.
|
||||
// Example: 723.42 -> 723 72.34 -> 72.3 2.23 -> 2.23
|
||||
|
Reference in New Issue
Block a user