Difference between revisions of "TUT:snmptable"

From Net-SNMP Wiki
Jump to: navigation, search
(Initial reworking)
("Specifying the OID" section)
Line 52: Line 52:
  
 
== Specifying the OID ==
 
== Specifying the OID ==
 +
 +
Unlike the other command line applications
 +
([[TUT:snmpget|snmpget]], [[TUT:snmpget|snmpgetnext]], [[TUT:snmpwalk|snmpwalk]] etc),
 +
<tt>snmptable</tt> can '''only''' be used with a MIB table object.
 +
If this command is given any other OID (including the <tt>tableEntry</tt> object,
 +
one of the table columns, or a particular instance within a table),
 +
then this will be rejected:
 +
 +
    % snmptable -v 2c -c demopublic -Os test.net-snmp.org sysOREntry
 +
    Was that a table? sysOREntry
 +
    % snmptable -v 2c -c demopublic -Os test.net-snmp.org sysORID
 +
    Was that a table? sysORID
 +
    % snmptable -v 2c -c demopublic -Os test.net-snmp.org sysORID.3
 +
    Was that a table? sysORID.3
 +
    % snmptable -v 2c -c demopublic -Os test.net-snmp.org system
 +
    Was that a table? system
 +
 +
Also, <tt>snmptable</tt> relies on having the relevant MIB file available
 +
(and loaded), in order to know which columns to retrieve.  It is not
 +
possible to run it without this MIB - even if numeric OIDs are used
 +
(which would otherwise be fine):
 +
 +
    % snmptable -v 2c -c demopublic '''-m ' ' '''test.net-snmp.org .1.3.6.1.2.1.1.9
 +
    Was that a table? iso.3.6.1.2.1.1.9
 +
    % snmptable -v 2c -c demopublic        test.net-snmp.org .1.3.6.1.2.1.1.9
 +
    SNMP table: SNMPv2-MIB::sysORTable
 +
        <i>etc, etc</i>
 +
  
 
<hr>
 
<hr>
  
 
{{TUT:LIST}}
 
{{TUT:LIST}}

Revision as of 16:42, 1 February 2007

Although snmpwalk can be used to retrieve the contents of a table, it will list the results for each column in turn. This is not how most people would naturally expect to see a table displayed. That's where snmptable comes in.

Basic usage

The snmptable command retrieves the contents of an SNMP table, and displays it in the usual manner - one row at a time:

  % snmptable -v 2c -c demopublic -Os test.net-snmp.org sysORTable
  SNMP table: sysORTable
                      sysORID                                       sysORDescr    sysORUpTime
                      snmpMIB              The Mib module for SNMPv2 entities.  0:0:00:00.00
               vacmBasicGroup        View-based Access Control Model for SNMP.  0:0:00:00.00
   snmpFrameworkMIBCompliance            The SNMP Management Architecture MIB.  0:0:00:00.00
            snmpMPDCompliance  The MIB for Message Processing and Dispatching.  0:0:00:00.00
             usmMIBCompliance  The MIB for the SNMP User-based Security Model.  0:0:00:00.00

The headings for the table columns (and the name of the table itself) can be omitted using the -Ch flag.

Wide Tables

This particular table only has a few columns (and the description strings shown here are relatively short, deliberately). In practise, the output for many tables can be too wide to be handled sensibly.

Fortunately, snmptable can apply a maximum width to the output, splitting the table into several chunks if necessary:

  % snmptable -v 2c -c demopublic -Os -Cw 80 test.net-snmp.org sysORTable
  SNMP table: sysORTable
                      sysORID                                       sysORDescr
                      snmpMIB              The Mib module for SNMPv2 entities.
               vacmBasicGroup        View-based Access Control Model for SNMP.
   snmpFrameworkMIBCompliance            The SNMP Management Architecture MIB.
            snmpMPDCompliance  The MIB for Message Processing and Dispatching.
             usmMIBCompliance  The MIB for the SNMP User-based Security Model.
  
SNMP table: sysORTable, part 2 sysORUpTime 0:0:00:00.00 0:0:00:00.00 0:0:00:00.00 0:0:00:00.00 0:0:00:00.00


Table Indexes

Holes in Tables

Specifying the OID

Unlike the other command line applications (snmpget, snmpgetnext, snmpwalk etc), snmptable can only be used with a MIB table object. If this command is given any other OID (including the tableEntry object, one of the table columns, or a particular instance within a table), then this will be rejected:

   % snmptable -v 2c -c demopublic -Os test.net-snmp.org sysOREntry
   Was that a table? sysOREntry
   % snmptable -v 2c -c demopublic -Os test.net-snmp.org sysORID
   Was that a table? sysORID
   % snmptable -v 2c -c demopublic -Os test.net-snmp.org sysORID.3
   Was that a table? sysORID.3
   % snmptable -v 2c -c demopublic -Os test.net-snmp.org system
   Was that a table? system

Also, snmptable relies on having the relevant MIB file available (and loaded), in order to know which columns to retrieve. It is not possible to run it without this MIB - even if numeric OIDs are used (which would otherwise be fine):

   % snmptable -v 2c -c demopublic -m ' ' test.net-snmp.org .1.3.6.1.2.1.1.9
   Was that a table? iso.3.6.1.2.1.1.9
   % snmptable -v 2c -c demopublic        test.net-snmp.org .1.3.6.1.2.1.1.9
   SNMP table: SNMPv2-MIB::sysORTable
       etc, etc



Tutorial Sections

About the SNMP Protocol

These tutorial links talk about SNMP generically and how the protocol itself works. They are good introductory reading material and the concepts are important to understand before diving into the later tutorials about Net-SNMP itself.

Net-SNMP Command Line Applications

These tutorial pages discuss the command line tools provided in the Net-SNMP suite of tools. Nearly all the example commands in these tutorials works if you try it yourself, as they're all examples that talk to our online Net-SNMP test agent. Given them a shot!

Application Configuration

All of our applications support configuration to allow you to customize how they behave.

Net-SNMP Daemons

Net-SNMP comes with two long-running daemons: a SNMP agent (snmpd) for responding to management requests and a notification receiver (snmptrapd) for receiving SNMP notifications.

Coding Tutorials

Net-SNMP comes with a highly flexible and extensible API. The API allows you to create your own commands, add extensions to the agent to support your own MIBs and perform specialized processing of notifications.

Debugging SNMP Applications and Agents

All our tools and applications have extensive debugging output. These tutorials talk about how the debugging system works and how you can add your own debugging statements to you code:

Operating System Specific Tutorials