If you need to query a device that supports the Simple Network Management Protocol (SNMP), you can do so from a command line interface, i.e, a shell prompt, on a Mac OS X or Linux system using the snmptest tool. To use the utility, issue the snmptest command specifying the "community string", which is somewhat equivalent to a password, with the -c option, specify the version of SNMP with the -v option and then specify the IP address or fully qualified domain name (FQDN). You will get a "Variable:" prompt when you run the command. You can specify an object identifider (OID) that you wish to query at that prompt. If you hit Enter the prompt will be repeated. When you've finished entering variables you wish to query, hit Enter at the next "Variable" prompt without entering any variable. You should then see the results returned as shown below. You can hit Ctrl-C to terminate the program.

# snmptest -c SomeSecret0123 -v 1
Variable: system.sysLocation.0
Variable: system.sysContact.0
Received Get Response from UDP: []:161->[]:41231
requestid 0xAF07FC2 errstat 0x0 errindex 0x0
SNMPv2-MIB::sysLocation.0 = STRING: London
SNMPv2-MIB::sysContact.0 = STRING: John Doe
Variable: ^C

If you type snmptest -h, you will see usage information for the command.

# snmptest -h

  Version:  5.7.2

  -h, --help            display this help message
  -H                    display configuration file directives understood
  -v 1|2c|3             specifies SNMP version to use
  -V, --version         display package version number
SNMP Version 1 or 2c specific
  -c COMMUNITY          set the community string
SNMP Version 3 specific
  -a PROTOCOL           set authentication protocol (MD5|SHA)
  -A PASSPHRASE         set authentication protocol pass phrase
  -e ENGINE-ID          set security engine ID (e.g. 800000020109840301)
  -E ENGINE-ID          set context engine ID (e.g. 800000020109840301)
  -l LEVEL              set security level (noAuthNoPriv|authNoPriv|authPriv)
  -n CONTEXT            set context name (e.g. bridge1)
  -u USER-NAME          set security name (e.g. bert)
  -x PROTOCOL           set privacy protocol (DES|AES)
  -X PASSPHRASE         set privacy protocol pass phrase
  -Z BOOTS,TIME         set destination engine boots/time
General communication options
  -r RETRIES            set the number of retries
  -t TIMEOUT            set the request timeout (in seconds)
  -d                    dump input/output packets in hexadecimal
  -D[TOKEN[,...]]       turn on debugging output for the specified TOKENs
                           (ALL gives extremely verbose debugging output)
General options
  -m MIB[:...]          load given list of MIBs (ALL loads everything)
  -M DIR[:...]          look in given list of directories for MIBs
    (default: $HOME/.snmp/mibs:/usr/share/snmp/mibs)
  -P MIBOPTS            Toggle various defaults controlling MIB parsing:
                          u:  allow the use of underlines in MIB symbols
                          c:  disallow the use of "--" to terminate comments
                          d:  save the DESCRIPTIONs of the MIB objects
                          e:  disable errors when MIB symbols conflict
                          w:  enable warnings when MIB symbols conflict
                          W:  enable detailed warnings when MIB symbols conflict
                          R:  replace MIB symbols from latest module
  -O OUTOPTS            Toggle various defaults controlling output display:
                          0:  print leading 0 for single-digit hex characters
                          a:  print all strings in ascii format
                          b:  do not break OID indexes down
                          e:  print enums numerically
                          E:  escape quotes in string indices
                          f:  print full OIDs on output
                          n:  print OIDs numerically
                          q:  quick print for easier parsing
                          Q:  quick print with equal-signs
                          s:  print only last symbolic element of OID
                          S:  print MIB module-id plus last element
                          t:  print timeticks unparsed as numeric integers
                          T:  print human-readable text along with hex strings
                          u:  print OIDs using UCD-style prefix suppression
                          U:  don't print units
                          v:  print values only (not OID = value)
                          x:  print all strings in hex format
                          X:  extended index format
  -I INOPTS             Toggle various defaults controlling input parsing:
                          b:  do best/regex matching to find a MIB node
                          h:  don't apply DISPLAY-HINTs
                          r:  do not check values for range/type legality
                          R:  do random access to OID labels
                          u:  top-level OIDs must have '.' prefix (UCD-style)
                          s SUFFIX:  Append all textual OIDs with SUFFIX before parsing
                          S PREFIX:  Prepend all textual OIDs with PREFIX before parsing
  -L LOGOPTS            Toggle various defaults controlling logging:
                          e:           log to standard error
                          o:           log to standard output
                          n:           don't log at all
                          f file:      log to the specified file
                          s facility:  log to syslog (via the specified facility)

                          [EON] pri:   log to standard error, output or /dev/null for level 'pri' and above
                          [EON] p1-p2: log to standard error, output or /dev/null for levels 'p1' to 'p2'
                          [FS] pri token:    log to file/syslog for level 'pri' and above
                          [FS] p1-p2 token:  log to file/syslog for levels 'p1' to 'p2'

Some other variables you might wish to query include system.sysDescr.0 for the system's description, which might include a model and serial number, system.sysUptime.0 for the system's uptime, i.e., the amount of time that has elapsed since the device was last powered on or rebooted.

Variable: system.sysUpTime.0
Received Get Response from UDP: []:161->[]:42109
requestid 0x5C2E5DC3 errstat 0x0 errindex 0x0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (4216892561) 488 days, 1:35:25.61


TechRabbit ad 300x250

Justdeals Daily Electronics Deals1x1 px