mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Added Syslog, Eventlog and Globe Map widgets
This commit is contained in:
29
html/includes/common/eventlog.inc.php
Normal file
29
html/includes/common/eventlog.inc.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$common_output[] = '
|
||||||
|
<table id="eventlog" class="table table-hover table-condensed table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th data-column-id="datetime" data-order="desc">Datetime</th>
|
||||||
|
<th data-column-id="hostname">Hostname</th>
|
||||||
|
<th data-column-id="type">Type</th>
|
||||||
|
<th data-column-id="message">Message</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
var grid = $("#eventlog").bootgrid({
|
||||||
|
ajax: true,
|
||||||
|
post: function ()
|
||||||
|
{
|
||||||
|
return {
|
||||||
|
id: "eventlog",
|
||||||
|
};
|
||||||
|
},
|
||||||
|
url: "/ajax_table.php"
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
';
|
29
html/includes/common/syslog.inc.php
Normal file
29
html/includes/common/syslog.inc.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
|
||||||
|
$query = mysql_query($sql);
|
||||||
|
|
||||||
|
$syslog_output = '
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="panel panel-default panel-condensed">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<strong>Syslog entries</strong>
|
||||||
|
</div>
|
||||||
|
<table class="table table-hover table-condensed table-striped">';
|
||||||
|
|
||||||
|
foreach (dbFetchRows($sql) as $entry) {
|
||||||
|
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
||||||
|
include 'includes/print-syslog.inc.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
$syslog_output .= '
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
$common_output[] = $syslog_output;
|
74
html/includes/common/worldmap.inc.php
Normal file
74
html/includes/common/worldmap.inc.php
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2014 Daniel Preussker <f0o@devilcode.org>
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Custom Frontpage
|
||||||
|
* @author f0o <f0o@devilcode.org>
|
||||||
|
* @copyright 2014 f0o, LibreNMS
|
||||||
|
* @license GPL
|
||||||
|
* @package LibreNMS
|
||||||
|
* @subpackage Frontpage
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($config['map']['engine'] == 'leaflet') {
|
||||||
|
|
||||||
|
$temp_output = '
|
||||||
|
<script src="js/leaflet.js"></script>
|
||||||
|
<script src="js/leaflet.markercluster-src.js"></script>
|
||||||
|
<script src="js/leaflet.awesome-markers.min.js"></script>
|
||||||
|
<div id="leaflet-map"></div>
|
||||||
|
<script>
|
||||||
|
';
|
||||||
|
|
||||||
|
$map_init = "[" . $config['leaflet']['default_lat'] . ", " . $config['leaflet']['default_lng'] . "], " . sprintf("%01.0f", $config['leaflet']['default_zoom']);
|
||||||
|
|
||||||
|
$temp_output .= 'var map = L.map(\'leaflet-map\').setView('.$map_init.');
|
||||||
|
|
||||||
|
L.tileLayer(\'//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {
|
||||||
|
attribution: \'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors\'
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
|
var markers = L.markerClusterGroup();
|
||||||
|
var redMarker = L.AwesomeMarkers.icon({
|
||||||
|
icon: \'server\',
|
||||||
|
markerColor: \'red\', prefix: \'fa\', iconColor: \'white\'
|
||||||
|
});
|
||||||
|
var greenMarker = L.AwesomeMarkers.icon({
|
||||||
|
icon: \'server\',
|
||||||
|
markerColor: \'green\', prefix: \'fa\', iconColor: \'white\'
|
||||||
|
});
|
||||||
|
';
|
||||||
|
|
||||||
|
foreach (dbFetchRows("SELECT `device_id`,`hostname`,`os`,`status`,`lat`,`lng` FROM `devices` LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location` WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != '' ORDER BY `status` ASC, `hostname`") as $map_devices) {
|
||||||
|
$icon = 'greenMarker';
|
||||||
|
if ($map_devices['status'] == 0) {
|
||||||
|
$icon = 'redMarker';
|
||||||
|
}
|
||||||
|
|
||||||
|
$temp_output .= "var title = '<a href=\"" . generate_device_url($map_devices) . "\"><img src=\"".getImageSrc($map_devices)."\" width=\"32\" height=\"32\" alt=\"\">".$map_devices['hostname']."</a>';
|
||||||
|
var marker = L.marker(new L.LatLng(".$map_devices['lat'].", ".$map_devices['lng']."), {title: title, icon: $icon});
|
||||||
|
marker.bindPopup(title);
|
||||||
|
markers.addLayer(marker);\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$temp_output .= 'map.addLayer(markers);
|
||||||
|
</script>';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$temp_output = 'Mapael engine not supported here';
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($common_output);
|
||||||
|
$common_output[] = $temp_output;
|
@@ -1,18 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (device_permitted($entry['device_id'])) {
|
if (device_permitted($entry['device_id'])) {
|
||||||
echo '<tr>';
|
$syslog_output .= '<tr>';
|
||||||
|
|
||||||
// Stop shortening hostname. Issue #61
|
// Stop shortening hostname. Issue #61
|
||||||
// $entry['hostname'] = shorthost($entry['hostname'], 20);
|
// $entry['hostname'] = shorthost($entry['hostname'], 20);
|
||||||
if ($vars['page'] != 'device') {
|
if ($vars['page'] != 'device') {
|
||||||
echo '<td>'.$entry['date'].'</td>';
|
$syslog_output .= '<td>'.$entry['date'].'</td>
|
||||||
echo '<td><strong>'.generate_device_link($entry).'</strong></td>';
|
<td><strong>'.generate_device_link($entry).'</strong></td>
|
||||||
echo '<td><strong>'.$entry['program'].' : </strong> '.htmlspecialchars($entry['msg']).'</td>';
|
<td><strong>'.$entry['program'].' : </strong> '.htmlspecialchars($entry['msg']).'</td>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo '<td><i>'.$entry['date'].'</i> <strong>'.$entry['program'].'</strong> '.htmlspecialchars($entry['msg']).'</td>';
|
$syslog_output .= '<td><i>'.$entry['date'].'</i> <strong>'.$entry['program'].'</strong> '.htmlspecialchars($entry['msg']).'</td>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</tr>';
|
$syslog_output .= '</tr>';
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,9 @@ echo ' <div class="panel panel-default panel-condensed">
|
|||||||
</div>
|
</div>
|
||||||
<table class="table table-hover table-condensed table-striped">';
|
<table class="table table-hover table-condensed table-striped">';
|
||||||
foreach (dbFetchRows($sql, $param) as $entry) {
|
foreach (dbFetchRows($sql, $param) as $entry) {
|
||||||
|
unset($syslog_output);
|
||||||
include 'includes/print-syslog.inc.php';
|
include 'includes/print-syslog.inc.php';
|
||||||
|
echo $syslog_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ' </table>
|
echo ' </table>
|
||||||
|
@@ -12,7 +12,9 @@ if ($config['enable_syslog']) {
|
|||||||
echo ' </div>
|
echo ' </div>
|
||||||
<table class="table table-hover table-condensed table-striped">';
|
<table class="table table-hover table-condensed table-striped">';
|
||||||
foreach ($syslog as $entry) {
|
foreach ($syslog as $entry) {
|
||||||
|
unset($syslog_output);
|
||||||
include 'includes/print-syslog.inc.php';
|
include 'includes/print-syslog.inc.php';
|
||||||
|
echo $syslog_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
@@ -42,31 +42,9 @@ print_optionbar_start();
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
print_optionbar_end();
|
print_optionbar_end();
|
||||||
|
|
||||||
|
require_once 'includes/common/eventlog.inc.php';
|
||||||
|
echo implode('',$common_output);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<table id="eventlog" class="table table-hover table-condensed table-striped">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th data-column-id="datetime" data-order="desc">Datetime</th>
|
|
||||||
<th data-column-id="hostname">Hostname</th>
|
|
||||||
<th data-column-id="type">Type</th>
|
|
||||||
<th data-column-id="message">Message</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
|
|
||||||
var grid = $("#eventlog").bootgrid({
|
|
||||||
ajax: true,
|
|
||||||
post: function ()
|
|
||||||
{
|
|
||||||
return {
|
|
||||||
id: "eventlog",
|
|
||||||
device: '<?php echo htmlspecialchars($_POST['device']); ?>'
|
|
||||||
};
|
|
||||||
},
|
|
||||||
url: "/ajax_table.php"
|
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
@@ -192,7 +192,9 @@ if ($config['enable_syslog']) {
|
|||||||
foreach (dbFetchRows($sql) as $entry) {
|
foreach (dbFetchRows($sql) as $entry) {
|
||||||
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
||||||
|
|
||||||
|
unset($syslog_output);
|
||||||
include 'includes/print-syslog.inc.php';
|
include 'includes/print-syslog.inc.php';
|
||||||
|
echo $syslog_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
@@ -156,7 +156,9 @@ echo '<table cellspacing=0 cellpadding=2 width=100%>';
|
|||||||
foreach (dbFetchRows($sql) as $entry) {
|
foreach (dbFetchRows($sql) as $entry) {
|
||||||
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
||||||
|
|
||||||
|
unset($syslog_output);
|
||||||
include 'includes/print-syslog.inc.php';
|
include 'includes/print-syslog.inc.php';
|
||||||
|
echo $syslog_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
@@ -89,7 +89,9 @@ echo "
|
|||||||
$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
|
$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog ORDER BY timestamp DESC LIMIT 20";
|
||||||
echo '<table cellspacing=0 cellpadding=2 width=100%>';
|
echo '<table cellspacing=0 cellpadding=2 width=100%>';
|
||||||
foreach (dbFetchRows($sql) as $entry) {
|
foreach (dbFetchRows($sql) as $entry) {
|
||||||
|
unset($syslog_output);
|
||||||
include 'includes/print-syslog.inc.php';
|
include 'includes/print-syslog.inc.php';
|
||||||
|
echo $syslog_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
@@ -86,7 +86,9 @@ if ($config['enable_syslog']) {
|
|||||||
foreach (dbFetchRows($sql) as $entry) {
|
foreach (dbFetchRows($sql) as $entry) {
|
||||||
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
||||||
|
|
||||||
|
unset($syslog_output);
|
||||||
include 'includes/print-syslog.inc.php';
|
include 'includes/print-syslog.inc.php';
|
||||||
|
echo $syslog_output;
|
||||||
}
|
}
|
||||||
echo("</table>");
|
echo("</table>");
|
||||||
echo("</div>");
|
echo("</div>");
|
||||||
|
@@ -102,7 +102,9 @@ echo "
|
|||||||
$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
|
$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
|
||||||
echo '<table cellspacing=0 cellpadding=2 width=100%>';
|
echo '<table cellspacing=0 cellpadding=2 width=100%>';
|
||||||
foreach (dbFetchRows($sql) as $entry) {
|
foreach (dbFetchRows($sql) as $entry) {
|
||||||
|
unset($syslog_output);
|
||||||
include 'includes/print-syslog.inc.php';
|
include 'includes/print-syslog.inc.php';
|
||||||
|
echo $syslog_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
@@ -23,50 +23,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ($config['map']['engine'] == 'leaflet') {
|
if ($config['map']['engine'] == 'leaflet') {
|
||||||
?>
|
require_once 'includes/common/worldmap.inc.php';
|
||||||
<script src="js/leaflet.js"></script>
|
echo implode('',$common_output);
|
||||||
<script src="js/leaflet.markercluster-src.js"></script>
|
|
||||||
<script src="js/leaflet.awesome-markers.min.js"></script>
|
|
||||||
<div id="leaflet-map"></div>
|
|
||||||
<script>
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$map_init = "[" . $config['leaflet']['default_lat'] . ", " . $config['leaflet']['default_lng'] . "], " . sprintf("%01.0f", $config['leaflet']['default_zoom']);
|
|
||||||
|
|
||||||
?>
|
|
||||||
var map = L.map('leaflet-map').setView(<?php echo $map_init; ?>);
|
|
||||||
|
|
||||||
L.tileLayer('//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
||||||
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
|
||||||
}).addTo(map);
|
|
||||||
|
|
||||||
var markers = L.markerClusterGroup();
|
|
||||||
var redMarker = L.AwesomeMarkers.icon({
|
|
||||||
icon: 'server',
|
|
||||||
markerColor: 'red', prefix: 'fa', iconColor: 'white'
|
|
||||||
});
|
|
||||||
var greenMarker = L.AwesomeMarkers.icon({
|
|
||||||
icon: 'server',
|
|
||||||
markerColor: 'green', prefix: 'fa', iconColor: 'white'
|
|
||||||
});
|
|
||||||
|
|
||||||
<?php
|
|
||||||
foreach (dbFetchRows("SELECT `device_id`,`hostname`,`os`,`status`,`lat`,`lng` FROM `devices` LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location` WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != '' ORDER BY `status` ASC, `hostname`") as $map_devices) {
|
|
||||||
$icon = 'greenMarker';
|
|
||||||
if ($map_devices['status'] == 0) {
|
|
||||||
$icon = 'redMarker';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "var title = '<a href=\"" . generate_device_url($map_devices) . "\"><img src=\"".getImageSrc($map_devices)."\" width=\"32\" height=\"32\" alt=\"\">".$map_devices['hostname']."</a>';
|
|
||||||
var marker = L.marker(new L.LatLng(".$map_devices['lat'].", ".$map_devices['lng']."), {title: title, icon: $icon});
|
|
||||||
marker.bindPopup(title);
|
|
||||||
markers.addLayer(marker);\n";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
map.addLayer(markers);
|
|
||||||
</script>
|
|
||||||
<?php
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (isset($config['mapael']['default_map']) && is_file($config['html_dir'].'/js/'.$config['mapael']['default_map'])) {
|
if (isset($config['mapael']['default_map']) && is_file($config['html_dir'].'/js/'.$config['mapael']['default_map'])) {
|
||||||
@@ -216,7 +174,9 @@ echo('<div class="container-fluid">
|
|||||||
{
|
{
|
||||||
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
$entry = array_merge($entry, device_by_id_cache($entry['device_id']));
|
||||||
|
|
||||||
|
unset($syslog_output);
|
||||||
include("includes/print-syslog.inc.php");
|
include("includes/print-syslog.inc.php");
|
||||||
|
echo $syslog_output;
|
||||||
}
|
}
|
||||||
echo("</table>");
|
echo("</table>");
|
||||||
echo("</div>");
|
echo("</div>");
|
||||||
@@ -250,10 +210,9 @@ echo('<div class="container-fluid">
|
|||||||
</div>
|
</div>
|
||||||
<table class="table table-hover table-condensed table-striped">');
|
<table class="table table-hover table-condensed table-striped">');
|
||||||
|
|
||||||
foreach (dbFetchRows($query) as $entry)
|
foreach (dbFetchRows($query) as $entry) {
|
||||||
{
|
include 'includes/print-event.inc.php';
|
||||||
include("includes/print-event.inc.php");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
echo("</table>");
|
echo("</table>");
|
||||||
echo("</div>");
|
echo("</div>");
|
||||||
|
@@ -96,7 +96,9 @@ echo "
|
|||||||
$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
|
$sql = "SELECT *, DATE_FORMAT(timestamp, '".$config['dateformat']['mysql']['compact']."') AS date from syslog,devices WHERE syslog.device_id = devices.device_id ORDER BY seq DESC LIMIT 20";
|
||||||
echo '<table cellspacing=0 cellpadding=2 width=100%>';
|
echo '<table cellspacing=0 cellpadding=2 width=100%>';
|
||||||
foreach (dbFetchRows($sql) as $entry) {
|
foreach (dbFetchRows($sql) as $entry) {
|
||||||
|
unset($syslog_output);
|
||||||
include 'includes/print-syslog.inc.php';
|
include 'includes/print-syslog.inc.php';
|
||||||
|
echo $syslog_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</table>';
|
echo '</table>';
|
||||||
|
1
sql-schema/060.sql
Normal file
1
sql-schema/060.sql
Normal file
@@ -0,0 +1 @@
|
|||||||
|
INSERT INTO `widgets` (`widget_title`, `widget`, `base_dimensions`) VALUES ('Syslog', 'syslog', '9,3'), ('Eventlog', 'eventlog', '9,5'), ('Global Map', 'worldmap', '8,6');
|
Reference in New Issue
Block a user