Files
librenms-librenms/html/includes/common/syslog.inc.php

112 lines
4.2 KiB
PHP
Raw Normal View History

<?php
2015-08-19 17:04:11 +02:00
$no_refresh = true;
2015-08-19 18:03:43 +02:00
2015-08-19 17:04:11 +02:00
$param = array();
2015-08-19 18:03:43 +02:00
2015-08-19 17:04:11 +02:00
if ($vars['action'] == 'expunge' && $_SESSION['userlevel'] >= '10') {
dbQuery('TRUNCATE TABLE `syslog`');
print_message('syslog truncated');
}
2015-08-19 18:03:43 +02:00
2015-08-19 17:04:11 +02:00
$pagetitle[] = 'Syslog';
2015-08-20 11:31:00 +02:00
$syslog_output = '
2015-08-19 17:04:11 +02:00
<div class="table-responsive">
<table id="syslog" class="table table-hover table-condensed table-striped">
2015-08-18 18:52:57 +02:00
<thead>
<tr>
2015-08-18 19:03:59 +02:00
<th data-column-id="timestamp" data-order="desc">Datetime</th>
<th data-column-id="device_id">Hostname</th>
2015-08-18 18:52:57 +02:00
<th data-column-id="program">Program</th>
2015-08-18 19:03:59 +02:00
<th data-column-id="msg">Message</th>
2015-08-18 18:52:57 +02:00
</tr>
</thead>
</table>
2015-08-19 17:04:11 +02:00
</div>
2015-08-18 18:52:57 +02:00
<script>
2015-08-19 18:03:43 +02:00
2015-08-19 17:04:11 +02:00
var grid = $("#syslog").bootgrid({
2015-08-18 18:52:57 +02:00
ajax: true,
2015-08-19 17:04:11 +02:00
templates: {
header: "<div id=\"{{ctx.id}}\" class=\"{{css.header}}\"><div class=\"row\">"+
"<div class=\"col-sm-9 actionBar\"><span class=\"pull-left\">"+
"<form method=\"post\" action=\"\" class=\"form-inline\" role=\"form\" id=\"result_form\">"+
"<div class=\"form-group\">"+
"<select name=\"device\" id=\"device\" class=\"form-control input-sm\">"+
"<option value=\"\">All Devices</option>"+
2015-08-20 11:31:00 +02:00
';
2015-08-19 17:04:11 +02:00
foreach (get_all_devices() as $hostname) {
$device_id = getidbyname($hostname);
if (device_permitted($device_id)) {
echo '"<option value=\"'.$device_id.'\"';
if ($device_id == $vars['device']) {
echo ' selected';
}
2015-08-19 18:03:43 +02:00
2015-08-19 17:04:11 +02:00
echo '>'.$hostname.'</option>"+';
}
}
2015-08-20 11:31:00 +02:00
$syslog_output .= '
2015-08-19 17:04:11 +02:00
"</select>"+
"</div>"+
"<div class=\"form-group\">"+
"<select name=\"program\" id=\"program\" class=\"form-control input-sm\">"+
"<option value=\"\">All Programs</option>"+
2015-08-20 11:31:00 +02:00
';
2015-08-19 17:04:11 +02:00
foreach (dbFetchRows('SELECT DISTINCT `program` FROM `syslog` ORDER BY `program`') as $data) {
echo '"<option value=\"'.$data['program'].'\"';
if ($data['program'] == $vars['program']) {
echo ' selected';
}
2015-08-19 18:03:43 +02:00
2015-08-19 17:04:11 +02:00
echo '>'.$data['program'].'</option>"+';
}
2015-08-20 11:31:00 +02:00
$syslog_output .= '
2015-08-19 17:04:11 +02:00
"</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></span></div>"+
"<div class=\"col-sm-3 actionBar\"><p class=\"{{css.actions}}\"></p></div></div></div>"
2015-08-19 18:03:43 +02:00
2015-08-19 17:04:11 +02:00
},
2015-08-18 18:52:57 +02:00
post: function ()
{
return {
id: "syslog",
2015-08-20 11:31:00 +02:00
device: "' .mres($vars['device']) .'",
program: "' .mres($vars['program']) .'",
to: "' .mres($vars['to']) .'",
from: "' .mres($vars['from']) .'",
2015-08-18 18:52:57 +02:00
};
},
url: "ajax_table.php"
});
2015-08-19 18:03:43 +02:00
2015-08-19 17:04:11 +02:00
$(function () {
$("#dtpickerfrom").datetimepicker();
$("#dtpickerfrom").on("dp.change", function (e) {
$("#dtpickerto").data("DateTimePicker").minDate(e.date);
});
$("#dtpickerto").datetimepicker();
$("#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 {
2015-08-20 11:31:00 +02:00
$("#dtpickerto").data("DateTimePicker").maxDate("'.mres($config['dateformat']['byminute']) .')";
2015-08-19 17:04:11 +02:00
}
});
2015-08-18 18:52:57 +02:00
</script>
2015-08-20 11:31:00 +02:00
';
$common_output[] = $syslog_output;