Tutorial for SNMP in PHPby Jim Campbell
The SNMP protocol is an older solution for remotely auditing and managing information about network resources. You can use this protocol in PHP to retrieve information about a remote resource on the network. The PHP language includes libraries for the SNMP protocol to remotely query an object and retrieve a list of data values regarding the network resource's services and configurations.
Right-click the PHP file you want to edit and select "Open With." Click your preferred PHP editor.
Use the following function to connect to the device on your network:
$device = snmpget("127.0.0.1", "public", "system.SysContact.0");
Replace the IP address with the IP address of the device you want to access.
Retrieve information about the device. The following code gets a list of data from the device:
Replace "MIB.txt" with the MIB file that contains the SNMP information on the device.
Print the output to the browser window. The following code prints the data to the browser for your review:
print_r( snmprealwalk('$data, 'FOO-BAR-MIB::table' );