# SNMP

Read SNMP agents — UPSes, PDUs, sensors, network gear — and receive their traps

- Category: Industrial
- Capabilities: trellis, Streams, Commands, Entities, Operations
- Runs on: Linux x64, Linux ARM64, macOS Apple silicon, macOS Intel, Windows x64

Read UPSes, PDUs, environmental sensors, chillers, network switches and any
other equipment with an **SNMP** agent — v1, v2c or v3 — and receive its
**traps** and **informs**. Channels are named and typed from the equipment's
own **MIB files**, so a reading arrives as `upsBatteryTemperature` in °C, not
as a number under a dotted OID.

## What you get

- **Live readings** — each object you list is a channel, polled at the rate
  you choose. A table (every outlet of a PDU, every port of a switch) becomes
  one channel per row, and new rows are picked up as they appear.
- **Units and scaling from the MIB** — `UNITS "0.1 Volt"` becomes volts,
  a `d-1` display hint becomes one decimal place, named states (`on(2)`)
  keep their code with the names shown, true/false objects show as a state.
- **Counters you can trust** — a counter channel is a running total. When a
  32-bit counter rolls over, the total carries on. When the agent restarts
  and its counters start again from zero, the total also carries on, and the
  counts lost across the restart are marked as a gap rather than misread as
  billions of new ones.
- **Traps and informs** — each notification lands on a text channel,
  `/snmp/<agent>/traps`, as one line naming what happened and its values.
  Informs are acknowledged, so the sender stops repeating them.
- **Writes** — objects you mark writable (and that the MIB allows to be
  written) can be set from **Trellis** with `ch.write(path, value)`. Each write
  is read back from the agent.
- **Many agents per input** — a rack of PDUs or a row of UPSes can share one
  input. Channels read `/snmp/<agent>/<object>`.

## Before you start

- The address of each agent, and its port if it is not **161**.
- For **v1 / v2c**: the **community** the agent answers.
- For **v3**: the **user**, the security level, and the authentication and
  encryption protocols and passwords configured on the agent.
- The equipment's **MIB files**, from its maker, in a folder on this computer.
  The standard system and interface objects (`sysUpTime`, `sysName`,
  `IF-MIB`) are built in; anything vendor-specific needs its MIB.

## Set up

1. In **Inputs**, choose **Add input** and pick **snmp**.
2. **Agents** — one per line, a name and an address:

   ```text
   ups1 = 10.0.0.5
   pdu-a = 10.0.0.6:161
   ```

   The name becomes part of every channel path.
3. **SNMP version** — v1 or v2c with a **Community**, or v3 with the
   security level the agent's user is set to (authenticated and encrypted,
   authenticated, or neither), then the **User**, and the **Authentication** /
   **Encryption** protocols and passwords that level needs.
   Passwords are kept with your other connection secrets and never written
   to logs.
4. **Objects** — one per line, by name or number:

   ```text
   sysUpTime
   upsBatteryTemperature
   upsOutputTable
   1.3.6.1.4.1.318.1.1.1.2.2.1.0
   ```

   When two of your MIBs use the same name, put the module in front, joined
   by two colons, as MIB tools write it. A scalar (`sysUpTime`) is read as itself. A table, a row or a column is
   walked, and each instance becomes a channel. A number no MIB describes is
   still read, under its number.
5. **MIB folders** — the folder holding the vendor's MIB files.
6. **Poll rate** — how often each agent is read (once a second by default).
7. Press **Test connection**. It reads `sysDescr`, `sysName` and `sysUpTime`
   from every agent, so a pass means each one answered your credentials.
8. Channels appear on **Live**.

### Traps

Tick **Receive traps and informs**, choose the **Trap port**, and point the
equipment's trap destination at this computer. Port **162** is the standard
one but needs administrator rights on most systems; a port such as **1162**
works without them. Set a **Trap community** to accept only senders that use
it (leave it empty to accept any community). v3 traps and informs use the
input's v3 user and passwords.

A trap from one of the input's agents lands under that agent's name; a trap
from any other address lands under that address.

### Writes

List the objects that may be written under **Writable objects**, for example
`ifAdminStatus`. An object is writable only when it is listed here
**and** its MIB says it can be written. A named state is written by its name
(`"off"`), a true/false object as `true` or `false`, a scaled number in the
units you read it in.

## Reference

### What each object becomes

| object | channel |
|---|---|
| integer, gauge with units or a display hint | a number, scaled, with the unit |
| named states (`off(1), on(2)`) | the state's number; the names are listed on the channel |
| true/false (`TruthValue`) | a state |
| counter (32- or 64-bit) | a running total (see below) |
| time ticks (`sysUpTime`) | seconds |
| text, addresses, identifiers | text (MAC addresses and dates as the MIB formats them) |
| no such object or instance | a sample with no value |

A unit is shown only when the MIB's `UNITS` text is one the connector
recognises; otherwise the MIB's own words are shown with the channel and no
unit is set, so you can set it yourself.

### Counters

- A 32-bit counter rolls over at 4,294,967,296. One rollover between two
  polls is carried into the total. Two cannot be told from one by anyone:
  for a fast interface use its 64-bit counter (`ifHCInOctets`) or poll
  faster.
- An agent restart is recognised by its `sysUpTime` going back (and, on v3,
  by its restart count going up). The counts between the last poll and the
  restart are unknown and shown as a gap; the total continues.

### Timing

Each reading is stamped with this computer's clock, at the middle of the
request and its answer. A poll the agent did not answer in time is shown as a
gap when the next one arrives.

### Limits measured on a simulator

One input polling **200 agents × 500 objects once a second** — 100,000
readings a second — with 500 traps a second arriving at the same time, on a
16-core Linux machine:

| | v2c | v3 (authenticated and encrypted) |
|---|---|---|
| readings landed | 100,454 / s (worst 10 s: 97,995) | 100,537 / s (worst 10 s: 97,731) |
| polls missed | none | none |
| CPU | 13 % of one core | 18 % of one core |
| memory | 86–91 MB, flat | 86–91 MB, flat |

Over a one-hour run at the same load (100 traps a second), memory stayed
flat — 90–95 MB on v2c, 99 MB on v3 from the tenth minute to the end — and
no poll was missed.

A burst of 20,000 traps sent as fast as one sender could (≈ 30,000 a second)
all landed. The connector keeps the number of requests in flight within what
the operating system's network buffer holds, so a large fleet does not lose
answers to it; an agent that drops requests is sent fewer at a time.

## Troubleshooting

| what you see | what to do |
|---|---|
| **Test connection** says the agent did not answer | Check the address and port, that SNMP is enabled on the equipment, and the community (v1/v2c), which the agent ignores silently when it is wrong. |
| "wrong authentication password or protocol" | The v3 authentication password or protocol differs from the agent's. |
| "could not decrypt" | The v3 encryption password or protocol differs from the agent's. With AES-192 or AES-256, try the other **key extension** under More settings. |
| "does not know this user name" | The v3 user is not configured on the agent. |
| An object stays a number, not a name | Its MIB is not in the **MIB folders**, or a module it imports is missing. |
| The trap port will not open | Ports below 1024 need administrator rights; use 1162 and point the equipment there. |
| Traps from a sender do not appear | Its community does not match **Trap community**, or (v3) its user or passwords differ from the input's. The input's status counts rejected notifications by reason. |

## Not yet run on real equipment

| what | status |
|---|---|
| Every agent the connector has polled so far is a simulator, net-snmp's reference agent, or a recording of a real device (Linux and Windows hosts, a UPS) replayed by an independent simulator | Live vendor agents (UPS, PDU, switch) not yet tested |
| AES-192/256 interoperability with a vendor's agent | Tested against two independent implementations, not a vendor's |

## Supports

- Any SNMP v1, v2c or v3 agent (USM: SHA-1/SHA-2 authentication, AES/DES privacy)
- Objects named and typed from the equipment's own MIB files
- Traps and informs (v1, v2c, v3) received as events

## Connection fields

| Field | Type | Required | Notes |
|---|---|---|---|
| Agents | Text | Yes |  |
| SNMP version | One of | Yes |  |
| Community | Secret | No |  |
| User | Text | No |  |
| Authentication | One of | No |  |
| Authentication password | Secret | No |  |
| Encryption | One of | No |  |
| Encryption password | Secret | No |  |
| Objects | Text | Yes |  |
| MIB folders | Text | No |  |
| Poll rate (Hz) | Number | No |  |
| Writable objects | Text | No |  |
| Receive traps and informs | On / off | No |  |
| Trap port | Number | No |  |
| Trap community | Secret | No |  |
| Context name (v3) | Text | No |  |
| AES-192/256 key extension | One of | No |  |
| Timeout (ms) | Number | No |  |
| Retries | Number | No |  |
| Objects per request | Number | No |  |
| Rows per walk request | Number | No |  |
| Re-walk tables every (s) | Number | No |  |
