From 31bb1f6ff4c90a6607e5071ef7dd1016a4d10892 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Thu, 14 Jan 2016 13:38:10 +1000 Subject: [PATCH 1/2] MIB-based polling: attempt to support more SNMP counter types --- doc/Extensions/MIB-based-polling.md | 5 +++-- includes/snmp.inc.php | 13 +++++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/doc/Extensions/MIB-based-polling.md b/doc/Extensions/MIB-based-polling.md index 8358c44e78..0909aacfb7 100644 --- a/doc/Extensions/MIB-based-polling.md +++ b/doc/Extensions/MIB-based-polling.md @@ -69,8 +69,9 @@ The components involved in MIB-based polling are: - During discovery, relevant MIBs are parsed using `snmptranslate`, and the data returned is used to populate a database which guides the poller in - what to store. At the moment, only OIDs with Unsigned32 and Counter64 - data types are parsed. + what to store. At the moment, only OIDs of INTEGER, Integer32, Unsigned32, + Counter32, and Counter64 data types are parsed, and negative values are + untested. - Devices may be excluded from MIB polling by changing the setting in the device edit screen: diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 6d1c322380..45e483a48a 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -1040,22 +1040,19 @@ function oid_rrd_type($oid, $mibdef) case 'INTEGER': case 'Integer32': - // FIXME - return false; + return 'GAUGE:600:U:U'; case 'Counter32': - // FIXME - return false; - case 'Counter64': return 'COUNTER:600:0:U'; + case 'Gauge32': case 'Unsigned32': - return 'GAUGE:600:U:U'; + return 'GAUGE:600:0:U'; + } return false; - } // oid_rrd_type @@ -1124,7 +1121,7 @@ function save_mibs($device, $mibname, $oids, $mibdef, &$graphs) foreach ($oids as $index => $array) { foreach ($array as $obj => $val) { // build up the device_oid row for saving into the database - $numvalue = preg_match('/^\d+$/', $val) ? $val : null; + $numvalue = is_numeric($val) ? $val + 0 : 0; $deviceoids[] = array( 'device_id' => $device['device_id'], 'oid' => $mibdef[$obj]['oid'].".".$index, From 1baeb36e12c75222a7131be3680753e41fdf8d60 Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Thu, 14 Jan 2016 13:40:37 +1000 Subject: [PATCH 2/2] Add Gauge32 --- doc/Extensions/MIB-based-polling.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/Extensions/MIB-based-polling.md b/doc/Extensions/MIB-based-polling.md index 0909aacfb7..d23d207dd6 100644 --- a/doc/Extensions/MIB-based-polling.md +++ b/doc/Extensions/MIB-based-polling.md @@ -69,9 +69,9 @@ The components involved in MIB-based polling are: - During discovery, relevant MIBs are parsed using `snmptranslate`, and the data returned is used to populate a database which guides the poller in - what to store. At the moment, only OIDs of INTEGER, Integer32, Unsigned32, - Counter32, and Counter64 data types are parsed, and negative values are - untested. + what to store. At the moment, only OIDs of INTEGER, Integer32, Gauge32, + Unsigned32, Counter32, and Counter64 data types are parsed, and negative + values are untested. - Devices may be excluded from MIB polling by changing the setting in the device edit screen: