Difference between revisions of "TUT:snmptable"
m (Consistent section headings) |
(fix link) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
− | Although [[ | + | Although [[snmpwalk|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 | it will list the results for each column in turn. This is not how most people | ||
− | would naturally expect to see a table displayed, which is where <tt>snmptable</tt> comes in. | + | would naturally expect to see a table displayed, which is where <tt>[[snmptable]]</tt> comes in. |
== Basic Example == | == Basic Example == | ||
Line 69: | Line 69: | ||
== Holes in Tables == | == Holes in Tables == | ||
− | The [[TUT: | + | The [[TUT:snmpgetnext|snmpgetnext tutorial]] includes a discussion of the idea of |
"holes" in a table, illustrated by an (artificially) missing value for | "holes" in a table, illustrated by an (artificially) missing value for | ||
<tt>sysORDescr.4</tt>. The <tt>snmptable</tt> command will handle such holes | <tt>sysORDescr.4</tt>. The <tt>snmptable</tt> command will handle such holes |
Latest revision as of 16:13, 23 December 2014
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, which is where snmptable comes in.
Contents
Basic Example
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.82 ifMIB generic objects for network interface sub-layers 0:0:00:00.81 ip The MIB module for managing IP and ICMP 0:0:00:00.83 udpMIB The MIB module for managing UDP implementations 0:0:00:00.82
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 have been deliberately shortened). 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 70 test.net-snmp.org sysORTable SNMP table: sysORTable sysORID sysORDescr snmpMIB The Mib module for SNMPv2 entities. ifMIB generic objects for network interface sub-layers ip The MIB module for managing IP and ICMP udpMIB The MIB module for managing UDP implementations
SNMP table: sysORTable, part 2 sysORUpTime 0:0:00:00.82 0:0:00:00.81 0:0:00:00.83 0:0:00:00.82
Table Indexes
One thing missing from the tables above, is any indication of the index values for each row. The earliest MIB tables (and some more recent, but poorly designed tables) did define the indexes as accessible objects, which would therefore appear in the snmptable output. But current MIB design has recognised that the index values are included in the instance OIDs, so it is not necessary to explicitly retrieve them as a separate column object.
By default, the snmptable command ignores these index values, but it will display them if invoked with the -Ci option:
% snmptable -v 2c -c demopublic -Os -Cw 70 -Ci test.net-snmp.org sysORTable SNMP table: sysORTable index sysORID sysORDescr 1 snmpMIB The Mib module for SNMPv2 entities. 2 ifMIB generic objects for network interface sub-layers 4 ip The MIB module for managing IP and ICMP 5 udpMIB The MIB module for managing UDP implementations
SNMP table: sysORTable, part 2 index sysORUpTime 1 0:0:00:00.82 2 0:0:00:00.81 4 0:0:00:00.83 5 0:0:00:00.82
Note that the index is listed for each block of a width-limited (and hence multi-sectioned) table display.
Holes in Tables
The snmpgetnext tutorial includes a discussion of the idea of "holes" in a table, illustrated by an (artificially) missing value for sysORDescr.4. The snmptable command will handle such holes automatically, filling in any such missing values:
% 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.82 ifMIB generic objects for network interface sub-layers 0:0:00:00.81 ip ? 0:0:00:00.83 udpMIB The MIB module for managing UDP implementations 0:0:00:00.82
Specifying the Table 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.
- How SNMP Works: About the protocol itself (GETs, GETNEXTs, etc)
- What data is in SNMP: All about SNMP Management Information Bases (MIBs)
- Securing SNMP: How to use the SNMP protocol securely
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!
- snmptranslate: learning about the MIB tree.
- snmpget: retrieving data from a host.
- snmpgetnext: retrieving unknown indexed data.
- snmpwalk: retrieving lots of data at once!
- snmptable: displaying a table.
- snmpset: peforming write operations.
- snmpbulkget: communicates with a network entity using SNMP GETBULK request
- snmpbulkwalk: retrieve a sub-tree of management values using SNMP GETBULK requests.
- snmptrap: Sending and receiving traps, and acting upon them.
- Traps/informs with SNMPv3/USM: Sending and receiving SNMPv3/USM TRAPs and INFORMs
- Sending Traps/Informs via AgentX: Sending notifications from the command line through snmpd
- Common command line options:
- Writing mib2c config files
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.
- SNMP Agent (snmpd) Configuration
- SNMP Notification Receiver (snmptrapd)
- Agent Monitoring
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.
- Client / Manager Coding Tutorials
- Agent Coding Tutorials
- The Agent Architecture page might be worth reading before or after the agent coding tutorials, and describes how the Agent Helpers work under the hood.
- Writing a mib module to serve information described by an SNMP MIB, and how to compile it into the net-snmp snmpd agent.
- Writing a Dynamically Loadable Object that can be loaded into the SNMP agent.
- Writing a Subagent that can be run to attach to the snmpd master agent.
- Writing a perl plugin to extend the agent using the NetSNMP::agent module.
- Writing shell scripts to extend the agent
- Using mib2c to help write an agent code template for you
- Header files and autoconf
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:
- Debugging output printed using the -D command line option
- Using -Ddump to display packet breakdowns
- Debugging using GDB
Operating System Specific Tutorials
- Building With Visual Studio 2005 Express
- Building Net-SNMP 64-bit with Visual C++ 2010 Express
- Net-Snmp on Ubuntu
- Net-SNMP and lm-sensors on Ubuntu 10.04
- Net-SNMP for windows: