mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
webui: Syslog table refresh (#7796)
* initial changes * final changes * added missing copyright, removed commented old code
This commit is contained in:
@@ -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"> </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>
|
||||
|
||||
@@ -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']),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
<?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
|
||||
*/
|
||||
|
||||
$no_refresh = true;
|
||||
|
||||
$param = array();
|
||||
|
||||
if ($vars['action'] == 'expunge' && $_SESSION['userlevel'] >= '10') {
|
||||
@@ -10,147 +22,141 @@ if ($vars['action'] == 'expunge' && $_SESSION['userlevel'] >= '10') {
|
||||
}
|
||||
|
||||
$pagetitle[] = 'Syslog';
|
||||
|
||||
print_optionbar_start();
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div id="{{ctx.id}}" class="{{css.header}}">
|
||||
<div class="row">
|
||||
<div class="col-sm-9 actionBar">
|
||||
<div class="pull-left">
|
||||
<form method="post" action="" class="form-inline" role="form" id="result_form">
|
||||
<div class="form-group">
|
||||
<?php
|
||||
if (!is_numeric($vars['device'])) {
|
||||
?>
|
||||
<select name="device" id="device" class="form-control input-sm">
|
||||
<option value="">All Devices</option>
|
||||
<?php
|
||||
foreach (get_all_devices() as $data) {
|
||||
if (device_permitted($data['device_id'])) {
|
||||
echo '"<option value="' . $data['device_id'] . '"';
|
||||
if ($data['device_id'] == $vars['device']) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo '>' . format_hostname($data) . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
} else {
|
||||
echo '<input type="hidden" name="device" id="device" value="' . $vars['device'] . '">';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select name="program" id="program" class="form-control input-sm">
|
||||
<option value="">All Programs</option>
|
||||
<?php
|
||||
$sqlstatement = 'SELECT DISTINCT `program` FROM `syslog`';
|
||||
if (is_numeric($vars['device'])) {
|
||||
$sqlstatement = $sqlstatement . ' WHERE device_id=?';
|
||||
$param[] = $vars['device'];
|
||||
}
|
||||
$sqlstatement = $sqlstatement .' ORDER BY `program`';
|
||||
foreach (dbFetchRows($sqlstatement, $param) as $data) {
|
||||
echo '"<option value="'.mres($data['program']).'"';
|
||||
if ($data['program'] == $vars['program']) {
|
||||
echo ' selected';
|
||||
}
|
||||
|
||||
echo '>'.$data['program'].'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select name="priority" id="priority" class="form-control input-sm">
|
||||
<option value="">All Priorities</option>
|
||||
<?php
|
||||
$sqlstatement = 'SELECT DISTINCT `priority` FROM `syslog`';
|
||||
if (is_numeric($vars['device'])) {
|
||||
$sqlstatement = $sqlstatement . ' WHERE device_id=?';
|
||||
$param[] = $vars['device'];
|
||||
}
|
||||
$sqlstatement = $sqlstatement .' ORDER BY `level`';
|
||||
foreach (dbFetchRows($sqlstatement, $param) as $data) {
|
||||
echo '"<option value="'.mres($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">
|
||||
<input name="to" type="text" class="form-control input-sm" id="dtpickerto" maxlength="16" value="<?php echo $vars['to']; ?>" placeholder="To" data-date-format="YYYY-MM-DD HH:mm">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default input-sm">Filter</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-3 actionBar">
|
||||
<p class="{{css.actions}}"></p>
|
||||
</div>
|
||||
<div class="panel panel-default panel-condensed">
|
||||
<div class="panel-heading">
|
||||
<strong>Syslog</strong>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require_once 'includes/common/syslog.inc.php';
|
||||
echo implode('', $common_output);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
$("#dtpickerfrom").datetimepicker({
|
||||
icons: {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-calendar-check-o',
|
||||
clear: 'fa fa-trash-o',
|
||||
close: 'fa fa-close'
|
||||
$('.actionBar').append(
|
||||
'<div class="pull-left">' +
|
||||
'<form method="post" action="" class="form-inline" role="form" id="result_form">' +
|
||||
'<div class="form-group">' +
|
||||
<?php
|
||||
if (!is_numeric($vars['device'])) {
|
||||
?>
|
||||
'<select name="device" id="device" class="form-control input-sm">' +
|
||||
'<option value="">All Devices </option>' +
|
||||
<?php
|
||||
foreach (get_all_devices() as $data) {
|
||||
if (device_permitted($data['device_id'])) {
|
||||
echo "'<option value=\"" . $data['device_id'] . "\"";
|
||||
if ($data['device_id'] == $vars['device']) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo ">" . format_hostname($data) . "</option>' + ";
|
||||
}
|
||||
}
|
||||
?>
|
||||
'</select>' +
|
||||
<?php
|
||||
} else {
|
||||
echo "' <input type=\"hidden\" name=\"device\" id=\"device\" value=\"" . $vars['device'] . "\">' + ";
|
||||
}
|
||||
?>
|
||||
'</div>' +
|
||||
' <div class="form-group">' +
|
||||
'<select name="program" id="program" class="form-control input-sm">' +
|
||||
'<option value="">All Programs </option>' +
|
||||
<?php
|
||||
$sqlstatement = 'SELECT DISTINCT `program` FROM `syslog`';
|
||||
if (is_numeric($vars['device'])) {
|
||||
$sqlstatement = $sqlstatement . ' WHERE device_id=?';
|
||||
$param[] = $vars['device'];
|
||||
}
|
||||
$sqlstatement = $sqlstatement . ' ORDER BY `program`';
|
||||
foreach (dbFetchRows($sqlstatement, $param) as $data) {
|
||||
echo "'<option value=\"" . mres($data['program']) . "\"";
|
||||
if ($data['program'] == $vars['program']) {
|
||||
echo ' selected';
|
||||
}
|
||||
echo ">" . $data['program'] . "</option>' + ";
|
||||
}
|
||||
?>
|
||||
'</select>' +
|
||||
'</div>' +
|
||||
' <div class="form-group">' +
|
||||
'<select name="priority" id="priority" class="form-control input-sm">' +
|
||||
'<option value="">All Priorities</option>' +
|
||||
<?php
|
||||
$sqlstatement = 'SELECT DISTINCT `priority` FROM `syslog`';
|
||||
if (is_numeric($vars['device'])) {
|
||||
$sqlstatement = $sqlstatement . ' WHERE device_id=?';
|
||||
$param[] = $vars['device'];
|
||||
}
|
||||
$sqlstatement = $sqlstatement . ' ORDER BY `level`';
|
||||
foreach (dbFetchRows($sqlstatement, $param) as $data) {
|
||||
echo "'<option value=\"" . mres($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">' +
|
||||
' <input name="to" type="text" class="form-control input-sm" id="dtpickerto" maxlength="16" value="<?php echo $vars['to']; ?>" placeholder="To" data-date-format="YYYY-MM-DD HH:mm">' +
|
||||
'</div>' +
|
||||
' <button type="submit" class="btn btn-default input-sm">Filter</button>' +
|
||||
'</form>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
);
|
||||
|
||||
$(function () {
|
||||
$("#dtpickerfrom").datetimepicker({
|
||||
icons: {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-calendar-check-o',
|
||||
clear: 'fa fa-trash-o',
|
||||
close: 'fa fa-close'
|
||||
}
|
||||
});
|
||||
$("#dtpickerfrom").on("dp.change", function (e) {
|
||||
$("#dtpickerto").data("DateTimePicker").minDate(e.date);
|
||||
});
|
||||
$("#dtpickerto").datetimepicker({
|
||||
icons: {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-calendar-check-o',
|
||||
clear: 'fa fa-trash-o',
|
||||
close: 'fa fa-close'
|
||||
}
|
||||
});
|
||||
$("#dtpickerto").on("dp.change", function (e) {
|
||||
$("#dtpickerfrom").data("DateTimePicker").maxDate(e.date);
|
||||
});
|
||||
if ($("#dtpickerfrom").val() != "") {
|
||||
$("#dtpickerto").data("DateTimePicker").minDate($("#dtpickerfrom").val());
|
||||
}
|
||||
if ($("#dtpickerto").val() != "") {
|
||||
$("#dtpickerfrom").data("DateTimePicker").maxDate($("#dtpickerto").val());
|
||||
} else {
|
||||
$("#dtpickerto").data("DateTimePicker").maxDate('<?php echo date($config['dateformat']['byminute']); ?>');
|
||||
}
|
||||
});
|
||||
$("#dtpickerfrom").on("dp.change", function (e) {
|
||||
$("#dtpickerto").data("DateTimePicker").minDate(e.date);
|
||||
});
|
||||
$("#dtpickerto").datetimepicker({
|
||||
icons: {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down',
|
||||
previous: 'fa fa-chevron-left',
|
||||
next: 'fa fa-chevron-right',
|
||||
today: 'fa fa-calendar-check-o',
|
||||
clear: 'fa fa-trash-o',
|
||||
close: 'fa fa-close'
|
||||
}
|
||||
});
|
||||
$("#dtpickerto").on("dp.change", function (e) {
|
||||
$("#dtpickerfrom").data("DateTimePicker").maxDate(e.date);
|
||||
});
|
||||
if( $("#dtpickerfrom").val() != "" ) {
|
||||
$("#dtpickerto").data("DateTimePicker").minDate($("#dtpickerfrom").val());
|
||||
}
|
||||
if( $("#dtpickerto").val() != "" ) {
|
||||
$("#dtpickerfrom").data("DateTimePicker").maxDate($("#dtpickerto").val());
|
||||
} else {
|
||||
$("#dtpickerto").data("DateTimePicker").maxDate('<?php echo date($config['dateformat']['byminute']); ?>');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
print_optionbar_end();
|
||||
require_once 'includes/common/syslog.inc.php';
|
||||
echo implode('', $common_output);
|
||||
?>
|
||||
|
||||
|
||||
@@ -20,22 +20,22 @@ use LibreNMS\Config;
|
||||
use LibreNMS\Exceptions\InvalidIpException;
|
||||
use LibreNMS\Util\IP;
|
||||
|
||||
function generate_priority_icon($priority)
|
||||
function generate_priority_label($priority)
|
||||
{
|
||||
$map = array(
|
||||
"emerg" => "fa-plus-circle text-danger",
|
||||
"alert" => "fa-ban text-danger",
|
||||
"crit" => "fa-minus-circle text-danger",
|
||||
"err" => "fa-times-circle text-warning",
|
||||
"warning" => "fa-exclamation-triangle text-warning",
|
||||
"notice" => "fa-info-circle text-info",
|
||||
"info" => "fa-info-circle text-info",
|
||||
"debug" => "fa-bug text-muted",
|
||||
"" => "fa-info-circle text-info",
|
||||
"emerg" => "label-danger",
|
||||
"alert" => "label-danger",
|
||||
"crit" => "label-danger",
|
||||
"err" => "label-danger",
|
||||
"warning" => "label-warning",
|
||||
"notice" => "label-info",
|
||||
"info" => "label-info",
|
||||
"debug" => "label-default",
|
||||
"" => "label-info",
|
||||
);
|
||||
|
||||
$fa_icon = isset($map[$priority]) ? $map[$priority] : 'fa-info-circle text-info';
|
||||
return '<i class="fa '. $fa_icon.' fa-lg" title="'.$priority.'" aria-hidden="true"></i>';
|
||||
$barColor = isset($map[$priority]) ? $map[$priority] : 'label-info';
|
||||
return '<span class="alert-status '.$barColor .'"> </span>';
|
||||
}
|
||||
|
||||
function generate_priority_status($priority)
|
||||
|
||||
Reference in New Issue
Block a user