Counter window No. 4

SNMP command builder

Fill in the form and the builder writes three Net-SNMP commands for the standard UPS MIB (RFC 1628): a full walk, a battery walk and a five-value get. The commands are built in your browser. Nothing you type is sent anywhere, and the page makes no SNMP request. Do not type a real passphrase or community string into this page: the commands show clearly marked placeholders (COMMUNITY, AUTH_PASSPHRASE, PRIV_PASSPHRASE) that you replace in your own terminal.

Message form

Never type a real secret here. This page has no box for a community string or passphrase. The commands show the placeholders COMMUNITY, AUTH_PASSPHRASE and PRIV_PASSPHRASE. Replace them with your real values in your own terminal, after you paste.

Where the card is

IPv4, IPv6 or host name. 192.0.2.20 is a documentation example.

1 to 65535. 161 is the registered SNMP port. The port is written into every command.

SNMP version
Community (v1 and v2c)

Nothing to type. The commands use the placeholder COMMUNITY; swap in your read community string in your own terminal.

SNMPv3 user

An example name. Edit it in your terminal if yours differs.

authPriv authenticates and encrypts, authNoPriv only authenticates, noAuthNoPriv does neither.

The commands use the placeholder AUTH_PASSPHRASE.

The commands use the placeholder PRIV_PASSPHRASE.

Net-SNMP needs SNMPv3 passphrases of at least 8 characters. Check that in your own terminal.

Delivered copy

Your commands

How the commands are built

Each line follows the Net-SNMP command pattern: the tool name, the version and credential options, the agent, then the object identifiers (OIDs).

Example commands, using the documentation address 192.0.2.20 (RFC 5737). Capitalised words are placeholders: replace them in your own terminal, never on this page.

snmpwalk -v 2c -c 'COMMUNITY' udp:192.0.2.20:161 1.3.6.1.2.1.33
snmpwalk -v 3 -l authPriv -u 'USER' -a SHA -A 'AUTH_PASSPHRASE' -x AES -X 'PRIV_PASSPHRASE' udp:192.0.2.20:161 1.3.6.1.2.1.33
  • Agent. The transport and port are always written out, so a client's snmp.conf cannot change them (snmp.conf manual). An IPv4 address or host name becomes udp:host:port. An IPv6 address becomes 'udp6:[address]:port'. The port box is required and starts at 161, the registered SNMP port. IPv6 text forms follow RFC 4291 section 2.2, checked locally in your browser.
  • Quoting. For POSIX-style shells, the user name is wrapped in single quotes, with any single quote inside it written as '\'', so the shell reads it as one word. The IPv6 agent is quoted too, because some shells treat square brackets as a file pattern. The placeholders are quoted the same way; keep the quotes when you replace them.
  • Security levels. noAuthNoPriv sends only the user name, authNoPriv adds -a and -A, and authPriv also adds -x and -X.
  • Protocols. The builder offers only the protocols the Net-SNMP snmpcmd manual lists: MD5 or SHA for -a, and DES or AES for -x. Newer Net-SNMP releases and some cards support more; check man snmpcmd on your system and your card's documentation.

What the get command asks for

The UPS MIB lives under 1.3.6.1.2.1.33. Single values end in .0 (RFC 2578 section 7). The battery group is 1.3.6.1.2.1.33.1.2. Meanings and units below are from RFC 1628.

ObjectOIDWhat the value means
upsIdentModel1.3.6.1.2.1.33.1.1.2.0Text: the UPS model name
upsBatteryStatus1.3.6.1.2.1.33.1.2.1.01 unknown, 2 batteryNormal, 3 batteryLow, 4 batteryDepleted
upsEstimatedMinutesRemaining1.3.6.1.2.1.33.1.2.3.0Minutes, an estimate at the present load
upsEstimatedChargeRemaining1.3.6.1.2.1.33.1.2.4.0Percent of full charge, an estimate
upsOutputSource1.3.6.1.2.1.33.1.4.1.01 other, 2 none, 3 normal, 4 bypass, 5 battery, 6 booster, 7 reducer

The battery walk also returns upsSecondsOnBattery (1.3.6.1.2.1.33.1.2.2.0), the seconds on battery, which is zero when the UPS is not on battery. RFC 1628 caps it at the time since the management subsystem last restarted, so it can read lower than the real time on battery.

Assumptions and limits

  • The commands only work if your card implements these RFC 1628 objects, and if your Net-SNMP client and the card both support the version, transport and protocol options you pick. Newer Net-SNMP releases support more options than the manual pages cited here list; check man snmpcmd on your system.
  • Not every card answers the standard UPS MIB, and many cards also have a maker's own MIB. If the walk returns nothing under 1.3.6.1.2.1.33, check the card's SNMP settings and its documentation for RFC 1628 support.
  • Net-SNMP needs SNMPv3 passphrases of at least 8 characters (snmpusm manual). The builder cannot check that, because you never type the passphrase here.
  • Ports run from 1 to 65535: port numbers are 16-bit values (RFC 6335), and port 0 is reserved in the IANA registry. SNMP agents are registered on UDP 161 and trap receivers such as snmptrapd on UDP 162.
  • Passphrases typed on a command line can end up in your shell history. The Net-SNMP manual calls passing pass phrases on the command line insecure and points to snmp.conf instead.
  • Values such as minutes remaining are the card's own estimates, not measurements made by this site.
  • The printable ASCII rule and the 255-character cap on the user name and address are this builder's own rules, not limits from the standards.

Sources

  1. RFC 1628: UPS Management Information Base IETF, RFC Editor
  2. snmpcmd - options and behaviour common to most of the Net-SNMP command-line tools Net-SNMP manual pages
  3. snmpwalk - retrieve a subtree of management values using SNMP GETNEXT requests Net-SNMP manual pages
  4. snmpget - communicates with a network entity using SNMP GET requests Net-SNMP manual pages
  5. snmpusm - creates and maintains SNMPv3 users on a network entity Net-SNMP manual pages
  6. RFC 5737: IPv4 Address Blocks Reserved for Documentation IETF, RFC Editor
  7. RFC 4291: IP Version 6 Addressing Architecture, section 2.2 IETF, RFC Editor
  8. RFC 2578: Structure of Management Information Version 2 (SMIv2), section 7 IETF, RFC Editor
  9. RFC 6335: Internet Assigned Numbers Authority (IANA) Procedures for the Management of the Service Name and Transport Protocol Port Number Registry IETF, RFC Editor
  10. Service Name and Transport Protocol Port Number Registry IANA
  11. snmp.conf - configuration files for the Net-SNMP applications Net-SNMP manual pages
  12. snmptrapd - Receive and log SNMP trap messages. Net-SNMP manual pages