| 1 | |
| 2 | == Running APC UPS Daemon on ESX 4.1 Host == |
| 3 | |
| 4 | |
| 5 | 1) Connect serial ports on ESX Host and Smart-UPS device with a Smart Signaling Cable (e.g. 940-0024C, or 940-1524C). |
| 6 | |
| 7 | 2) Install the {{{apcupsd}}} package built for the Enterprise Linux version corresponding to that of COS. |
| 8 | |
| 9 | {{{ |
| 10 | # cat /etc/*-release |
| 11 | Red Hat Enterprise Linux Server release 5.1 (Tikanga) |
| 12 | VMware ESX 4.1 (Kandinsky) |
| 13 | # uname -sri |
| 14 | x86_64 |
| 15 | # |
| 16 | # rpm -i apcupsd-3.14.8-1.el5.x86_64.rpm |
| 17 | # |
| 18 | }}} |
| 19 | |
| 20 | 3) Modify the apcupsd run-control script to work around shared library version mismatch. |
| 21 | |
| 22 | {{{ |
| 23 | # ldd /sbin/apcupsd |
| 24 | /sbin/apcupsd: /usr/lib/vmware/lib64/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /sbin/apcupsd) |
| 25 | libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003926200000) |
| 26 | libcrypto.so.6 => /lib64/libcrypto.so.6 (0x0000003925600000) |
| 27 | libnetsnmp.so.10 => /usr/lib64/libnetsnmp.so.10 (0x0000003925a00000) |
| 28 | libgcc_s.so.1 => /usr/lib/vmware/lib64/libgcc_s.so.1 (0x0000003926800000) |
| 29 | libc.so.6 => /lib64/libc.so.6 (0x0000003924e00000) |
| 30 | /lib64/ld-linux-x86-64.so.2 (0x0000003924a00000) |
| 31 | libdl.so.2 => /lib64/libdl.so.2 (0x0000003925200000) |
| 32 | libz.so.1 => /usr/lib/vmware/lib64/libz.so.1 (0x0000003926600000) |
| 33 | # |
| 34 | # strings /usr/lib/vmware/lib64/libgcc_s.so.1 |grep GCC_4 |
| 35 | GCC_4.0.0 |
| 36 | # |
| 37 | # LD_LIBRARY_PATH="/lib64:/usr/lib64:/lib:/usr/lib" ldd /sbin/apcupsd |
| 38 | libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003926200000) |
| 39 | libcrypto.so.6 => /lib64/libcrypto.so.6 (0x0000003925600000) |
| 40 | libnetsnmp.so.10 => /usr/lib64/libnetsnmp.so.10 (0x0000003925a00000) |
| 41 | libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00002aaaaf3eb000) |
| 42 | libc.so.6 => /lib64/libc.so.6 (0x0000003924e00000) |
| 43 | /lib64/ld-linux-x86-64.so.2 (0x0000003924a00000) |
| 44 | libdl.so.2 => /lib64/libdl.so.2 (0x0000003925200000) |
| 45 | libz.so.1 => /usr/lib64/libz.so.1 (0x00002aaaaf5fa000) |
| 46 | # |
| 47 | # strings /lib64/libgcc_s.so.1 |grep GCC_4 |
| 48 | GCC_4.0.0 |
| 49 | GCC_4.2.0 |
| 50 | # |
| 51 | # |
| 52 | # cp -a /etc/rc.d/init.d/apcupsd /etc/rc.d/init.d/apcupsd.orig |
| 53 | # vi /etc/rc.d/init.d/apcupsd |
| 54 | # diff -U 2 /etc/rc.d/init.d/apcupsd.orig /etc/rc.d/init.d/apcupsd |
| 55 | --- /etc/rc.d/init.d/apcupsd.orig 2010-01-18 14:59:07.000000000 -0800 |
| 56 | +++ /etc/rc.d/init.d/apcupsd 2010-11-15 14:26:19.000000000 -0800 |
| 57 | @@ -7,4 +7,5 @@ |
| 58 | # description: apcupsd monitors power and takes action if necessary |
| 59 | # |
| 60 | +LD_LIBRARY_PATH="/lib64:/usr/lib64:/lib:/usr/lib" ; export LD_LIBRARY_PATH |
| 61 | APCPID=/var/run/apcupsd.pid |
| 62 | |
| 63 | # |
| 64 | }}} |
| 65 | |
| 66 | 4) Configure the {{{apcupsd}}} daemon. |
| 67 | |
| 68 | {{{ |
| 69 | # cp -a /etc/apcupsd/apcupsd.conf /etc/apcupsd/apcupsd.conf.orig |
| 70 | # vi /etc/apcupsd/apcupsd.conf |
| 71 | # egrep '^(UPS|DEVICE)' /etc/apcupsd/apcupsd.conf |
| 72 | UPSNAME UPS-A |
| 73 | UPSCABLE 940-0024C |
| 74 | UPSTYPE apcsmart |
| 75 | DEVICE /dev/ttyS0 |
| 76 | UPSCLASS standalone |
| 77 | UPSMODE disable |
| 78 | # |
| 79 | }}} |
| 80 | |
| 81 | 5) If need to configure UPS parameters (e.g. the {{{UPSNAME}}}), run the {{{apctest}}} utility. |
| 82 | |
| 83 | {{{ |
| 84 | # LD_LIBRARY_PATH="/lib64:/usr/lib64:/lib:/usr/lib" /sbin/apctest |
| 85 | }}} |
| 86 | |
| 87 | 6) Start the daemon. Make sure it will start again after reboot. |
| 88 | |
| 89 | {{{ |
| 90 | # service apcupsd start |
| 91 | Starting UPS monitoring: [ OK ] |
| 92 | # |
| 93 | # chkconfig apcupsd on |
| 94 | # chkconfig --list apcupsd |
| 95 | apcupsd 0:off 1:off 2:on 3:on 4:on 5:on 6:off |
| 96 | # |
| 97 | }}} |
| 98 | |
| 99 | 7) Check the UPS status. |
| 100 | |
| 101 | {{{ |
| 102 | # service apcupsd status |
| 103 | apcupsd (pid 21893) is running... |
| 104 | APC : 001,050,1203 |
| 105 | DATE : 2010-11-15 17:29:21 -0800 |
| 106 | HOSTNAME : esx41-1 |
| 107 | VERSION : 3.14.8 (16 January 2010) redhat |
| 108 | UPSNAME : UPS-A |
| 109 | CABLE : APC Cable 940-0024C |
| 110 | MODEL : Smart-UPS 3000 XL |
| 111 | UPSMODE : Stand Alone |
| 112 | STARTTIME: 2010-11-15 14:26:25 -0800 |
| 113 | STATUS : ONLINE |
| 114 | LINEV : 119.5 Volts |
| 115 | LOADPCT : 66.9 Percent Load Capacity |
| 116 | BCHARGE : 100.0 Percent |
| 117 | TIMELEFT : 25.0 Minutes |
| 118 | MBATTCHG : 5 Percent |
| 119 | MINTIMEL : 3 Minutes |
| 120 | MAXTIME : 0 Seconds |
| 121 | MAXLINEV : 119.5 Volts |
| 122 | MINLINEV : 118.8 Volts |
| 123 | OUTPUTV : 119.5 Volts |
| 124 | SENSE : High |
| 125 | DWAKE : 000 Seconds |
| 126 | DSHUTD : 090 Seconds |
| 127 | DLOWBATT : 02 Minutes |
| 128 | LOTRANS : 106.0 Volts |
| 129 | HITRANS : 127.0 Volts |
| 130 | RETPCT : 000.0 Percent |
| 131 | ITEMP : 22.5 C Internal |
| 132 | ALARMDEL : 5 seconds |
| 133 | BATTV : 55.4 Volts |
| 134 | LINEFREQ : 60.0 Hz |
| 135 | LASTXFER : Automatic or explicit self test |
| 136 | NUMXFERS : 0 |
| 137 | TONBATT : 0 seconds |
| 138 | CUMONBATT: 0 seconds |
| 139 | XOFFBATT : N/A |
| 140 | SELFTEST : NO |
| 141 | STESTI : 336 |
| 142 | STATFLAG : 0x07000008 Status Flag |
| 143 | REG1 : 0x00 Register 1 |
| 144 | REG2 : 0x00 Register 2 |
| 145 | REG3 : 0x00 Register 3 |
| 146 | MANDATE : 03/09/10 |
| 147 | SERIALNO : AS1011290020 |
| 148 | BATTDATE : 03/09/10 |
| 149 | NOMOUTV : 120 Volts |
| 150 | NOMBATTV : 48.0 Volts |
| 151 | EXTBATTS : 0 |
| 152 | FIRMWARE : 691.19.D |
| 153 | APCMODEL : FWD |
| 154 | END APC : 2010-11-15 17:29:44 -0800 |
| 155 | # |
| 156 | }}} |
| 157 | |
| 158 | 8) If there are slave APCUPSd servers on the the LAN (or want to run the {{{multimon}}} CGI script on a separate host/virtual machine), allow remote connections to the //NIS// service by creating an opening {{{(tcp#3551)}}} in the host firewall. |
| 159 | |
| 160 | {{{ |
| 161 | # esxcfg-firewall --ipruleAdd 10.4.8.32/27,3551,tcp,ACCEPT,"apcupsd" |
| 162 | # |
| 163 | # esxcfg-firewall -q |grep 3551 |
| 164 | 4 168 ACCEPT tcp -- * * 10.4.8.32/27 0.0.0.0/0 tcp dpt:3551 |
| 165 | apcupsd : host 10.4.8.32/27 cport 3551 ACCEPT tcp |
| 166 | # |
| 167 | }}} |
| 168 | |
| 169 | 9) Install MTA ({{{Postfix}}}) and MUA ({{{/bin/mail}}}) for being able to get notifications about power failures, and such. |
| 170 | |
| 171 | {{{ |
| 172 | # rpm -i --nodeps postfix-2.3.3-2.1.el5_2.x86_64.rpm |
| 173 | # rpm -i mailx-8.1.1-44.2.2.x86_64.rpm |
| 174 | }}} |
| 175 | |
| 176 | 10) Create the {{{doshutdown}}} script that will attempt graceful shutdown of all active virtual machines, and then will put host into the //Maintenance Mode//. |
| 177 | |
| 178 | {{{ |
| 179 | # vi /etc/apcupsd/doshutdown |
| 180 | # |
| 181 | # pr -to3 /etc/apcupsd/doshutdown |
| 182 | #!/bin/sh |
| 183 | # |
| 184 | # doshutdown - attempt graceful shutdown of all running VMs |
| 185 | # |
| 186 | SYSADMIN=root |
| 187 | MAIL_CMD=/bin/mail |
| 188 | VMWARE_CMD=/usr/bin/vmware-cmd |
| 189 | #DO_CMD=echo |
| 190 | DO_CMD=eval |
| 191 | HOSTNAME=`uname -n | tr '[a-z]' '[A-Z]'` |
| 192 | MSG="Initiating VM shutdown on the $HOSTNAME host" |
| 193 | # |
| 194 | ( echo "$MSG" ; echo ; /sbin/apcaccess status ) |\ |
| 195 | $MAIL_CMD -s "$MSG" $SYSADMIN |
| 196 | |
| 197 | $VMWARE_CMD -l |(while read vm; do |
| 198 | vm="`echo $vm |sed -e 's/ /\\\\ /g'`" |
| 199 | if [ -n "$vm" ]; then |
| 200 | case `eval $VMWARE_CMD $vm getstate` in |
| 201 | "getstate() = on") $DO_CMD "$VMWARE_CMD $vm stop trysoft" ;; |
| 202 | esac |
| 203 | fi |
| 204 | done) |
| 205 | /usr/bin/vmware-vim-cmd /hostsvc/maintenance_mode_enter |
| 206 | exit 0 |
| 207 | |
| 208 | ### End-Of-File |
| 209 | # |
| 210 | # chmod 744 /etc/apcupsd/doshutdown |
| 211 | # |
| 212 | }}} |
| 213 | |
| 214 | |
| 215 | === See Also === |
| 216 | |
| 217 | http://www.apcupsd.org/ \\ Apcupsd, a daemon for controlling APC UPSes |
| 218 | |