-
Notifications
You must be signed in to change notification settings - Fork 59
Using MIBs
barryo edited this page Jun 20, 2012
·
2 revisions
You'll have seen code such as the following in the examples which is how MIBs are used:
$names = $snmpHost->useCisco_VTP()->vlanNames();
The call useXXX
is a magic method in the SNMP class. It essentially instantiates a class as defined in XXX. So, for example:
-
useSystem()
instantiates\OSS_SNMP\MIBS\System
-
useIface()
instantiates\OSS_SNMP\MIBS\Iface
-
useCisco()
instantiates\OSS_SNMP\MIBS\Cisco
-
useCisco_VTP()
instantiates\OSS_SNMP\MIBS\Cisco\VTP
-
useCisco_RSTP()
instantiates\OSS_SNMP\MIBS\Cisco\RSTP
As you can see, underscores (multiple allowed) move further down the tree.
As part of instantiating the class, it also stores a reference to the SNMP object in the class (i.e. a reference to $snmpHost
is stored in the object returned by useCisco_VTP()
).
This instantiated class is returned where a method is then called. So:
$names = $snmpHost->useCisco_VTP()->vlanNames();
calls the vlanNames()
function of the instantiated \OSS_SNMP\MIBS\Cisco\VTP
class.