function OSS_SNMP_Lookup($dev, $snmplookup, $oid = null) { // This is find out the name of the function that called this to make the error logging more descriptive $caller = "OSS_SNMP_Lookup"; $failed = false; $snmpHost = new OSS_SNMP\SNMP($dev->PrimaryIP, $dev->SNMPCommunity, $dev->SNMPVersion, $dev->v3SecurityLevel, $dev->v3AuthProtocol, $dev->v3AuthPassphrase, $dev->v3PrivProtocol, $dev->v3PrivPassphrase); $snmpresult = false; try { $snmpresult = is_null($oid) ? $snmpHost->useSystem()->{$snmplookup}(true) : $snmpHost->get($oid); } catch (Exception $e) { IncrementFailures($dev->DeviceID); $failed = true; error_log("PowerDistribution::{$caller}({$dev->DeviceID}) " . $e->getMessage()); } if (!$failed) { ResetFailures($dev->DeviceID); } return $snmpresult; }
private static function OSS_SNMP_Lookup($dev, $snmplookup, $portid = null, $baseoid = null) { // This is find out the name of the function that called this to make the error logging more descriptive $caller = debug_backtrace(); $caller = $caller[1]['function']; // Since we don't really let the user specify the version right now here's a stop gap // Try the default version of 2c first $snmpHost = new OSS_SNMP\SNMP($dev->PrimaryIP, $dev->SNMPCommunity, $dev->SNMPVersion, $dev->v3SecurityLevel, $dev->v3AuthProtocol, $dev->v3AuthPassphrase, $dev->v3PrivProtocol, $dev->v3PrivPassphrase); try { $snmpHost->useSystem()->name(); } catch (Exception $e) { // That shit the bed so drop down to 1 $snmpHost = new OSS_SNMP\SNMP($dev->PrimaryIP, $dev->SNMPCommunity, 1); } $snmpresult = false; try { $snmpresult = is_null($portid) ? $snmpHost->useIface()->{$snmplookup}(true) : $snmpHost->get($baseOID . ".{$portid}"); } catch (Exception $e) { error_log("SwitchInfo::{$caller}({$dev->DeviceID}) " . $e->getMessage()); } return $snmpresult; }