Pular para o conteúdo

UPS with NUT

Este conteúdo não está disponível em sua língua ainda.

A UPS plugged into a NAS, a Raspberry Pi or a server over USB is usually watched by Network UPS Tools (NUT): its daemon, upsd, publishes what the UPS says on TCP port 3493. DumbMonit reads that server, like any NUT client: whether the UPS runs on mains or battery, whether the battery is low or worn out, the charge, the runtime left, the load, the input voltage and the age of the battery. One server often publishes several UPS; all of them are read in one connection, and every series carries the name of its UPS.

For a UPS with its own network card, the SNMP device type reads the standard UPS-MIB instead.

From the DumbMonit server (or its relay agent) to the device:

PortProtocolPurpose
3493TCPupsd (default)

All metrics are prefixed dumbmonit_nut_ and carry the label ups, the UPS name in ups.conf (ups on a Synology NAS, qnapups on a QNAP). A variable the UPS does not publish produces no series.

MetricWhatLabels
ups_on_line, ups_on_battery, ups_low_battery, ups_high_battery, ups_replace_battery, ups_charging, ups_discharging, ups_bypass, ups_calibrating, ups_off, ups_overload, ups_trim, ups_boost, ups_forced_shutdown, ups_alarmThe flags of ups.status (OL, OB, LB, HB, RB, CHRG, DISCHRG, BYPASS, CAL, OFF, OVER, TRIM, BOOST, FSD, ALARM): 1 when set, 0 otherwise, all of them at every readups
ups_status_infovalue 1, the raw ups.statusups, status
battery_charge_percent, battery_charge_low_percentcharge, and the charge under which the UPS reports a low batteryups
battery_runtime_seconds, battery_runtime_low_secondsruntime left on battery at the present load, and the low-battery runtimeups
battery_voltage_volts, battery_temperature_celsiusups
battery_age_secondstime since battery.date (installed or replaced), or else battery.mfr.dateups, source (installed, manufactured)
input_voltage_volts, input_voltage_nominal_volts, input_frequency_hertzmains side; 0 V during an outageups
output_voltage_volts, output_frequency_hertzload sideups
ups_load_percentload, in percent of the UPS capacityups
ups_realpower_watts, ups_realpower_nominal_watts, ups_power_va, ups_power_nominal_vapower drawn and the rating, when the UPS reports themups
ups_temperature_celsiusups
ups_self_test_failed1 when the last self-test (ups.test.result) reports an error or a warning, 0 when it passed; absent when no test ranups, result
ups_infovalue 1ups, manufacturer, model, firmware, driver, battery_type, description
ups_data_stale1 when upsd answers but has no fresh data from the UPS (DATA-STALE, DRIVER-NOT-CONNECTED)ups
ups_driver_connected0 when the NUT driver of that UPS is not runningups
server_upsnumber of UPS the server publishes
server_infovalue 1version

Serial numbers are never put in a label. At most 32 UPS are read per server.

The built-in rules that apply: UPS on battery, UPS battery low, UPS battery needs replacing, UPS load high, UPS runtime short, UPS data stale, plus Monitor unreachable when the NUT server itself stops answering.

The panel above the charts reads what the probe stored; opening the page never connects to the NUT server. One card per UPS: its state in words (on mains, on battery, low battery, replace battery, bypass, overload…), the charge, the runtime left, the load, the input voltage and the age of the battery.

  1. On a plain NUT install, add this line to upsd.conf and restart upsd.

    LISTEN 0.0.0.0 3493
  2. Open TCP port 3493 in the firewall for the DumbMonit host.

  3. On a NAS, enable its network UPS server instead: Synology DSM → Control Panel → Hardware & Power → UPS, then add the DumbMonit host under Permitted DiskStation Devices.

  4. Optional, to name this client: add a user without actions or instcmds to upsd.users, with a long random password, and restart upsd.

    [dumbmonit]
    password = a-long-random-password
  5. In DumbMonit, enter the NUT server’s address (nas.lan): every UPS it publishes is watched.

Vendor documentation: https://networkupstools.org/docs/man/upsd.conf.html

Reading needs no account: upsd lets any host it accepts read the variables, and changes nothing without a user that has the right to. DumbMonit sends a user name and password only if you enter one.

The NUT server is the machine the UPS is plugged into (a NAS, a Raspberry Pi, a server); it runs upsd on TCP port 3493. On a Synology the UPS is named ups. QNAP: the UPS page of the Control Panel, Enable network UPS master, with the DumbMonit host among the allowed addresses; the UPS is named qnapups. TrueNAS: the UPS service with Remote Monitor ticked. To watch only some UPS, list their names in the UPS option.

To check from the DumbMonit host that the server answers and to note the names of its UPS (with the NUT client tools, upsc -l nas.lan gives the same list):

printf 'LIST UPS\nLOGOUT\n' | nc nas.lan 3493

DumbMonit only reads: it sends LIST UPS and LIST VAR, never LOGIN, SET, INSTCMD or FSD, so the server never counts it as a secondary to wait for before shutting down.

CredentialFields
No authenticationThe default: upsd lets any host it accepts read the UPS variables.
upsd user name / passwordSent with USERNAME and PASSWORD before reading. upsd only checks them for commands, which DumbMonit never sends.

Address: a host name or IP (nas.lan), host:port, or the ups@host form of upsc, of which only the host is kept. Options: port (3493), the UPS to watch (all by default) and the timeout per exchange (10 s).

A refused connection or no answer counts as the monitor being unreachable. When the machine running the NUT server shuts down in the outage it reports (it is often its own upsmon primary), the UPS alerts are hidden as suppressed while Monitor unreachable fires for that same monitor: read the Monitor unreachable alert as the sign that the power failure won. Run the NUT server on a machine that outlives the others, or watch the UPS from a second NUT server. ACCESS-DENIED is shown as a credential error, and a UPS name the server does not publish as a configuration error; neither wakes anyone at night. The connection is plain TCP: STARTTLS is not used, and nothing read is secret.