mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
refactor: Added support for dskTable in UCD-SNMP-MIB (#4993)
This commit is contained in:
@@ -23,6 +23,7 @@ source: Support/FAQ.md
|
||||
- [Why do I not see all interfaces in the Overall traffic graph for a device?](#faq23)
|
||||
- [How do I move my LibreNMS install to another server?](#faq24)
|
||||
- [Why is my EdgeRouter device not detected?](#faq25)
|
||||
- [Why are some of my disks not showing?](#faq26)
|
||||
|
||||
### Developing
|
||||
- [How do I add support for a new OS?](#faq8)
|
||||
@@ -227,6 +228,19 @@ If you have `service snmp description` set in your config then this will be why,
|
||||
|
||||
If you don't have that set then this may be then due to an update of EdgeOS or a new device type, please [create an issue](https://github.com/librenms/librenms/issues/new).
|
||||
|
||||
#### <a name="faq26"> Why are some of my disks not showing?</a>
|
||||
|
||||
If you are monitoring a linux server then net-snmp doesn't always expose all disks via hrStorage (HOST-RESOURCES-MIB). We have additional support which will retrieve disks via dskTable (UCD-SNMP-MIB).
|
||||
To expose these disks you need to add additional config to your snmpd.conf file. For example, to expose `/dev/sda1` which may be mounted as `/storage` you can specify:
|
||||
|
||||
`disk /dev/sda1`
|
||||
|
||||
Or
|
||||
|
||||
`disk /storage`
|
||||
|
||||
Restart snmpd and LibreNMS should populate the additional disk after a fresh discovery.
|
||||
|
||||
#### <a name="faq8"> How do I add support for a new OS?</a>
|
||||
|
||||
The easiest way to show you how to do that is to link to an existing pull request that has been merged in on [GitHub](https://github.com/librenms/librenms/pull/352/files)
|
||||
|
@@ -30,7 +30,7 @@ $rrd_options .= ' AREA:perc#'.$background['right'].':';
|
||||
$rrd_options .= ' LINE1.25:perc#'.$background['left'].":'$descr'";
|
||||
$rrd_options .= ' GPRINT:size:LAST:%6.2lf%sB';
|
||||
$rrd_options .= ' GPRINT:free:LAST:%6.2lf%sB';
|
||||
$rrd_options .= " GPRINT:perc:LAST:%5.2lf%%\\\\n";
|
||||
$rrd_options .= " GPRINT:perc:LAST:%5.2lf%%\\n";
|
||||
|
||||
if ($_GET['previous']) {
|
||||
$descr = rrdtool_escape('Prev '.$storage['storage_descr'], 12);
|
||||
@@ -48,5 +48,5 @@ if ($_GET['previous']) {
|
||||
$rrd_options .= ' LINE1.25:percX#'.$colour.":'$descr'";
|
||||
$rrd_options .= ' GPRINT:sizeX:LAST:%6.2lf%sB';
|
||||
$rrd_options .= ' GPRINT:freeX:LAST:%6.2lf%sB';
|
||||
$rrd_options .= " GPRINT:percX:LAST:%5.2lf%%\\\\n";
|
||||
$rrd_options .= " GPRINT:percX:LAST:%5.2lf%%\\n";
|
||||
}
|
||||
|
19
includes/discovery/storage/ucd-dsktable.inc.php
Normal file
19
includes/discovery/storage/ucd-dsktable.inc.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$dsktable_array = snmpwalk_cache_oid($device, 'dskTable', null, 'UCD-SNMP-MIB');
|
||||
|
||||
$sql = "SELECT `storage_descr` FROM `storage` WHERE `device_id` = '".$device['device_id']."' AND `storage_type` != 'dsk'";
|
||||
$tmp_storage = dbFetchColumn($sql);
|
||||
|
||||
if (is_array($dsktable_array)) {
|
||||
foreach ($dsktable_array as $dsk) {
|
||||
if (isset($dsk['dskPath'])) {
|
||||
if (!in_array($dsk['dskPath'], $tmp_storage)) {
|
||||
$dsk['dskTotal'] = $dsk['dskTotal'] * 1024;
|
||||
$dsk['dskAvail'] = ($entry['dskAvail'] * 1024);
|
||||
$dsk['dskUsed'] = $dsk['dskTotal'] - $dsk['dskAvail'];
|
||||
discover_storage($valid_storage, $device, $dsk['dskIndex'], 'dsk', 'ucd-dsktable', $dsk['dskPath'], $dsk['dskTotal'], 1024, $dsk['dskUsed']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,20 +1,8 @@
|
||||
<?php
|
||||
|
||||
// This is an include so that we don't lose variable scope.
|
||||
if ($include_dir_regexp == '' || !isset($include_dir_regexp)) {
|
||||
$include_dir_regexp = '/\.inc\.php$/';
|
||||
foreach (glob($config['install_dir'].'/'.$include_dir.'/*.inc.php') as $file) {
|
||||
d_echo('Including: ' . $file . PHP_EOL);
|
||||
include $file;
|
||||
}
|
||||
|
||||
if ($handle = opendir($config['install_dir'].'/'.$include_dir)) {
|
||||
while (false !== ($file = readdir($handle))) {
|
||||
if (filetype($config['install_dir'].'/'.$include_dir.'/'.$file) == 'file' && preg_match($include_dir_regexp, $file)) {
|
||||
d_echo('Including: '.$config['install_dir'].'/'.$include_dir.'/'.$file."\n");
|
||||
|
||||
include $config['install_dir'].'/'.$include_dir.'/'.$file;
|
||||
}
|
||||
}
|
||||
|
||||
closedir($handle);
|
||||
}
|
||||
|
||||
unset($include_dir_regexp, $include_dir);
|
||||
unset($include_dir);
|
||||
|
13
includes/polling/storage/ucd-dsktable.inc.php
Normal file
13
includes/polling/storage/ucd-dsktable.inc.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
if (!is_array($storage_cache['dsk'])) {
|
||||
$storage_cache['dsk'] = snmpwalk_cache_oid($device, 'dskTable', null, 'UCD-SNMP-MIB');
|
||||
d_echo($storage_cache);
|
||||
}
|
||||
|
||||
$entry = $storage_cache['dsk'][$storage[storage_index]];
|
||||
|
||||
$storage['units'] = 1024;
|
||||
$storage['size'] = ($entry['dskTotal'] * $storage['units']);
|
||||
$storage['free'] = ($entry['dskAvail'] * $storage['units']);
|
||||
$storage['used'] = ($storage['size'] - $storage['free']);
|
Reference in New Issue
Block a user