galiacyj's Posts

Hey there ! I recently had to think of a solution to do this, here's what I've come up with. This works with SSH-enabled ESXi host, I'm using ESXi 4.1 U1 (free licence) but this should work o... See more...
Hey there ! I recently had to think of a solution to do this, here's what I've come up with. This works with SSH-enabled ESXi host, I'm using ESXi 4.1 U1 (free licence) but this should work on version 5 too. First, I've plugged my UPS with the USB cable to a dedicated machine running Windows (XP in my case, but that's not important). Using the dedicated software of my UPS, I've set it to run a batch-script when UPS battery was low. I then found, on the putty download page ( http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html via http://www.putty.org ) a tool called plink.exe This is a command-line tool that allows you to create a ssh connection (or telnet or else - any connection putty can manage) and then execute one "line" of shell commands (nothing prevents you to do command1 & command2 etc.). Next up, the batch script, pretty simple @echo off <pathtoplink.exe>\plink.exe -ssh -2 -pw <password> root@ip "command" And that's it The command can be anything from a simple "halt" to a shell (.sh) script you've written and placed on your ESXi host. Note : you can also use ssh keys to avoid using user/password, the plink tool works the same as putty I've tested this and it works perfectly, I'm also using this very useful tool to schedule backup tasks on the ESXi, without having to manipulate the rc.local or cron files Hope it helps ps : for this to work, the dedicated machine AND the network switches must be on some kind of UPS as well