Merge pull request #2536 from paulgear/mib-poller-alpha2

MIB-based poller alpha2
This commit is contained in:
Neil Lathwood
2016-01-06 09:08:56 +00:00
42 changed files with 1371 additions and 478 deletions
+13 -1
View File
@@ -57,7 +57,11 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) {
</a>
</li>';
$health = (dbFetchCell("SELECT COUNT(*) FROM storage WHERE device_id = '".$device['device_id']."'") + dbFetchCell("SELECT COUNT(sensor_id) FROM sensors WHERE device_id = '".$device['device_id']."'") + dbFetchCell("SELECT COUNT(*) FROM mempools WHERE device_id = '".$device['device_id']."'") + dbFetchCell("SELECT COUNT(*) FROM processors WHERE device_id = '".$device['device_id']."'"));
$health = dbFetchCell("SELECT COUNT(*) FROM storage WHERE device_id = '" . $device['device_id'] . "'") +
dbFetchCell("SELECT COUNT(sensor_id) FROM sensors WHERE device_id = '" . $device['device_id'] . "'") +
dbFetchCell("SELECT COUNT(*) FROM mempools WHERE device_id = '" . $device['device_id'] . "'") +
dbFetchCell("SELECT COUNT(*) FROM processors WHERE device_id = '" . $device['device_id'] . "'") +
count_mib_health($device);
if ($health) {
echo '<li class="'.$select['health'].'">
@@ -367,6 +371,14 @@ if (device_permitted($vars['device']) || $check_device == $vars['device']) {
</a>
</li>';
if (device_permitted($device['device_id'])) {
echo '<li class="'.$select['mib'].'">
<a href="'.generate_device_url($device, array('tab' => 'mib')).'">
<i class="fa fa-file-text-o"></i> MIB
</a>
</li>';
}
echo '<li style="float: right;"><a href="https://'.$device['hostname'].'"><img src="images/16/http.png" alt="https" title="Launch browser to https://'.$device['hostname'].'" border="0" width="16" height="16" target="_blank"></a></li>
<li style="float: right;"><a href="ssh://'.$device['hostname'].'"><img src="images/16/ssh.png" alt="ssh" title="SSH to '.$device['hostname'].'" border="0" width="16" height="16"></a></li>
+1 -6
View File
@@ -22,11 +22,7 @@ foreach (dbFetchRows('SELECT * FROM device_graphs WHERE device_id = ? ORDER BY g
}
}
// These are standard graphs we should have for all systems
$graph_enable['poller']['poller_perf'] = 'device_poller_perf';
if (can_ping_device($attribs) === true) {
$graph_enable['poller']['ping_perf'] = 'device_ping_perf';
}
enable_graphs($device, $graph_enable);
$sep = '';
foreach ($graph_enable as $section => $nothing) {
@@ -56,7 +52,6 @@ print_optionbar_end();
$graph_enable = $graph_enable[$vars['group']];
// foreach ($config['graph_types']['device'] as $graph => $entry)
foreach ($graph_enable as $graph => $entry) {
$graph_array = array();
if ($graph_enable[$graph]) {
-8
View File
@@ -1,8 +0,0 @@
<?php
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/ucd_cpu.rrd')) {
$graph_title = 'Processor Utilisation';
$graph_type = 'device_cpu';
include 'includes/print-device-graph.php';
}
@@ -1,8 +0,0 @@
<?php
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/hrSystem.rrd')) {
$graph_title = 'Running Processes';
$graph_type = 'device_hrprocesses';
include 'includes/print-device-graph.php';
}
-8
View File
@@ -1,8 +0,0 @@
<?php
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/hrSystem.rrd')) {
$graph_title = 'Users Logged On';
$graph_type = 'device_hrusers';
include 'includes/print-device-graph.php';
}
-70
View File
@@ -1,70 +0,0 @@
<?php
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/ipSystemStats-ipv6.rrd')) {
$graph_title = 'IPv6 IP Packet Statistics';
$graph_type = 'device_ipSystemStats_v6';
include 'includes/print-device-graph.php';
$graph_title = 'IPv6 IP Fragmentation Statistics';
$graph_type = 'device_ipSystemStats_v6_frag';
include 'includes/print-device-graph.php';
}
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/ipSystemStats-ipv4.rrd')) {
$graph_title = 'IPv4 IP Packet Statistics';
$graph_type = 'device_ipSystemStats_v4';
include 'includes/print-device-graph.php';
}
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/netstats-ip.rrd')) {
$graph_title = 'IP Statistics';
$graph_type = 'device_ip';
include 'includes/print-device-graph.php';
$graph_title = 'IP Fragmented Statistics';
$graph_type = 'device_ip_fragmented';
include 'includes/print-device-graph.php';
}
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/netstats-tcp.rrd')) {
$graph_title = 'TCP Statistics';
$graph_type = 'device_tcp';
include 'includes/print-device-graph.php';
}
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/netstats-udp.rrd')) {
$graph_title = 'UDP Statistics';
$graph_type = 'device_udp';
include 'includes/print-device-graph.php';
}
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/netstats-snmp.rrd')) {
$graph_title = 'SNMP Packets Statistics';
$graph_type = 'device_snmp_packets';
include 'includes/print-device-graph.php';
$graph_title = 'SNMP Message Type Statistics';
$graph_type = 'device_snmp_statistics';
include 'includes/print-device-graph.php';
}
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/netstats-icmp.rrd')) {
$graph_title = 'ICMP Statistics';
$graph_type = 'device_icmp';
include 'includes/print-device-graph.php';
$graph_title = 'ICMP Informational Statistics';
$graph_type = 'device_icmp_informational';
include 'includes/print-device-graph.php';
}
@@ -1,8 +0,0 @@
<?php
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/netstats-icmp.rrd')) {
$graph_title = 'ICMP Informational Statistics';
$graph_type = 'device_icmp_informational';
include 'includes/print-device-graph.php';
}
@@ -1,13 +0,0 @@
<?php
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/netstats-snmp.rrd')) {
$graph_title = 'SNMP Packets Statistics';
$graph_type = 'device_snmp_packets';
include 'includes/print-device-graph.php';
$graph_title = 'SNMP Message Type Statistics';
$graph_type = 'device_snmp_statistics';
include 'includes/print-device-graph.php';
}
-6
View File
@@ -1,6 +0,0 @@
<?php
$graph_title = 'Device Uptime';
$graph_type = 'device_uptime';
require 'includes/print-device-graph.php';
+2 -2
View File
@@ -2,8 +2,8 @@
$storage = dbFetchCell('select count(*) from storage WHERE device_id = ?', array($device['device_id']));
$diskio = dbFetchCell('select count(*) from ucd_diskio WHERE device_id = ?', array($device['device_id']));
$mempools = dbFetchCell('select count(*) from mempools WHERE device_id = ?', array($device['device_id']));
$processor = dbFetchCell('select count(*) from processors WHERE device_id = ?', array($device['device_id']));
$mempools = dbFetchCell('select count(*) from mempools WHERE device_id = ?', array($device['device_id'])) + count_mib_mempools($device);
$processor = dbFetchCell('select count(*) from processors WHERE device_id = ?', array($device['device_id'])) + count_mib_processors($device);
$charge = dbFetchCell("select count(*) from sensors WHERE sensor_class='charge' AND device_id = ?", array($device['device_id']));
$temperatures = dbFetchCell("select count(*) from sensors WHERE sensor_class='temperature' AND device_id = ?", array($device['device_id']));
+36 -9
View File
@@ -4,8 +4,16 @@ $graph_type = 'mempool_usage';
$i = '1';
if (count_mib_mempools($device) > 0) {
$mempools = get_mib_mempools($device);
$graph_type = 'device_mempool';
}
else {
$mempools = dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($device['device_id']));
}
// FIXME css alternating colours
foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($device['device_id'])) as $mempool) {
foreach ($mempools as $mempool) {
if (!is_integer($i / 2)) {
$row_colour = $list_colour_a;
}
@@ -15,30 +23,49 @@ foreach (dbFetchRows('SELECT * FROM `mempools` WHERE device_id = ?', array($devi
$text_descr = rewrite_entity_descr($mempool['mempool_descr']);
$mempool_url = 'graphs/id='.$mempool['mempool_id'].'/type=mempool_usage/';
$mini_url = 'graph.php?id='.$mempool['mempool_id'].'&amp;type='.$graph_type.'&amp;from='.$config['time']['day'].'&amp;to='.$config['time']['now'].'&amp;width=80&amp;height=20&amp;bg=f4f4f4';
if ($graph_type == 'device_mempool') {
$id = 'device';
$val = $device['device_id'];
}
else {
$id = 'id';
$val = $mempool['mempool_id'];
}
$mempool_url = 'graphs/'.$id.'='.$val.'/type='.$graph_type.'/';
$mini_url = 'graph.php?'.$id.'='.$val.'&amp;type='.$graph_type.'&amp;from='.$config['time']['day'].'&amp;to='.$config['time']['now'].'&amp;width=80&amp;height=20&amp;bg=f4f4f4';
$mempool_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname'].' - '.$text_descr;
$mempool_popup .= "</div><img src=\'graph.php?id=".$mempool['mempool_id'].'&amp;type='.$graph_type.'&amp;from='.$config['time']['month'].'&amp;to='.$config['time']['now']."&amp;width=400&amp;height=125\'>";
$mempool_popup .= "</div><img src=\'graph.php?'.$id.'=".$val.'&amp;type='.$graph_type.'&amp;from='.$config['time']['month'].'&amp;to='.$config['time']['now']."&amp;width=400&amp;height=125\'>";
$mempool_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"';
$total = formatStorage($mempool['mempool_total']);
$used = formatStorage($mempool['mempool_used']);
$free = formatStorage($mempool['mempool_free']);
$perc = round(($mempool['mempool_used'] / $mempool['mempool_total'] * 100));
// don't bother recalculating if mempools use percentage
if ($mempool['percentage'] === true) {
$perc = round($mempool['mempool_used']);
}
else {
$perc = round(($mempool['mempool_used'] / $mempool['mempool_total'] * 100));
}
$background = get_percentage_colours($percent);
$right_background = $background['right'];
$left_background = $background['left'];
$graph_array['id'] = $mempool['mempool_id'];
$graph_array[$id] = $val;
$graph_array['type'] = $graph_type;
echo "<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'>$text_descr <div class='pull-right'>$used/$total - $perc% used</div></h3>
</div>";
<div class='panel-heading'>";
if ($mempool['percentage'] === true) {
echo " <h3 class='panel-title'>$text_descr <div class='pull-right'>$perc% used</div></h3>";
}
else {
echo " <h3 class='panel-title'>$text_descr <div class='pull-right'>$used/$total - $perc% used</div></h3>";
}
echo " </div>";
echo "<div class='panel-body'>";
include 'includes/print-graphrow.inc.php';
echo "</div></div>";
+23 -8
View File
@@ -3,21 +3,36 @@
$graph_type = 'processor_usage';
$i = '1';
foreach (dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($device['device_id'])) as $proc) {
$proc_url = 'graphs/id='.$proc['processor_id'].'/type=processor_usage/';
$mini_url = 'graph.php?id='.$proc['processor_id'].'&amp;type='.$graph_type.'&amp;from='.$config['time']['day'].'&amp;to='.$config['time']['now'].'&amp;width=80&amp;height=20&amp;bg=f4f4f4';
if (count_mib_processors($device) > 0) {
$processors = get_mib_processors($device);
$graph_type = 'device_processor';
}
else {
$processors = dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($device['device_id']));
}
$text_descr = $proc['processor_descr'];
foreach ($processors as $proc) {
if ($graph_type == 'device_processor') {
$id = 'device';
$val = $device['device_id'];
}
else {
$id = 'id';
$val = $proc['processor_id'];
}
$proc_url = 'graphs/'.$id.'='.$val.'/type='.$graph_type.'/';
$base_url = 'graph.php?'.$id.'='.$val.'&amp;type='.$graph_type.'&amp;from='.$config['time']['day'].'&amp;to='.$config['time']['now'];
$mini_url = $base_url.'&amp;width=80&amp;height=20&amp;bg=f4f4f4';
$text_descr = rewrite_entity_descr($text_descr);
$text_descr = rewrite_entity_descr($proc['processor_descr']);
$proc_popup = "onmouseover=\"return overlib('<div class=list-large>".$device['hostname'].' - '.$text_descr;
$proc_popup .= "</div><img src=\'graph.php?id=".$proc['processor_id'].'&amp;type='.$graph_type.'&amp;from='.$config['time']['month'].'&amp;to='.$config['time']['now']."&amp;width=400&amp;height=125\'>";
$proc_popup .= "</div><img src=\'".$base_url."&amp;width=400&amp;height=125\'>";
$proc_popup .= "', RIGHT".$config['overlib_defaults'].');" onmouseout="return nd();"';
$percent = round($proc['processor_usage']);
$graph_array['id'] = $proc['processor_id'];
$graph_array[$id] = $val;
$graph_array['type'] = $graph_type;
echo "<div class='panel panel-default'>
@@ -27,4 +42,4 @@ foreach (dbFetchRows('SELECT * FROM `processors` WHERE device_id = ?', array($de
echo "<div class='panel-body'>";
include 'includes/print-graphrow.inc.php';
echo "</div></div>";
}//end foreach
}//end foreach
+88
View File
@@ -0,0 +1,88 @@
<?php
/*
* LibreNMS device MIB browser
*
* Copyright (c) 2015 Gear Consulting Pty Ltd <github@libertysys.com.au>
*
* Author: Paul Gear
*
* 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.
*/
if (!isset($vars['section'])) {
$vars['section'] = "mib";
}
?>
<h4><i class="fa fa-file-text-o"></i> Device MIB associations</h4>
<div class="table-responsive">
<table id="mibs" class="table table-hover table-condensed mibs">
<thead>
<tr>
<th data-column-id="module">Module</th>
<th data-column-id="mib">MIB</th>
<th data-column-id="included_by">Included by</th>
<th data-column-id="last_modified">Last Modified</th>
</tr>
</thead>
</table>
</div>
<h4><i class="fa fa-file-text-o"></i> Device MIB values</h4>
<div class="table-responsive">
<table id="oids" class="table table-hover table-condensed mibs">
<thead>
<tr>
<th data-column-id="module">Module</th>
<th data-column-id="mib">MIB</th>
<th data-column-id="object_type">Object type</th>
<th data-column-id="oid">OID</th>
<th data-column-id="value">Value</th>
<th data-column-id="numvalue">Numeric Value</th>
<th data-column-id="last_modified">Last Modified</th>
</tr>
</thead>
</table>
</div>
<script>
var grid = $("#mibs").bootgrid({
ajax: true,
rowCount: [50,100,250,-1],
post: function ()
{
return {
id: "device_mibs",
device_id: '<?php echo htmlspecialchars($device['device_id']); ?>',
};
},
url: "/ajax_table.php",
formatters: {
},
templates: {
}
});
</script>
<script>
var grid2 = $("#oids").bootgrid({
ajax: true,
rowCount: [50,100,250,-1],
post: function ()
{
return {
id: "device_oids",
device_id: '<?php echo htmlspecialchars($device['device_id']); ?>',
};
},
url: "/ajax_table.php",
formatters: {
},
templates: {
}
});
</script>
+49
View File
@@ -0,0 +1,49 @@
<?php
/*
* LibreNMS global MIB association viewer
*
* Copyright (c) 2015 Gear Consulting Pty Ltd <github@libertysys.com.au>
*
* Author: Paul Gear
*
* 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.
*/
?>
<h4>MIB associations for all devices</h4>
<div class="table-responsive">
<table id="mibs" class="table table-hover table-condensed mibs">
<thead>
<tr>
<th data-column-id="hostname">Hostname</th>
<th data-column-id="module">Module</th>
<th data-column-id="mib">MIB</th>
<th data-column-id="included_by">Included by</th>
<th data-column-id="last_modified">Last Modified</th>
</tr>
</thead>
</table>
</div>
<script>
var grid = $("#mibs").bootgrid({
ajax: true,
rowCount: [50,100,250,-1],
post: function ()
{
return {
id: "device_mibs",
};
},
url: "/ajax_table.php",
formatters: {
},
templates: {
}
});
</script>
+54
View File
@@ -0,0 +1,54 @@
<?php
/*
* LibreNMS global MIB viewer
*
* Copyright (c) 2015 Gear Consulting Pty Ltd <github@libertysys.com.au>
*
* Author: Paul Gear
*
* 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.
*/
?>
<h4><i class="fa fa-file-text-o"></i> All MIB definitions</h4>
<div class="table-responsive">
<table id="mibs" class="table table-hover table-condensed mibs">
<thead>
<tr>
<th data-column-id="module">Module</th>
<th data-column-id="mib">MIB</th>
<th data-column-id="object_type">Object Type</th>
<th data-column-id="oid">Object Id</th>
<th data-column-id="syntax">Syntax</th>
<th data-column-id="description">Description</th>
<!-- th data-column-id="max_access">Maximum Access</th>
<th data-column-id="status">Status</th -->
<th data-column-id="included_by">Included by</th>
<th data-column-id="last_modified">Last modified</th>
</tr>
</thead>
</table>
</div>
<script>
var grid = $("#mibs").bootgrid({
ajax: true,
rowCount: [50,100,250,-1],
post: function ()
{
return {
id: "mibs",
view: '<?php echo $vars['view']; ?>'
};
},
url: "/ajax_table.php",
formatters: {
},
templates: {
}
});
</script>