Initial commit

This commit is contained in:
monoadmin
2026-04-10 15:36:36 -07:00
commit 918ff903f0
16 changed files with 929 additions and 0 deletions

116
readme.md Normal file
View File

@@ -0,0 +1,116 @@
# OpenWrt UPS SNMP
Sets up NUT (Network UPS Tools) on a MikroTik 951Ui-2HnD running OpenWrt (20.0.0.26)
to monitor a Tripp Lite SMART1500 UPS connected via USB.
- **View UPS status** in the LuCI web interface (Services → UPS)
- **SNMP exposure** so the UPS data is queryable from the network like the RouterOS device at 10.223.135.242
SNMP community: `fsr`
---
## How it works
1. **NUT `usbhid-ups` driver** talks to the Tripp Lite over USB
2. **`upsd`** serves UPS data locally on `127.0.0.1:3493`
3. **`luci-app-nut`** adds a UPS status page to the LuCI web UI
4. **`net-snmp` extend** entries call `upsc` to expose each UPS metric as an SNMP OID
This mirrors what RouterOS does natively for its connected UPS.
---
## Deploy
```bash
./deploy.sh root@20.0.0.26
```
Or manually:
```bash
scp -r openwrt/etc/nut root@20.0.0.26:/etc/
scp -r openwrt/etc/snmp root@20.0.0.26:/etc/
scp openwrt/install.sh root@20.0.0.26:/tmp/ups-install.sh
ssh root@20.0.0.26 "sh /tmp/ups-install.sh"
```
---
## Viewing UPS status
**UPS status web page (nut-web-cgi):**
```
http://20.0.0.26/cgi-bin/nut/upsstats.cgi
```
**LuCI — NUT configuration only** (not live status):
http://20.0.0.26 → Services → NUT Server / NUT Monitor
**CLI on the router:**
```bash
upsc tripplite@localhost
```
**SNMP from the network:**
```bash
snmpwalk -v2c -c fsr 20.0.0.26 .1.3.6.1.4.1.8072.1.3.2
```
---
## SNMP OIDs
UPS data is exposed under the NET-SNMP extend tree. Query with `snmpwalk` above or use
individual OIDs for polling tools (Zabbix, LibreNMS, PRTG, etc.).
| Extend name | UPS metric | Notes |
|-------------|-----------|-------|
| `battery_charge` | battery.charge | % |
| `battery_runtime` | battery.runtime | seconds |
| `ups_load` | ups.load | % |
| `input_voltage` | input.voltage | V |
| `output_voltage` | output.voltage | V |
| `ups_status` | ups.status | `OL`=online `OB`=on battery `LB`=low battery |
| `battery_temp` | battery.temperature | °C (may not be reported by all units) |
| `battery_voltage` | battery.voltage | V |
Each OID follows the pattern:
`.1.3.6.1.4.1.8072.1.3.2.3.1.2.<name-length>.<ascii-bytes-of-name>`
---
## Packages installed
| Package | Purpose |
|---------|---------|
| `nut` | Core NUT tools (`upsc`, `upsmon`) |
| `nut-server` | `upsd` daemon |
| `nut-driver-usbhid-ups` | USB HID driver for Tripp Lite |
| `luci-app-nut` | UPS status page in LuCI |
| `net-snmp` | Full snmpd with extend support |
---
## Troubleshooting
**UPS not found:**
```bash
lsusb | grep -i tripp # Tripp Lite vendor ID is 09AE
dmesg | grep -i hid
```
**`upsc` returns "connection failure":**
```bash
upsdrvctl stop && upsdrvctl start && upsd
```
**SNMP returns "No Such Object" for extend OIDs:**
- Make sure `net-snmp` is installed, not `mini-snmpd`
- Confirm `/etc/snmp/snmpd.conf` has the `extend` lines
- Test the extend command directly: `upsc tripplite@localhost battery.charge`
**SNMP not responding at all:**
- Check firewall allows UDP 161 inbound on OpenWrt
- Network → Firewall → Traffic Rules → add rule for SNMP