power / knowledge
nut-scanner로 UPS를 잡고 ups.conf 쓰기
ups.conf 에 UPS를 식별하는 값을 적어야 하는데, 이걸 손으로 찾을 필요는 없다. nut-scanner 가 붙어 있는 UPS를 훑어서 그대로 쓸 수 있는 형태로 뱉는다.
$ nut-scanner -U
Scanning USB bus.
[nutdev1]
driver = "usbhid-ups"
port = "auto"
vendorid = "051D"
productid = "0002"
product = "Back-UPS BX950MI"
serial = "000000000000"
vendor = "American Power Conversion"
bus = "001"
여기 나온 값을 /etc/nut/ups.conf 로 옮긴다.
실제 설정
maxretry = 3
retrydelay = 5
pollinterval = 2
[apc]
driver = "usbhid-ups"
port = "auto"
vendorid = "051d"
productid = "0002"
serial = "0000000000"
desc = "APC Back-UPS BX950MI"
[apc] 가 이 UPS를 부를 이름이다. 이후 upsmon.conf 나 upsc 에서 apc@localhost 처럼 쓴다.
port = auto 는 USB일 때 쓴다. 직렬 케이블이면 장치 경로, 네트워크로 붙는 UPS면 IP를 적는다.
vendorid, productid, serial 은 usbhid-ups 드라이버가 여러 USB 장치 중에서 이 UPS를 골라내는 데 쓴다. 장치가 하나뿐이면 없어도 되지만 적어두는 편이 안전하다.
드라이버 이름은 UPS 기종마다 다르다. NUT의 hardware compatibility list에서 찾는다.
전역 값
| 항목 | 값 | 의미 |
|---|---|---|
maxretry |
3 | 드라이버 시작을 몇 번까지 다시 시도할지 |
retrydelay |
5 | 그 시도들 사이의 간격(초) |
pollinterval |
2 | UPS 상태 변수를 몇 초마다 읽을지 |
pollinterval 은 정전을 얼마나 빨리 알아채는지와 직결된다. 2초면 충분하고, 더 줄이면 USB만 계속 두드리게 된다.