The final battle in my quest for properly integrated UPS Monitoring was to get my ESXi 4.1 box into the mix.
Some rummaging around online turned up a NUT Client for ESXi 5 (french) which doesn’t work for ESXi 4, fortunately the same guy has also done a NUT Client for ESXi 4 (french) which will work, but takes some effort.
The tricky part is that it seems that the only way to customise an ESXi 4 install is via oem.tgz, whereas in ESXi 5 we have the concept of “packages”, I broke my ESXi box several times figuring out how to actually do this properly so I figure I might as well write it up for others (also it’s probably good to have a native English version rather than having to go through the peril of Google Translate.)
- Enable SSH access on your ESXi box;
- Login to vSphere
- Select host
- Configuration -> Security Profile
- Firewall -> Properties…
- Remote Tech Support (SSH) -> Options…
- Click Start
SSH into your ESXi box and do the following;
~ # cp /bootbank/* /altbootbank/ # not necessary but recommended, backs up your bootbank ~ # cp /bootbank/oem.tgz /bootbank/oem.tgz.orig ~ # cd /tmp /tmp # mkdir oem /tmp # cd oem /tmp/oem # tar -zxf /bootbank/oem.tgz /tmp/oem # cd .. /tmp # wget http://rene.margar.fr/downloads/oem.tgz Connecting to rene.margar.fr (220.127.116.11:80) oem.tgz 100% |*******************************| 40871 00:00:00 ETA /tmp # cd oem/ /tmp/oem # tar -zxf ../oem.tgz
Once that’s done you’ve got a “merged” tree of the existing oem.tgz and the NUT oem.tgz, next step is to go edit etc/ups/upsmon.conf to add a MONITOR clause for your UPS, and then update etc/ups/notify.sh if you want email notifications (If you don’t want notifications, just comment out the NOTIFYCMD line in upsmon.conf).
Once you’re happy with the config you need to re-pack the oem.tgz, the trick here (took several attempts and one ESXi rebuild to get this right…) is that your .tgz must NOT have leading ./ in the paths, the way to do this is pretty simple;
/tmp/oem # tar -zcf /bootbank/oem.tgz bin/ etc/ lib/ oem.txt sbin/ usr/ var
Now reboot, and if all’s well ESXi will boot up happily, if it doesn’t consult the troubleshooting section below.
Once ESXi has booted up, SSH back in and run;
~ # upsmon Network UPS Tools upsmon 2.4.3 UPS: compaq3kva@lodestone (slave) (power value 1) Using power down flag file /etc/killpower
It you’re seeing that then it looks like you’re all good, now to test the shutdown script issue the following;
~ # upsmon -c fsd
ESXi should shut itself down shortly thereafter.
If that all works then you’re done.
If your ESXi box pink screens, you probably cocked up the oem.tgz, at the loading screen do a “Shift+O” and give the additional option “noOem”, this will prevent ESXi from loading the oem.tgz, then you can SSH back in and try again.
If the above doesn’t work then you’ve REALLY screwed something up (like say, when I DELETED the oem.tgz file… Protip: DON’T DO THAT) for that “Shift+R” will switch you over to the “altbootbank” (actually it swaps the contents of bootbank and altbootbank), which will revert you to the original state (assuming you did the backup as suggested in the above code), SSH in and try again.
If that doesn’t work you can boot the install CD, switch to a console with “Alt-F1” and copy the oem.tgz.orig file back to oem.tgz.
If that doesn’t work then you’ve done something REALLY special and I can’t help 😉