wy艂膮czanie esxi ze zwyk艂ego ups na usb

Dokona艂a si臋 rewolucja w domowym sprz臋cie, serwer ju偶 nie dzia艂a na unraidzie z jego wywalaj膮cymi si臋 pluginami, tylko jest hostem darmowego vmware esxi 5.5.

Pok艂osiem tych zmian b臋dzie pewnie par臋 notek o linuksiarstwie i rozwi膮zywaniu problem贸w.
Jednym z problem贸w by艂 shutdown serwera a wcze艣niej bezpieczne zamkni臋cie maszyn wirtualnych – po co nara偶a膰 domowe archiwum na problemy.

W domu mam tylko zwyk艂e, proste ups, fideltronika 500 do sieci a serwer jest podpi臋ty do apc back ups cs 650 z w艂asnor臋cznie zrobionym kablem usb.

Esxi nie widzi tego ups, po sieci go nie puszcz臋, takie rzeczy to smart ups z kart膮 sieciow膮 za tysiaka.

Ale znalaz艂em linuksiarskie obejscie: usb passthrough tego ups do linuxowego hosta a tam apcusbd kt贸ry zrobi shutdown esxi, kt贸ry przez zamkni臋ciem siebie w odpowiedniej kolejno艣ci powy艂膮cza maszyny wirtualne.

Znalezione tutaj, copypasta dla potomno艣ci:

Enable SSH access on your ESXi host
Create a Linux VM – I use Ubuntu. You only need a very minimal setup – no GUI or anything.
Connect your APC device via USB to the ESXi host and pass it through to the Linux VM.
Make sure that the USB controller you add to the VM matches the actual, physical USB controller the APC device is connected to, i.e. only add an XHCI controller if the physical device is a USB3 device. Mismatches seem to cause odd problems in the Linux USB device driver.
If things aren’t working out and you see errors like ctrl urb status -62 in dmesg, chances are the physical controller doesn’t match the one in your VM. If they do match – well then it’s a problem. I have one setup with this sort of problem and no real solution to it.
Install apcupsd on the Linux VM – in Ubuntu, you can do sudo apt-get install apcupsd to install the latest version. The NUT project is also nice but I am a traditionalist.
Install the plink utility by doing sudo apt-get install putty-tools
Connect to your ESXI host by doing plink root@. You can close the connection immediately. The objective is to get the host key saved so plink won’t prompt for it again when we run it via a script
Edit /etc/apcupsd/apcupsd.conf and change the items below so they match:
UPSNAME < the name you'd like your UPS to have >
UPSCABLE usb
UPSTYPE usb
Also make sure that /etc/default/apcupsd has ISCONFIGURED=yes
Edit /etc/apcupsd/apccontrol and scroll to the doshutdown case. Make it look like this:
doshutdown)
echo "UPS ${2} initiated Shutdown Sequence" | ${WALL}
# Shut down indirectly by triggering the ESXi host to do the
# shutdown via VMWare tools
/usr/bin/plink root@< your ESXi host IP > -pw Cde32wsx "/sbin/shutdown.sh && /sbin/poweroff"
;;

Restart apcupsd using sudo service apcupsd restart and see if things are working by invoking apcaccess. If not, check logs and dmesg
Make sure all VMs that need to shut down nicely in case of a power failure have VMWare Tools installed. Also make sure that they are part of the VM startup/shutdown list (in the vSphere Web Client, go to: vCenter -> -> Manage -> Settings -> VM Startup/Shutdown). Make sure that the shutdown action is to shut down the guest OS.
Once you have these things running, the doshutdown scriptlet from step 8 gets invoked on a power failure. This is turn invokes the shutdown.sh script on the ESXi host, which signals the VMWare Tools package in each VM on your host to do a clean shut down via the guest OS. In my experience, it works better than the PowerChute software from APC.

If you like to monitor things from your VMs, you can setup slave apcupsd instances on them that connect to the master UPS control Linux VM. Your slave apcupsd.conf files should have an entry like this:
UPSTYPE net < your UPS control VM IP >:3551
Entries like UPSCABLE and such do not matter in this case. This works with the Windows version of apcupsd (available here) as well. You can use the included apctray.exe to check out the current status of things.

That pretty much covers it, I think.

wy艂膮czanie esxi ze zwyk艂ego ups na usb