# SNMP

SNMP is how network equipment has reported trouble for decades, and most organisations have a system that collects such reports: a network management system. CrushMFT 27 can send its alerts there as **SNMP traps**, so that the file server shows up on the same screen as the routers and switches, and wakes the same people.

This page is about how that fits together. The receivers and their fields are described in [Preferences, Alerts: SNMP](Prefs-Alerts-SNMP.md).

## What the server does, and does not

- It **sends traps**: a message, pushed to your management system, the moment an alert fires.
- It **does not answer queries**. A management system cannot ask this server for values over SNMP (there is no agent to "walk"). For numbers that are asked for, the server has [Prometheus metrics](Monitoring-Metrics.md) and [health checks](Monitoring-Health.md).

So SNMP here means: alerts, delivered as traps.

## How it fits together

1. **Receivers** say where traps go: your management system's address, and how it is spoken to. Set once.
2. **Each alert** has a switch for sending a trap. An alert with the switch on sends one trap to every enabled receiver when it fires.

An alert can send a trap, a mail and start a job at the same time, or only one of them. The alert's limit per hour counts for all of them together.

So the choice of what reaches the management system is made alert by alert: [Alerts overview](Alerts.md) says which are worth having.

## v2c or v3

| | SNMPv2c | SNMPv3 |
|---|---|---|
| the receiver is told | a **community** name | a **user**, the server's **engine ID**, and passwords |
| signed | no: anybody who knows the community can send a trap in the server's name | yes, with **Authentication**: SHA-256 unless you change it |
| encrypted | no: the trap's text can be read on the way | yes, with **Privacy**: AES-128 |
| use it | only inside a management network that is closed off | everywhere else. A new receiver is set to it. |

A trap carries the subject and the text of an alert: user names, addresses, file names. That is reason enough for v3 on any network that is not yours alone.

## What a trap holds

Every trap is of one kind, `crushmftAlert`, and carries nine values: the alert's type, its subject and its text, the host that raised it, the user and address it is about, the server's short key for the alert, the severity, and the time. See [what a trap carries](Prefs-Alerts-SNMP.md#what-a-trap-carries).

The **subject and text** are the ones you wrote in the alert, with their variables filled in. Write them for the person at the monitoring screen: "Disk D: on files01 has 2 GB left" rather than "Disk alert".

The **short key** (`disk`, `ip_banned_logins`, `low_memory` …) is the value to build rules on in the management system: it does not change when somebody rewords a subject.

## The MIB file

A management system shows traps as numbers unless it is given the names. The server's names are in the file `CRUSHMFT-MIB.txt`, which can be fetched from the [SNMP settings page](Prefs-Alerts-SNMP.md#the-mib-file). Load it into the management system.

All of the server's numbers begin with `1.3.6.1.4.1.67717.27`. 67717 is the number registered for CrushFTP, LLC; 27 stands for the server.

## Setting it up

1. In the management system: note its address and port (162 unless it says otherwise), make a user for SNMPv3 with authentication and privacy, and load the MIB file.
2. In **Preferences, Alerts**: add a receiver with that address, user and the two passwords.
3. **Send Test Trap**:

   > SUCCESS: v3 trap of 466 bytes sent to nms.example.com:162 (engine ID 8001088505a1b2c3d4e5f60718, user crushftp). UDP cannot confirm delivery: check the receiver.

4. Give the management system the **engine ID** from that answer, with the user. An SNMPv3 receiver throws away traps from an engine it does not know.
5. Look for the test trap in the management system. It has the type "SNMP Test" and the severity `info`.
6. Turn the trap on in the alerts that matter, and **Save**.

## When traps do not arrive

| Check | |
|---|---|
| the test trap's answer | "SUCCESS … sent" means it left the server. It cannot say more: a trap is sent over UDP, and nothing comes back. |
| a firewall | UDP port 162, from the server to the receiver |
| SNMPv3: the engine ID | the receiver must know the one the server uses. It is made from the server's host name unless you set **SNMPv3 engine ID**; after a change of host name it is another one. Set it yourself to keep it fixed. |
| SNMPv3: user, both passwords, both methods | all five must match on both sides |
| the alert itself | is its trap switch on, did it fire, has it reached its limit for the hour? The server's log has a line for each alert that fired. |
| the alert's type | a test trap proves the way, not the alert. Trigger the alert for real once, or use its own test. |

## Things to know

- **A trap is not confirmed.** A management system that was down when the trap was sent never gets it. For anything that must not be missed, add a mail, or let the monitoring also ask the [health address](Monitoring-Health.md).
- **Several receivers** all get every trap.
- **Passwords and the community** are stored encrypted, and are masked for administrators with limited rights.
- **In a cluster**, each server sends its own traps; the host in the trap says which.
- **Counted**: traps sent are among the [metrics](Monitoring-Metrics.md).
