ノートPCでも使ってるんでなきゃ、サーバーに無停電電源装置がほしいですね。落雷や停電の時のみならず、1秒以下の瞬電でもPCが壊れることがあります。備えあれば憂いなしなので、UPSを設置しました。
今回は、Powercom WOW-300URをUbuntu Server 14.04 LTSでUPSとして設置したので、設定周りをメモ。
- UPSの監視・制御を行うnutをインストールする。
1 |
$sudo apt-get install nut |
- lsusb でPowercom のBusとIDを調べる。idVendorとidProductをメモしておく。
1 2 |
$lsusb Bus 001 Device 002: ID 0d9f:0004 Powercom Co., Ltd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
$ lsusb -v -s 001:002 Bus 001 Device 002: ID 0d9f:0004 Powercom Co., Ltd Couldn't open device, some information will be missing Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0d9f Powercom Co., Ltd idProduct 0x0004 bcdDevice 0.01 iManufacturer 3 iProduct 1 iSerial 2 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 34 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 0 No Subclass bInterfaceProtocol 0 None iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.00 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 966 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 100 |
- /etc/nut/nut.confの編集
今回はサーバー1台のみなので、スタンドアロンモードを設定する。
1 |
MODE=standalone |
- /etc/nut/ups.confにドライバ、ポートなどを記述する。vendoridとproductidには先ほど調べた番号を記述する。[]の中は、UPSにつけた任意の名前を書く。ドライバはusbhid-upsを指定する。
1 2 3 4 5 6 |
[ups] driver = usbhid-ups port = auto vendorid = 0d9f productid = 0004 pollinterval = 10 |
- upsmon.confの以下の項目を修正/追記する。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
MONITOR ups@localhost 1 upsmon pass master MINSUPPLIES 1 SHUTDOWNCMD "/sbin/shutdown -h +0" NOTIFYCMD "etc/nut/notifycmd" NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC NOTIFYFLAG FSD SYSLOG+WALL+EXEC NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC |
- 最後に再起動して、upscを使って接続状況を確認する。
うまくいっていれば、UPSの状態が画面に表示される。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
$upsc ups@localhost Init SSL without certificate database battery.charge: 100 battery.charge.low: 10 battery.charge.warning: 30 battery.date: 2010/12/20 battery.runtime: 800 battery.type: PbAc device.mfr: POWERCOM Co.,LTD device.model: HID UPS Battery device.serial: 004-0D9F-000 device.type: ups driver.name: usbhid-ups driver.parameter.pollfreq: 30 driver.parameter.pollinterval: 10 driver.parameter.port: auto driver.parameter.productid: 0004 driver.parameter.vendorid: 0d9f driver.version: 2.7.1 driver.version.data: PowerCOM HID 0.4 driver.version.internal: 0.38 input.frequency: 59.0 input.voltage: 100.0 input.voltage.nominal: 100 output.frequency: 60.0 output.voltage: 100.0 output.voltage.nominal: 100 ups.beeper.status: enabled ups.date: 2010/12/20 ups.delay.shutdown: 20 ups.delay.start: 60 ups.load: 10 ups.mfr: POWERCOM Co.,LTD ups.model: HID UPS Battery ups.productid: 0004 ups.serial: 004-0D9F-000 ups.status: OL ups.test.result: Done and passed ups.timer.shutdown: 0 ups.timer.start: 0 ups.vendorid: 0d9f |
- WOW-300URは、javaで書かれた制御ツールがLinuxようにあるが、うまく動かなかったのでこちらで対応。
現在順調に動いている。
sudo upsdrvctl start
でドライバを有効にしないとうまく動かないので追記。