__call()
__construct()
cache()
disableCache()
enableCache()
get()
getCache()
getCommunity()
getHost()
getLastResult()
getResultCache()
getRetry()
getTimeout()
parseSnmpValue()
ppTruthValue()
realWalk()
setCache()
setCommunity()
setHost()
setOidOutputFormat()
setRetry()
setTimeout()
subOidWalk()
translate()
useExtension()
walk1d()
walkIPv4()
$SNMP_TRUTHVALUES
$_cache
$_community
$_disableCache
$_host
$_lastResult
$_retry
$_timeout
OID_OUTPUT_FULL
OID_OUTPUT_NUMERIC
SNMP_TRUTHVALUE_FALSE
SNMP_TRUTHVALUE_TRUE
A class for performing SNMP V2 queries and processing the results.
copyright | Copyright (c) 2012, Open Source Solutions Limited, Dublin, Ireland |
---|---|
author | Barry O'Donovan |
__call(string $method, array $args)
__construct(string $host, string $community) : \OSS_SNMP
string
The target host for SNMP queries.
string
The community to use for SNMP queries.
\OSS_SNMP
An instance of $this (for fluent interfaces)cache() : boolean
boolean
True of the local lookup cache is enabled. Otherwise false.disableCache() : \SNMP
\SNMP
An instance of this for fluent interfacesenableCache() : \SNMP
\SNMP
An instance of this for fluent interfacesget(string $oid) : mixed
string
The OID to get
\OSS_SNMP\Exception |
On *any* SNMP error, warnings are supressed and a generic exception is thrown |
---|
mixed
The resultant valuegetCache() : \OSS_SNMP\Cache
We kind of mandate the use of a cache as the code is written with a cache in mind. You are free to disable it via disableCache() but your machines may be hammered!
We would suggest disableCache() / enableCache() used in pairs only when really needed.
\OSS_SNMP\Cache
The cache objectgetCommunity() : string
string
The community string currently in use.getHost() : string
string
The target host as currently configured for SNMP queriesgetLastResult() : mixed
mixed
The unaltered original last SNMP resultgetResultCache() : array
array
The internal result cachegetRetry() : string
string
The SNMP query retry countgetTimeout() : int
int
The the SNMP query timeout (microseconds)parseSnmpValue(string $v) : mixed
For example, [STRING: "blah"] is parsed to a PHP string containing: blah
string
The value to parse
\Exception |
---|
mixed
The parsed valueppTruthValue(integer $value) : boolean
integer
The TruthValue ( 1 => true, 2 => false) to convert
boolean
realWalk(string $oid) : array
string
The OID to walk
array
The results of the walksetCommunity(string $c) : \OSS_SNMP
string
The community to use for SNMP queries.
\OSS_SNMP
An instance of $this (for fluent interfaces)setHost(string $h) : \OSS_SNMP\SNMP
string
The target host for SNMP queries.
\OSS_SNMP\SNMP
An instance of $this (for fluent interfaces)setOidOutputFormat(int $f) : \OSS_SNMP\SNMP
Should be one of the class OID_OUTPUT_* constants
int
The fomat to use
\OSS_SNMP\SNMP
An instance of $this (for fluent interfaces)setRetry(int $r) : \OSS_SNMP
int
The SNMP query retry count
\OSS_SNMP
An instance of $this (for fluent interfaces)setTimeout(int $t) : \OSS_SNMP
int
The timeout to use for SNMP queries (microseconds).
\OSS_SNMP
An instance of $this (for fluent interfaces)subOidWalk(string $oid, int $position) : array
I.e. the following query with sample results:
subOidWalk( '.1.3.6.1.4.1.9.9.23.1.2.1.1.9', 15 )
.1.3.6.1.4.1.9.9.23.1.2.1.1.9.10101.5 = Hex-STRING: 00 00 00 01
.1.3.6.1.4.1.9.9.23.1.2.1.1.9.10105.2 = Hex-STRING: 00 00 00 01
.1.3.6.1.4.1.9.9.23.1.2.1.1.9.10108.4 = Hex-STRING: 00 00 00 01
would yield an array:
10101 => Hex-STRING: 00 00 00 01
10105 => Hex-STRING: 00 00 00 01
10108 => Hex-STRING: 00 00 00 01
string
The OID to walk
int
The position of the OID to use as the key
\OSS_SNMP\Exception |
On *any* SNMP error, warnings are supressed and a generic exception is thrown |
---|
array
The resultant valuestranslate(mixed $values, array $translator) : mixed
I.e. all elements '$value' will be replaced with $translator( $value ) where $translator is an associated array.
Huh? Just read the code below!
mixed
A scalar or array or values to translate
array
An associated array to use to translate the values
mixed
The translated scalar or arrayuseExtension(string $mib, array $args) : \OSS_SNMP\MIBS
Calling $this->useXXX_YYY_ZZZ()->fn() will instantiate an extension MIB class is the given name and this $this SNMP instance and then call fn().
See the examples for more information.
string
The extension class to use
array
\OSS_SNMP\MIBS
walk1d(string $oid) : array
Walks the SNMP tree returning an array of key => value pairs.
This is a first degree walk and it will throw an exception if there is more that one degree of values.
I.e. the following query with sample results:
walk1d( '.1.0.8802.1.1.2.1.3.7.1.4' )
.1.0.8802.1.1.2.1.3.7.1.4.1 = STRING: "GigabitEthernet1/0/1"
.1.0.8802.1.1.2.1.3.7.1.4.2 = STRING: "GigabitEthernet1/0/2"
.1.0.8802.1.1.2.1.3.7.1.4.3 = STRING: "GigabitEthernet1/0/3"
.....
would yield an array:
1 => GigabitEthernet1/0/1
2 => GigabitEthernet1/0/2
3 => GigabitEthernet1/0/3
string
The OID to walk
\OSS_SNMPException |
On *any* SNMP error, warnings are supressed and a generic exception is thrown |
---|
array
The resultant valueswalkIPv4(string $oid) : array
I.e. the following query with sample results:
subOidWalk( '.1.3.6.1.2.1.15.3.1.1. )
.1.3.6.1.2.1.15.3.1.1.10.20.30.4 = IpAddress: 192.168.10.10
...
would yield an array:
[10.20.30.4] => "192.168.10.10"
....
string
The OID to walk
\OSS_SNMP\Exception |
On *any* SNMP error, warnings are supressed and a generic exception is thrown |
---|
array
The resultant values$SNMP_TRUTHVALUES
$_cache
$_community
$_disableCache
$_host
$_lastResult
$_retry
$_timeout
OID_OUTPUT_FULL
OID_OUTPUT_NUMERIC
SNMP_TRUTHVALUE_FALSE
SNMP_TRUTHVALUE_TRUE