I hate SNMP! But I have to use it on a daily basis with my company, Open Solutions.
Don’t get me wrong, it’s an essential tool in the trade of network engineering but it’s also a serious PITA. Finding MIBs, OIBs, making them work, translating them, cross-vendor translations, etc, blah, blah. And then, when you do find what you need, you’ll have forgotten it months later when you need it again.
Anyway, while trying to create some automatic L2 topology graphing tools (via Cisco/Foundry Discovery Protocol for example) and also some per VLAN RSTP tools to show port states, I started writing this library. As I wrote, I realised it was actually very useful and present it here now in the hopes that the wider network engineering community will find it useful and also contribute back MIBs.
An example may best illustrate the library:
First, we need to instantiate an SNMP object with a hostname / IP address and a community string:
$ciscosw = new \OSS\SNMP( $ip, $community );
Assuming the above is a standard Cisco switch, let’s say we want to get an associate array of VLAN names indexed by the VLAN ids:
print_r( $ciscosw->useCisco_VTP()->vlanNames() );
This yields something like the following:
Array (  => default  => mgmt  => cust-widgets  => fddi-default ... )
It really is that easy.
See the GitHub project page: https://github.com/opensolutions/OSS_SNMP