webui: Syslog table refresh (#7796)

* initial changes

* final changes

* added missing copyright, removed commented old code
This commit is contained in:
crcro
2017-12-24 21:57:54 +02:00
committed by Neil Lathwood
parent 9e63d3200d
commit 71711326fb
4 changed files with 189 additions and 162 deletions

View File

@@ -1,16 +1,30 @@
<?php
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2017 LibreNMS
* @author LibreNMS Contributors
*/
$common_output[] = '
<div class="table-responsive">
<table id="syslog" class="table table-hover table-condensed table-striped">
<thead>
<tr>
<th data-column-id="priority">&nbsp;</th>
<th data-column-id="timestamp" data-order="desc">Datetime</th>
<th data-column-id="label"></th>
<th data-column-id="timestamp" data-order="desc">Timestamp</th>
<th data-column-id="level">Level</th>
<th data-column-id="device_id">Hostname</th>
<th data-column-id="program">Program</th>
<th data-column-id="msg">Message</th>
<th data-column-id="status">Message</th>
<th data-column-id="priority">Priority</th>
</tr>
</thead>
</table>
@@ -31,14 +45,7 @@ var syslog_grid = $("#syslog").bootgrid({
from: "'.mres($vars['from']).'",
};
},
url: "ajax_table.php",
statusMappings: {
// Nagios style
0: "text-muted",
1: "warning",
2: "danger",
3: "info"
}
url: "ajax_table.php"
});
</script>

View File

@@ -1,4 +1,17 @@
<?php
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version. Please see LICENSE.txt at the top level of
* the source code distribution for details.
*
* @package LibreNMS
* @subpackage webui
* @link http://librenms.org
* @copyright 2017 LibreNMS
* @author LibreNMS Contributors
*/
$where = '1';
$param = array();
@@ -68,12 +81,13 @@ $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(
'priority' => generate_priority_icon($syslog['priority']),
'timestamp' => '<div style="white-space:nowrap;">'.$syslog['date'].'</div>',
'label' => generate_priority_label($syslog['priority']),
'timestamp' => $syslog['date'],
'level' => $syslog['priority'],
'device_id' => generate_device_link($dev, shorthost($dev['hostname'])),
'program' => $syslog['program'],
'msg' => display($syslog['msg']),
'status' => generate_priority_status($syslog['priority']),
'priority' => generate_priority_status($syslog['priority']),
);
}