power / knowledge
NUT에서 primary와 secondary 나누기
UPS 하나에 여러 대가 물려 있으면 아무나 "지금 다 끄자"고 선언하게 두면 안 된다. NUT은 이걸 역할로 나눈다.
| 역할 | 할 수 있는 것 |
|---|---|
| primary | UPS와 직접 연결된 주 감시자. 강제 종료(FSD)를 선언할 수 있다 |
| secondary | 상태를 원격으로 받아보고, primary가 FSD를 걸면 따라서 꺼진다 |
UPS를 실제로 제어하는 건 primary뿐이다. secondary는 자기만 꺼진다.
upsd.users
권한은 계정 단위로 준다.
[upsadmin]
password =
actions = SET
instcmds = ALL
upsmon primary
[upsuser]
password =
upsmon secondary
actions = SET— UPS의 변수를 바꿀 수 있다instcmds = ALL— UPS가 지원하는 명령을 전부 쓸 수 있다upsmon primary/secondary— 이 계정으로 붙은upsmon의 역할
upsuser 에는 actions 와 instcmds 를 주지 않았다. 감시만 하면 되는 쪽에 UPS를 끌 권한까지 줄 이유가 없다.
instcmds를 좁히려면
ALL 대신 특정 명령만 허용할 수도 있다. 어떤 명령이 있는지는 UPS에 물어본다.
$ upscmd -l apc@localhost
Instant commands supported on UPS [apc]:
beeper.disable - Disable the UPS beeper
beeper.enable - Enable the UPS beeper
beeper.mute - Temporarily mute the UPS beeper
load.off - Turn off the load immediately
load.off.delay - Turn off the load with a delay (seconds)
shutdown.reboot - Shut down the load briefly while rebooting the UPS
shutdown.stop - Stop a shutdown in progress
test.battery.start.deep - Start a deep battery test
test.battery.start.quick - Start a quick battery test
test.battery.stop - Stop the battery test
여기서 골라 여러 줄로 적는다.
[user1]
instcmds = beeper.disable
instcmds = test.battery.stop
upsmon.conf의 MONITOR
각 기계는 MONITOR 한 줄로 누구를 볼지 정한다.
# primary (UPS가 물린 쪽)
MONITOR apc@localhost 1 upsadmin <password> primary
# secondary
MONITOR apc@<NUT 서버 주소> 1 upsuser <password> secondary
순서대로 UPS 이름, power value, 계정, 비밀번호, 역할이다. power value는 이 시스템이 그 UPS에서 받는 전원 공급 개수인데 보통 1이다.
여기 적는 역할과 upsd.users 에 적은 역할이 서로 맞아야 한다. 어긋나면 붙긴 하는데 FSD가 전달되지 않는다.
TrueNAS는 파일 대신 GUI
TrueNAS는 upsmon.conf 를 직접 편집하는 구조가 아니라 Services의 UPS 항목에서 같은 값을 넣는다. 여기서도 모드를 slave로 두고 NUT 서버 주소와 upsuser 계정을 넣으면 된다. 종료 명령만 /sbin/shutdown -P now 로 잡았다.