fix problem with snmp_get_multi

git-svn-id: http://www.observium.org/svn/observer/trunk@3163 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-05-10 15:02:57 +00:00
parent e490d32489
commit fe67f1e5a2
2 changed files with 9 additions and 2 deletions

View File

@ -14,7 +14,8 @@
unset($poll_device);
$snmpdata = snmp_get_multi($device, "sysUpTime.0 sysLocation.0 sysContact.0 sysName.0", "-OQUs", "SNMPv2-MIB");
foreach (array_keys($snmpdata[0]) as $key) { $poll_device[$key] = $snmpdata[0][$key]; }
print_r($snmpdata);
$poll_device = $snmpdata[0];
$poll_device['sysDescr'] = snmp_get($device, "sysDescr.0", "-Oqv", "SNMPv2-MIB");
$poll_device['sysObjectID'] = snmp_get($device, "sysObjectID.0", "-Oqvn", "SNMPv2-MIB");

View File

@ -53,7 +53,13 @@ function snmp_get_multi($device, $oids, $options = "-OQUs", $mib = NULL, $mibdir
$runtime_stats['snmpget']++;
foreach (explode("\n", $data) as $entry)
{
$array[$index][$oid] = $value;
list($oid,$value) = explode("=", $entry);
$oid = trim($oid); $value = trim($value);
list($oid, $index) = explode(".", $oid);
if (!strstr($value, "at this OID") && isset($oid) && isset($index))
{
$array[$index][$oid] = $value;
}
}
return $array;