dheg Posted February 16, 2013 Share Posted February 16, 2013 Last weekend I finally decided to configure my UPS with my ESXi server. My server is running since last September, and the UPS since October, although automated shutdown wasn’t configured yet. So this has been a (one-of-many) new year resolution, and considering we are still in February, I feel quite good about it ! As I’ve gone through some research, I thought of saving you the work and make a thread of the different solutions I found: 1. CyberPower UPS. There is a post somewhere in the mother-of-all-ESXi-threads in this forum (yes, I refer to Atlas) mentioning this method. I don’t remember where it is, however, this is the to a quite informative and detailed youtube video explaining the process. As I found soon enough, I couldn’t use this solution since my UPS is an APC model. If you are in the same place, keep on reading. 2. APC UPS with NMC In the link explaining the how-to for the CyberPower UPS (http://tinkertry.com/configure-automated-shutdown-homelab-datacenter-15-minutes/), down in the comments I found what seemed quite a well documented solution for my case (it’s a long post, do a quick find for “analog_”). It seemed quite easy and promising, but of course I don’t have a NMC. For those noobs out there (I myself didn’t know what it meant) NMC stands for Network Management Card, and is priced at +200€. So this wasn’t either going to cut it. 3. APC UPS with USB Google came to the rescue, and after some surfing I found this link. Also very promising. It required to install apcupsd. At this point I had make my mind to go with the official APC solution, but if apcupsd could handle it, I was ok with that. However, the apcupsd website states “DO NOT purchase the following APC UPS models: SmartUPS SMX/SMT 750, 1000, 1500 / SmartUPS RT 3000XL, 5000XL”. Guess which one I have: SMT750. 4. APC UPS with USB and PCBE I finally decided, not that I had any other choice, to install PCBE (ParcaChute Business Edition, the official APC solution) with the provided cable. A pretty similar solution would be to connect the UPS to a Windows VM , passthrough the USB and use plink to pass the shutdown script to the ESXi host. This will probably be easier for the windows power users. However: I like taking the hard way: it’s more difficult, but also more fan With this solution, you can spare the Win license Next you'll find a step-by-step guide of the solution I took: Quote Link to comment
dheg Posted February 16, 2013 Author Share Posted February 16, 2013 Setting up ESXi 5.1 with an APC SmartUPS connected through USB Disclaimer: I’ve used these steps to connect an APC Smart-UPS 750. I have no reason to believe it wouldn’t work in other setups, but I can’t confirm. I came to this solution because I learnt that the SMT750 is not fully supported by apcusbd. As I’m a linux noob myself, I’ll try to go as in detail as possible, no intention to offend anyone ! [*]Download vMA 5.1 here (login needed) [*]Install vMA. I found a very good guide here [*]Enable SSH connections to vMA. Detailed instructions are in this link. Now you can connect through putty and copy/paste the instructions [*]Passthrough the serial port. Go to the vSphere Client, select the vMA guest and edit the properties. In the hardware tab: add a Serial Port interface Select option “Use physical serial port on the host” The port should show something like this: /dev/char/serial/uart0 Select the SmartUPS (it must be plugged) and that’s it, you have passthroughed the serial port to the vMA guest. Click Ok and power on the vMA guest. [*]Download PowerChute Business Edition for linux (pcbe910_linux.tar.gz). This is the link [*]Upload pcbe910_linux.tar.gz to vMA guest using SCP: # sudo scp <user_name>@<remote_host_ip><path_to_remote_host_dir>/pcbe910_linux.tar.gz /home/vi-admin/pcbe910_linux.tar.gz As an example, this is what I did: # sudo scp [email protected]:/home/ubuntu/pcbe910_linux.tar.gz /home/vi-admin/pcbe910_linux.tar.gz You can copy the file anywhere in vMA. I copied to my home directory to avoid permission issues. [*]CD to you user directory: # cd ~ [*]Check the file is there: # ls –l bin pcbe910_linux.tar.gz [*]Untar pcbe910_linux.tar.gz # sudo tar -zxvf pcbe910_linux.tar.gz This would add a file and a folder: # ls bin install_pbeagent_linux.sh pcbe910_linux.tar.gz rpms [*]Execute the install script. It must be as sudo: # sudo ./install_pbeagent_linux.sh [*]You will be prompt for the monitoring port. Select option 2 (RJ45). It will ask then how you are connected. Since I’m not using a NMC, just select 2 (No) Note: I chose RJ45 (option 2) and used this cable. I tried to get it to work with the usb cable without success. I prefer the serial though, it can be screwed to the port in the server and it’s more difficult to fall. Note 2: I read somewhere that the pinout in the cable provided by APC is different than in commercial cables. I cannot confirm this. However, if you are following this tutorial and fail to connect, make sure you are using the supplied APC SmartUPS serial cable. [*]Next, the configuration program will prompt you with a series of questions (enter username and password for the PCBE agent, you'll need this to access the web GUI) [*]Go to a browser and input https://<vMA_IP_address>:6547. Make sure you type https://, for some reason the web page didn’t load without it. In my browser (Firefox) I get a security warning. Just click on ‘I understand the risks’ and add the exception, and voila, you’ll see the login page! [*]Once you login, you’ll be welcome by the initial setup wizard: As in no way I’m an expert and this is very much a matter of anyone’s preferences, I won’t hold your hand here. PS: If you want to check you have connection, you can click on ‘Quick Status’ in the upper-right corner. A new window will prompt stating: Device Status: On-line (off course ) Let's go with the shutdown script so all pieces fall together Quote Link to comment
dheg Posted February 16, 2013 Author Share Posted February 16, 2013 Shutdown script Once you have configured your settings at your liking, let’s go with the shutdown script. This part was a bit tricky. I found many places making use of the vicfg-hostops command to trigger a VM/Host shutdown. And apparently, this work up to ESXi Free edition 5.0. But off course, I’m using 5.1. Dead end. I also found thisin the VM community forum. It basically emulates the vSphere Client call to shutdown the host. However, I couldn’t make it work. I ran into permission issues that couldn’t sort out (I’m a linux noob). So after some tinkering , I decided to go the easy way: to issue an ssh halt command. The shutdown script is actually very easy, it only has to send a halt order through ssh. I’ll cover that later. The tricky part here is to use Public Keys Authentication to avoid having to input the password to the ESXi host when ssh’d from a remote location. To achieve this: [*]On your vMA guest, create a pair of keys with ssh-keygen -t rsa. Choose default options and save the keys in the locations prompted. vi-admin@helios:~> ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/vi-admin/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/vi-admin/.ssh/id_rsa. Your public key has been saved in /home/vi-admin/.ssh/id_rsa.pub. The key fingerprint is: d4:cd:4f:a0:8b:0f:c2:75:99:1a:0b:9f:23:e0:32:c5 vi-admin@helios The key's randomart image is: +--[ RSA 2048]----+ | . | | . . * . | | E . + * o . | | o o = B . o | | o . + S . . | | o o + | | . | | | | | +-----------------+ [*]Now you have to copy this key into the authorized_keys file in the ESXi Host this file is in /etc/ssh/keys-root. So copy the output of cat /home/vi-admin/.ssh/id_rsa.pub into /etc/ssh/keys-root/ authorized_keys For this change to take effect you need to reboot the server, go the vSphere client and right-click on the Host > Reboot [*]That’s it, on restart now you can ssh from the vMA to the ESXi Host without a password. To test it just type ssh <user>@<IP> (in my case, I'm using user root and the IP of my ESXI host is 192.168.1.151): vi-admin@helios:~> ssh [email protected] The time and date of this login have been sent to the system logs. VMware offers supported, powerful system administration tools. Please see www.vmware.com/go/sysadmintools for details. The ESXi Shell can be disabled by an administrative user. See the vSphere Security documentation for more information. You are effectively logged in the Host shell from the vMA one (which I’m accessing from a putty session from windows, this is mind-blowing stuff !). For example, if you type ls you'll get the list of files and directories of the ESXi host, not the vMA guest. # ls altbootbank lib64 sbin var bin local.tgz scratch vmfs bootbank locker store vmimages bootpart.gz mbr tardisks vmupgrade dev opt tardisks.noauto etc proc tmp lib productLocker usr BTW, to log out from the Host inside the Guest , just type exit. We are almost there. [*]The last step would be to create the shutdown script, but before continuing is important you understand how this script works: it will send a halt command to the Host, which basically will follow the logic set up in Configuration > Virtual Machine Startup/Shutdown to shutdown the VMs. A couple of comments here: You need to define the order in which VMs need to start in the Automatic Startup. Shutdown order will be the opposite. For this to (cleanly) work, each VM needs to have installed VM tools. The Shutdown Action has to be set up to Guest Shutdown. Any other option will just power them off once the Host is down. Adjust the Startup Delay and Shutdown Delay to make sure VM are started/stopped in the proper order. In my case, many of my VMs have directories mounted on unRAID, so I have a long delay to make sure array is properly started and online before starting up the other VMs. The shutdown delay, might not be so important. According to VMWare manual: shutdown delay applies only if the virtual machine has not already shut down before the delay period elapses. If the virtual machine shuts down before that delay time is reached, the next virtual machine starts shutting down. [*]The shutdown script is actually very simple (it has to be if I did it ) #!/bin/sh # # ServerShutdown.sh - Script to trigger shutdown of Host # ssh <ESXi user>@<ESXi host IP> halt For those that need an example, the shutdown command in my case would be ssh [email protected] halt [*]APC agent scripts (Command Files in APC lingo) are located in /opt/APC/PowerChuteBusinessEdition/Agent/cmdfiles, so save/create the script there and chmod it to make it executable # sudo chmod +x ServerShutdown.sh [*]And we are done. Go the PCBE website > Shutdown Settings and configure the APC agent to trigger the shutdown script. . The script will be triggered once the conditions in the PCBE Shutdown Settings are met. I hope it works for you too ! Quote Link to comment
K2Flag Posted February 21, 2013 Share Posted February 21, 2013 Hello dheg, Thank you for this post. It seems to come right at the right time for me. I am currently working on getting Esxi5 working with a APC1500 though serial. I have done all of your steps to a T but I can't get the vMA to see the APC. I have enabled Passthough on ESXi. I am working with a Dell T420. Am I choosing the wrong options? During the install? I am choosing RJ45. Which is right. Its serial to the server and RJ45 to the APC Then it asks are you connected to a share UPS, Interface Expander or in Simple Signalling mode? I choose 1) Yes Then installs Then asks for a username and password. After that it asks Select the Signal Type i choose 1) Smart Then Select the Serial Port I've picked both on 2 different installs neither work. but i pick ([2] /dev/ttyS1) since that is the one that works with windows vm on this esxi install. I have even tried 3. Other and put in what ESXi says for the vMA /dev/char/serial/uart1 I still can't connect. Device Communications Not Established Any ideas? Thank you. Quote Link to comment
dheg Posted February 22, 2013 Author Share Posted February 22, 2013 I'm traveling and can't check right now, but make sure you install pcbe and not pcns Sent from my GT-I9100 using Tapatalk 2 Quote Link to comment
K2Flag Posted February 25, 2013 Share Posted February 25, 2013 Thank you for the reply. The file that installed on the vMA was pcbe910_linux.tar.gz Quote Link to comment
dheg Posted February 25, 2013 Author Share Posted February 25, 2013 I'll be back on Wednesday, I'll have a look then. Hope you can wait ;-) Sent from my GT-P7500 using Tapatalk 2 Quote Link to comment
mrow Posted February 26, 2013 Share Posted February 26, 2013 Thanks so much for this! I was about to have to figure this all out for myself as I'm about to move everything to VMs once I get some free time. Shame you can't get it to work with USB though. I guess I'll have to try to find where ever I put the box the UPS came in and get out the serial cable. Quote Link to comment
dheg Posted February 26, 2013 Author Share Posted February 26, 2013 Let us know how it goes. Hope it works! Sent from my GT-I9100 using Tapatalk 2 Quote Link to comment
K2Flag Posted February 27, 2013 Share Posted February 27, 2013 Still unable to get the vMA to see the serial port. Is there a linux command i can run to see if the port is even active on the vMA? Quote Link to comment
dheg Posted February 28, 2013 Author Share Posted February 28, 2013 Then it asks are you connected to a share UPS, Interface Expander or in Simple Signalling mode? I choose 1) Yes Choose option 2, this should be it. It shouldn't ask later on for smart signalling Quote Link to comment
dheg Posted February 28, 2013 Author Share Posted February 28, 2013 Still unable to get the vMA to see the serial port. Is there a linux command i can run to see if the port is even active on the vMA? try dmesg | grep ttyS This is my output: vi-admin@helios:~> dmesg | grep ttyS [ 0.421679] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A [ 0.421990] serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A [ 0.422481] 00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A [ 0.422796] 00:0a: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A Quote Link to comment
K2Flag Posted February 28, 2013 Share Posted February 28, 2013 I get... vi-admin@localhost:~> dmesg | grep ttyS [ 0.321953] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A [ 0.322451] serial8250: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A [ 0.323242] 00:09: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A [ 0.323761] 00:0a: ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A vi-admin@localhost:~> Quote Link to comment
dheg Posted February 28, 2013 Author Share Posted February 28, 2013 Ok, it detects the serial port. In the PM you sent me you chose ttyS1 instead of ttyS0, any reason for that? Sent from my GT-P7500 using Tapatalk 2 Quote Link to comment
K2Flag Posted February 28, 2013 Share Posted February 28, 2013 i used ttS1 because that is what worked with a windows server that I loaded as a test. So i assume that is the port that is open with the ESXi physical host. Quote Link to comment
dheg Posted March 1, 2013 Author Share Posted March 1, 2013 Did you try ttyS0? Sent from my GT-I9100 using Tapatalk 2 Quote Link to comment
K2Flag Posted March 6, 2013 Share Posted March 6, 2013 Okay, so I changed out the APC UPS for a new one along with a new cable. And it works.......? The other UPS was brand new out of the box also. I'm going to do some more testing today on both of them to see what's going on. Quote Link to comment
dheg Posted March 6, 2013 Author Share Posted March 6, 2013 Okay, so I changed out the APC UPS for a new one along with a new cable. And it works.......? The other UPS was brand new out of the box also. I'm going to do some more testing today on both of them to see what's going on. Who would have thought, right? Happy it's working for you Sent from my GT-P7500 using Tapatalk 2 Quote Link to comment
beire Posted July 5, 2013 Share Posted July 5, 2013 I have set this up today... All works fine EXCEPT the shutdown script. For one reason or another PowerChute BE fails at running the script. Pushing the TEST button also does nothing. When ssh'ing to the vma, and manually running the script everything shuts down fine. I have changed ownership with chown + (also tried chmod 777). Are there any logs i can view? Quote Link to comment
beire Posted July 9, 2013 Share Posted July 9, 2013 Shutdown script Once you have configured your settings at your liking, let’s go with the shutdown script. This part was a bit tricky. I found many places making use of the vicfg-hostops command to trigger a VM/Host shutdown. And apparently, this work up to ESXi Free edition 5.0. But off course, I’m using 5.1. Dead end. I also found thisin the VM community forum. It basically emulates the vSphere Client call to shutdown the host. However, I couldn’t make it work. I ran into permission issues that couldn’t sort out (I’m a linux noob). So i never got your method to work using ssh. Though the script was being run fine, the ssh entry wasn't for god knows what reason. (manual ssh command works fine) So i tried the other method you linked to ( the one you claim to not get working for you ) and after some tinkering it all works fine. I cut the power today and all vm's shut down nicely. So i'm happy So basically... Thank you for your writeup, it made my path to a working esxi setup a lot easier. Quote Link to comment
vl1969 Posted July 24, 2013 Share Posted July 24, 2013 one question though, just be gentel a total noob here how do you send shutdown command to unRaid. or any other VM for that matter? Quote Link to comment
beire Posted July 24, 2013 Share Posted July 24, 2013 one question though, just be gentel a total noob here how do you send shutdown command to unRaid. or any other VM for that matter? Vmtools should be installed on all vm's. When esxi receives a shutdown signal it will in his turn send a shutdown command to all vm's. Sent from my HTC One using Tapatalk 2 Quote Link to comment
oleg Posted July 25, 2014 Share Posted July 25, 2014 Setting up ESXi 5.1 with an APC SmartUPS connected through USB The port should show something like this: /dev/char/serial/uart0 So far so good. Select the SmartUPS (it must be plugged) and that’s it, you have passthroughed the serial port to the vMA guest. Click Ok and power on the vMA guest. I cannot select the UPS anywhere? Can you explain please? I can only select it if I pass through the USB instead of serial port. NB: I'm using VMWare 5.5. Thanks Quote Link to comment
dheg Posted July 25, 2014 Author Share Posted July 25, 2014 My advice: just try it. I have it configured in 5.1, and not planning to move to 5.5, so I'm afraid I can't help you. I do remember though, that for the life of me, i couldn't make it work through usb Sent from my GT-I9305 using Tapatalk Quote Link to comment
dheg Posted July 25, 2014 Author Share Posted July 25, 2014 Btw, are you using the serial cable that came with the ups? It's not the same that a standard one Sent from my GT-I9305 using Tapatalk Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.