From b1d60eafd07513d92a08c67e89f35ecc89a1aacb Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Thu, 10 Mar 2011 16:00:37 +0000 Subject: [PATCH] git-svn-id: http://www.observium.org/svn/observer/trunk@1817 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/polling/ports.inc.php | 5 +++-- includes/polling/ucd-mib.inc.php | 12 ++++-------- includes/snmp.inc.php | 6 ++++++ 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index daf0db09a..527f03e92 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -192,8 +192,9 @@ /// Update RRDs $rrdfile = $host_rrd . "/port-" . safename($port['ifIndex'] . ".rrd"); - if(!is_file($rrdfile)) { - $woo = shell_exec($config['rrdtool'] . " create $rrdfile -s 300 \ + if(!is_file($rrdfile)) + { + rrdtool_create($rrdfile," --step 300 \ DS:INOCTETS:DERIVE:600:0:12500000000 \ DS:OUTOCTETS:DERIVE:600:0:12500000000 \ DS:INERRORS:DERIVE:600:0:12500000000 \ diff --git a/includes/polling/ucd-mib.inc.php b/includes/polling/ucd-mib.inc.php index db1fd8208..6490bfcad 100755 --- a/includes/polling/ucd-mib.inc.php +++ b/includes/polling/ucd-mib.inc.php @@ -124,12 +124,8 @@ RRA:MAX:0.5:24:800 \ RRA:MAX:0.5:288:800"; - $mem_cmd = $config['snmpget'] . " -M ".$config['mibdir']. " -m UCD-SNMP-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port']; - $mem_cmd .= " memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0"; - - $mem_raw = shell_exec($mem_cmd); - - list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = explode("\n", str_replace(" kB", "", $mem_raw)); + $mem_raw = snmp_get_multi($device, "memTotalSwap.0 memAvailSwap.0 memTotalReal.0 memAvailReal.0 memTotalFree.0 memShared.0 memBuffer.0 memCached.0", "-OQUS", "UCD-SNMP-MIB"); + list($memTotalSwap, $memAvailSwap, $memTotalReal, $memAvailReal, $memTotalFree, $memShared, $memBuffer, $memCached) = $mem_raw; ## Check to see that the OIDs are actually populated before we make the rrd if(is_numeric($memTotalReal) && is_numeric($memAvailReal) && is_numeric($memTotalFree)) @@ -164,8 +160,8 @@ RRA:MAX:0.5:288:800"; $load_get = "laLoadInt.1 laLoadInt.2 laLoadInt.3"; - $load_raw = snmp_get($device, $load_get, "-Oqv", "UCD-SNMP-MIB"); - list ($load1, $load5, $load10) = explode ("\n", $load_raw); + $load_raw = snmp_get_multi($device, $load_get, "-OQUs", "UCD-SNMP-MIB"); + list ($load1, $load5, $load10) = $load_raw; ## Check to see that the OIDs are actually populated before we make the rrd if(is_numeric($load1) && is_numeric($load5) && is_numeric($load10)) diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index 0c3ff860e..e22e81687 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -71,6 +71,12 @@ function snmp_get($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL) if (is_numeric($device['timeout'])) { $timeout = $device['timeout']; } elseif (isset($config['snmp']['timeout'])) { $timeout = $config['snmp']['timeout']; } if (is_numeric($device['retries'])) { $retries = $device['retries']; } elseif (isset($config['snmp']['retries'])) { $retries = $config['snmp']['retries']; } + + if (strstr($oid,' ')) + { + echo "BUG: snmp_get called for multiple OIDs: $oid\n"; + echo "Please report this to the Observium team."; + } if ($config['snmp']['internal'] == true) {