安くて頼れる無停電電源装置の、CLASSIC PRO UPS1500LXを買いまして、備えあれば憂いがないという日々を送りはじめてみます。
中にUPSilon2000という電源管理ソフトウェアが同梱されていますが、CUIでは使えないのでスルーします。
代わりにNetwork UPS Toolsという、フリーウェアの汎用的な電源管理ツールを使います。
以下、導入時のコマンド履歴です。誰かのお役に立てば。
$ sudo /sbin/lsusb Bus 005 Device 001: ID 0000:0000 Bus 003 Device 003: ID 0001:0000 Fry's Electronics Bus 003 Device 001: ID 0000:0000 Bus 004 Device 001: ID 0000:0000 Bus 001 Device 001: ID 0000:0000 Bus 002 Device 001: ID 0000:0000 $ sudo /sbin/lsusb -v -s 003:003 Bus 003 Device 003: ID 0001:0000 Fry's Electronics Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.00 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0001 Fry's Electronics idProduct 0x0000 bcdDevice 1.00 iManufacturer 1 MEC iProduct 2 MEC0002 iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 34 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0x80 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 624 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 10
$ sudo yum install -y libusb.i386 $ sudo yum install -y libusb-devel.i386 $ cd /usr/local/src/ $ wget http://www.networkupstools.org/source/2.6/nut-2.6.5.tar.gz $ tar zxvf nut-2.6.5.tar.gz $ cd nut-2.6.5 $ ./configure --with-user={UPS管理ユーザ名} --with-group={UPS管理グループ名} --with-usb --with-cgi --prefix=/etc/nut $ make $ sudo make install
$ sudo mv /etc/nut/nut.conf.sample /etc/nut/nut.conf $ sudo vi /etc/nut/nut.conf MODE=standalone $ sudo mv /etc/nut/ups.conf.sample /etc/nut/ups.conf $ sudo vi /etc/nut/ups.conf [ups1500lx] driver = blazer_usb vendorid = 0001 productid = 0000 subdriver = krauler desc = "SoundHouse CLASSIC PRO UPS 1500LX" port = auto $ sudo mv /etc/nut/upsd.users.sample /etc/nut/upsd.users $ sudo vi /etc/nut/upsd.users [{UPS管理ユーザ名}] password = {UPS管理ユーザ パスワード} allowfrom = localhost upsmon master $ sudo mv /etc/nut/upsmon.conf.sample /etc/nut/upsmon.conf $ sudo vi /etc/nut/upsmon.conf MONITOR ups1500lx@localhost 1 {UPS管理ユーザ名} {UPS管理ユーザ パスワード} master RUN_AS_USER root NOTIFYCMD /etc/nut/notify.sh NOTIFYMSG ONLINE "UPS %s on line power" NOTIFYMSG ONBATT "UPS %s on battery" NOTIFYMSG LOWBATT "UPS %s battery is low" NOTIFYMSG SHUTDOWN "Auto logout and shutdown proceeding" NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced" NOTIFYFLAG ONLINE SYSLOG+EXEC NOTIFYFLAG ONBATT SYSLOG+EXEC NOTIFYFLAG LOWBATT SYSLOG+EXEC NOTIFYFLAG SHUTDOWN SYSLOG+EXEC NOTIFYFLAG REPLBATT SYSLOG+EXEC $ sudo vi /etc/nut/notify.sh #!/bin/bash /usr/sbin/sendmail -t << EOF From: {送信元メールアドレス} Subject: Alart form Network UPS Tools To: {送信先メールアドレス} This is auto mail from Network UPS Tools about UPS1500LX ${1} EOF $ sudo chmod 0755 /etc/nut/notify.sh $ sudo mv /etc/nut/upsd.conf.sample /etc/nut/upsd.conf $ sudo mv /etc/nut/upssched.conf.sample /etc/nut/upssched.conf
$ sudo blazer_usb -u root -a ups1500lx -DDD 0.001111 Checking device (0001/0000) (003/003) 2.012263 - VendorID: 0001 2.012302 - ProductID: 0000 2.012323 - Manufacturer: MEC 2.012333 - Product: MEC0002 2.012342 - Serial Number: unknown 2.012353 - Bus: 003 2.012364 Trying to match device 2.012412 Device matches 2.018275 Trying megatec protocol... 2.018307 send: Q1 2.635094 received 47 (40) 2.635127 read: (098.0 000.0 100.0 027 50.0 25.8 29.0 00001000 2.635274 Status read in 1 tries 2.635290 Supported UPS detected with megatec protocol ... $ upsdrvctl start ups1500lx Network UPS Tools - UPS driver controller 2.6.5 Network UPS Tools - Megatec/Q1 protocol USB driver 0.09 (2.6.5) Supported UPS detected with megatec protocol Vendor information read in 1 tries No values provided for battery high/low voltages in ups.conf Using 'guestimation' (low: 20.800000, high: 26.000000)! Battery runtime will not be calculated (runtimecal not set) $ upsdrvctl stop ups1500lx
$ sudo vi /etc/rc.d/init.d/nut #!/bin/bash # chkconfig: 2345 60 99 # description: NUT ups daemon # processname: nut # config: /etc/nut/ups.conf # pidfile: /var/state/ups source /etc/rc.d/init.d/functions RETVAL=0 prog="nut" upsdrv="/bin/upsdrvctl" drv="blazer_usb" upsd="/sbin/upsd" ups="upsd" upsmon="/sbin/upsmon" mon="upsmon" desc="NUT daemon" start() { echo -n $"Starting $desc : " daemon $upsdrv -u root start $upsd -u root $upsmon -u root RETVAL=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog return $RETVAL } stop() { echo -n $"Shutting down $desc: " killproc $drv killproc $ups killproc $mon RETVAL=$? echo [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog return $RETVAL } restart() { stop start } reload() { echo -n $"Reloading $desc: " killproc $drv -HUP killproc $ups -HUP killproc $mon -HUP RETVAL=$? echo return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload) reload ;; condrestart) [ -e /var/lock/subsys/$prog ] && restart RETVAL=$? ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|reload|condrestart|status}" RETVAL=1 esac exit $RETVAL $ sudo chmod 0755 /etc/rc.d/init.d/nut $ sudo /sbin/chkconfig --add nut $ sudo /sbin/chkconfig --list nut nut 0:off 1:off 2:on 3:on 4:on 5:on 6:off $ sudo /sbin/service nut start $ ps aux | grep ups | grep -v cupsd | grep -v grep root 31066 0.0 0.0 2160 692 ? Ss 23:22 0:00 //bin/blazer_usb -a ups1500lx -u root root 31068 0.0 0.0 5240 736 ? Ss 23:22 0:00 /sbin/upsd -u root root 31070 0.0 0.0 5120 828 ? Ss 23:22 0:00 /sbin/upsmon -u root root 31071 0.0 0.0 5120 784 ? S 23:22 0:00 /sbin/upsmon -u root $ sudo /sbin/service nut stop