Using the SNMPWALK -o Option

Instead of writing the voluminous results of the SNMPWalk to the Debug log, InterMapper can write the results to an SQLite file. To use this feature, you use the -o option.

When you use the -o option, snmpwalk stores its output into an SQLite database. To use this feature, you specify the name of the database file following the -o option.

Example:

To create an SQLite3 database named "foo" and store the snmpwalk results there, use the following "server command":

snmpwalk -v1 -c public -o foo switch 1.3

This writes the output to an SQLite database file named "foo", located in InterMapper Settings/Temporary directory. The database file named "foo" may contain multiple snmpwalk's. The file is created if it doesn't exist.

When the -o option is used, only these four lines are written to the Debug log:

SNMPWalk command received: 'snmpwalk -v1 -c public -o foo -n 10 switch 1.3'
  SNMPWalk 192.168.1.36 3: prefix 1.3 (version SNMPv1 ...
  SNMPWalk on switch started
  SNMPWalk 192.168.1.36 3: Finished (10 OIDs ...   

 

The SNMPWALK Schema

Here is the schema used for the snmpwalk database:

CREATE TABLE walks (
     id           INTEGER PRIMARY KEY,
     address      TEXT,
     port         INTEGER,
     startOid     TEXT,
     snmpVersion  INTEGER,
     pktTimeout   INTEGER,
     pktRetries   INTEGER,
     maxOids      INTEGER,
     toEnd        INTEGER,
     timeStarted  INTEGER,
     timeFinished INTEGER,
     oidCount     INTEGER,
     stopReason   TEXT
   );

   CREATE TABLE results (
     walk_id      INTEGER,
     name TEXT,
     oid          TEXT,
     type         INTEGER,
     value        BLOB
   );

Table: walks

The walks table stores one row for each snmpwalk command. Each walk will receive a unique id that is used to identify it (id). The other columns are:

address

the address of the snmpwalk target device

port

the udp port number of the snmpwalk target device

startOid

the starting OID specified in the snmpwalk command

snmpVersion

the SNMP version specified

pktTimeout

the packet timeout specified

pktRetries

the packet retry count specified

maxOids

the maximum number of OID's specified

toEnd

a boolean flag indicating that the walk should proceed to the end (i.e. don't limit by startOid).

timeStarted

the UTC timestamp when the walk was started

timeFinished

the UTC timestamp when the walk was completed

oidCount

the number of OID rows walked

stopReason

text indicating the reason the walk stopped where it did

Table: results

The results table stores a row for each entry of one snmpwalk, as specified by id in the walks table.

walk_id

the id of the walk (references walks.id)

oid

the text of the OID naming the SNMP variable

type

the ASN.1 type integer for the SNMP variable

value

the actual, uninterpreted binary value returned by the SNMP agent

Accessing the SQLite Data

On Mac OS X 10.4, you can use the built-in sqlite3 command to access the data in the SQLite database file:

  $ sqlite3 foo

  sqlite> .mode csv
  sqlite> select * from walks;
  1,"192.168.1.1",161,1.0,0,10000,3,2000,0,1178801645,1178801685,0,"No answer received"
  2,"192.168.1.2",161,1.3,0,10000,3,2000,0,1178801708,1178801895,2000,"Finished (2000 OIDs found)"
  sqlite> select count(*) from results where walk_id = 1;
  0
  sqlite> select count(*) from results where walk_id = 2;
  2000
  sqlite> select * from results where walk_id = 2 order by oid limit 5; 
  2,"1.3.6.1.2.1.1.1.0",4,"HP J4813A ProCurve Switch 2524..."
  2,"1.3.6.1.2.1.1.2.0",6,"+\006\001\004\001\013\002\003\007\013\023"
  2,"1.3.6.1.2.1.1.3.0",67,"\035\330J\375"
  2,"1.3.6.1.2.1.1.4.0",4,"Bill Fisher"
  2,"1.3.6.1.2.1.1.5.0",4,"HP ProCurve Switch 2524"

There is a Firefox add-on called "SQLite Manager" that opens and displays SQLite database files. This makes it a cross-platform tool, requiring only Firefox 3.5 or greater, plus a small download.

To install SQLite Manager:

  1. Start Firefox 3.5 or newer - Tools -> Add-ons - Click Get Add-ons
  2. Enter "SQLite" into the Search field and press Return.
  3. Double-click the "SQLite Manager" item to install it. Restart Firefox when instructed.

To use SQLite Manager:

  1. Tools -> SQLite Manager to open it.
  2. Use the Database -> Connect Database (within the window) to open a saved SQLite database
  3. Click the results table to view it.

of