I have written a very simple perl CGI script that extracts some basic information using SNMP and displays it in a web page. The information contains the basic SNMP information (name, contact, location, available services), and some basic information about IP addresses, routes, interfaces and storage. Not all devices will implement all the Management Information Bases (MIB) so do not be surprised if some fields remain empty.
The script uses two basic SNMP commands:
snmptable, those are typically available on Unix system by the way of Net-SNMP project. I’m using the script on Mac OS X, but it should run on any Unix with Net-SNMP installed. If this is not the case, I’m interested in hearing from you.
To use it, do the following:
- Download the Zipped archive
- Unzip it, the file is named
- Copy the file into the CGI folder of your server, on a Mac OS X client machine, this is
- Make sure the file is executable:
chmod uga+x hostinfo.
- The script assumes the SNMP commands are in
/usr/bin, if this is not the case, edit lines 12 and 13, and add the correct path to the commands (you can use
which snmptableto figure it out). If you want to run the script on windows, you will need to add the drive letters at those lines.
- The script is accessible (assuming you install it locally) at the following url: http://127.0.0.1/cgi-bin/hostinfo.
As usual, this script is given as is. I took some care to avoid code injections issues, but I take no responsability if your computer crashes, your laptop explodes or your cat tries to become master of the universe. Below a sample output for my NAS.
One thought on “SNMP hostinfo”