I am working on a project that involves SNMP, MIBS and OIDS.
ADDENDUM: I want to have the OIDs translated into names, rather than numeric format. I only have remote access to server.
I get 2 different OID formats when I use LINUX terminal and PHP functions
This is what I do:
In LINUX terminal I type:
snmpwalk -v 1 -c public ip | less
the output is similar to this (short version)
Using php
<?php
$session = new SNMP(SNMP::VERSION_1, ipaddress, "public");
$session->oid_output_format = SNMP_OID_OUTPUT_FULL;
$result = $session->walk("");
print_r($result);
?>
the output is below
The issue: How can i get the same format in php similar to linux terminal format?
MAYBE: Is there a command that we can run from LINUX terminal that will change the format php's snmpwalk() returns OIDs ???
Php has to know about the MIB it is walking, otherwise it can't translate OIDs to variable names. The names and types, etc, are defined in a MIB file.
I don't have access to a php instance to test right now, but according to the documentation this example should work if you have the MIB file:
snmp_read_mib('./FOO-BAR-MIB.txt');
print_r(snmprealwalk('localhost', 'public', 'FOO-BAR-MIB::someTable');
which should ouput something similar to
[FOO-BAR-MIB::someTable.0] => Gauge32: 6
If you don't have the MIB file, you're out of luck. Try getting it from the equipment vendor, or just do a web search for the OID.
Edit: To clarify: There is no way to translate a numeric OID into a variable name without having the MIB file which defines that OID. If you don't have the MIB files on the local machine, you have to find a way to get them there. See also this question.