mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-04 16:12:20 +02:00
Merge pull request #246 from bohdan-s/statuspage
Public status page for all active devices
This commit is contained in:
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of LibreNMS
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 Bohdan Sanders <http://bohdans.com/>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if ($bg == $list_colour_b) { $bg = $list_colour_a; } else { $bg = $list_colour_b; }
|
||||||
|
|
||||||
|
if ($device['status'] == '0')
|
||||||
|
{
|
||||||
|
$class = "bg-danger";
|
||||||
|
} else {
|
||||||
|
$class = "bg-primary";
|
||||||
|
}
|
||||||
|
if ($device['ignore'] == '1')
|
||||||
|
{
|
||||||
|
$class = "bg-warning";
|
||||||
|
if ($device['status'] == '1')
|
||||||
|
{
|
||||||
|
$class = "bg-success";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($device['disabled'] == '1')
|
||||||
|
{
|
||||||
|
$class = "bg-info";
|
||||||
|
}
|
||||||
|
|
||||||
|
$type = strtolower($device['os']);
|
||||||
|
|
||||||
|
if ($device['os'] == "ios") { formatCiscoHardware($device, true); }
|
||||||
|
$device['os_text'] = $config['os'][$device['os']]['text'];
|
||||||
|
|
||||||
|
echo(' <tr>
|
||||||
|
<td class="'. $class .' "></td>
|
||||||
|
<td>' . $image . '</td>
|
||||||
|
<td><span style="font-size: 15px;">' . generate_device_link($device) . '</span></td>'
|
||||||
|
);
|
||||||
|
|
||||||
|
echo('<td>');
|
||||||
|
if ($port_count) { echo(' <img src="images/icons/port.png" align=absmiddle /> '.$port_count); }
|
||||||
|
echo('<br />');
|
||||||
|
if ($sensor_count) { echo(' <img src="images/icons/sensors.png" align=absmiddle /> '.$sensor_count); }
|
||||||
|
echo('</td>');
|
||||||
|
echo(' <td>' . $device['hardware'] . ' ' . $device['features'] . '</td>');
|
||||||
|
echo(' <td>' . formatUptime($device['uptime'], 'short') . ' <br />');
|
||||||
|
|
||||||
|
if (get_dev_attrib($device,'override_sysLocation_bool')) { $device['location'] = get_dev_attrib($device,'override_sysLocation_string'); }
|
||||||
|
echo(' ' . truncate($device['location'],32, '') . '</td>');
|
||||||
|
|
||||||
|
echo(' </tr>');
|
||||||
|
|
||||||
|
?>
|
||||||
+26
-5
@@ -163,19 +163,24 @@ if (!$vars['bare'] == "yes") {
|
|||||||
if ($_SESSION['authenticated'])
|
if ($_SESSION['authenticated'])
|
||||||
{
|
{
|
||||||
include("includes/print-menubar.php");
|
include("includes/print-menubar.php");
|
||||||
} else {
|
|
||||||
echo('<hr color="#444444" />');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<br />
|
<br />
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
<?php
|
||||||
|
if ($_SESSION['authenticated'])
|
||||||
|
{
|
||||||
|
?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<br /><br />
|
<br /><br />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
?>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<?php
|
<?php
|
||||||
@@ -205,10 +210,26 @@ if ($_SESSION['authenticated'])
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Not Authenticated. Print login.
|
// Not Authenticated. Show status page if enabled
|
||||||
|
if ( $config['public_status'] === true )
|
||||||
|
{
|
||||||
|
if (isset($vars['page']) && strstr("login", $vars['page']))
|
||||||
|
{
|
||||||
include("pages/logon.inc.php");
|
include("pages/logon.inc.php");
|
||||||
|
} else {
|
||||||
exit;
|
echo '<div id="public-status">';
|
||||||
|
include("pages/public.inc.php");
|
||||||
|
echo '</div>';
|
||||||
|
echo '<div id="public-logon" style="display:none;">';
|
||||||
|
echo '<div class="well"><h3>Logon<button class="btn btn-default" type="submit" style="float:right;" id="ToggleStatus">Status</button></h3></div>';
|
||||||
|
include ("pages/logon.inc.php");
|
||||||
|
echo '</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
include("pages/logon.inc.php");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of LibreNMS
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 Bohdan Sanders <http://bohdans.com/>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script class="code" type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("#ToggleLogon").click( function()
|
||||||
|
{
|
||||||
|
document.getElementById('public-logon').style.display="block";
|
||||||
|
document.getElementById('public-status').style.display="none";
|
||||||
|
});
|
||||||
|
$("#ToggleStatus").click( function()
|
||||||
|
{
|
||||||
|
document.getElementById('public-logon').style.display="none";
|
||||||
|
document.getElementById('public-status').style.display="block";
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// Set Defaults here
|
||||||
|
|
||||||
|
$sql_param = array();
|
||||||
|
$pagetitle[] = "Public Devices";
|
||||||
|
|
||||||
|
$query = "SELECT * FROM `devices` WHERE 1 AND disabled='0' AND `ignore`='0' ORDER BY hostname";
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="well"><h3>System Status<button class="btn btn-default" type="submit" style="float:right;" id="ToggleLogon">Logon</button></h3></div>
|
||||||
|
<div class="panel panel-default panel-condensed">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-condensed">
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th></th>
|
||||||
|
<th>Device</th>
|
||||||
|
<th></th>
|
||||||
|
<th>Platform</th>
|
||||||
|
<th>Uptime/Location</th>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
foreach (dbFetchRows($query, $sql_param) as $device)
|
||||||
|
{
|
||||||
|
include("includes/hostbox-public.inc.php");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -118,6 +118,7 @@ $config['page_title_suffix'] = $config['project_name'];
|
|||||||
$config['timestamp_format'] = 'd-m-Y H:i:s';
|
$config['timestamp_format'] = 'd-m-Y H:i:s';
|
||||||
$config['page_gen'] = 0; # display MySqL & PHP stats in footer?
|
$config['page_gen'] = 0; # display MySqL & PHP stats in footer?
|
||||||
$config['login_message'] = "Unauthorised access or use shall render the user liable to criminal and/or civil prosecution.";
|
$config['login_message'] = "Unauthorised access or use shall render the user liable to criminal and/or civil prosecution.";
|
||||||
|
$config['public_status'] = false; // Enable public accessable status page
|
||||||
|
|
||||||
$config['old_graphs'] = 1; // RRDfiles from before the great rra reform. This is default for a while.
|
$config['old_graphs'] = 1; // RRDfiles from before the great rra reform. This is default for a while.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user