XenServer and APC UPS protection



  • So this topic here outlines what needs to be done to power off your VM's and host.

    Sadly it requires a physical installation of Windows, with XenCenter, and APCs PowerChute software to operate. This to me seems insane.

    So what are others doing to shutdown your VM's and hosts using your UPS?



  • I know XO has the emergency shutdown function, but there has to be some way (besides the above) to be able to do this.



  • apcupsd should handle this for you. It's worked for me with a number of different UPS brands, on XenServer.

    You'll might need to get fix the base yum repo fixed to get dependencies installed, it's been a while so I'm not remembering what issues I had if any.



  • @DustinB3403 said in XenServer and APC UPS protection:

    So this topic here outlines what needs to be done to power off your VM's and host.

    Sadly it requires a physical installation of Windows, with XenCenter, and APCs PowerChute software to operate. This to me seems insane.

    So what are others doing to shutdown your VM's and hosts using your UPS?

    My config just shuts down the host with 10 minutes of battery power left. XenServer tries to shut down any guests nicely before turning off. The standard wait time is 3 minutes for shutting down the guests, which is why I start it at the 10 minute mark.



  • I wonder if this could be integrated into XO some how.. . .



  • @DustinB3403 said in XenServer and APC UPS protection:

    I wonder if this could be integrated into XO some how.. . .

    Ah, here we go the Mint repos have apcupsd-cgi. Which is a web interface. Even if it's not already implemented, it shouldn't be to hard to integrate it as an add on.



  • Hrm... I'll take a look into it.



  • I wonder if APCUPSD works with networked UPS as well..

    As that would be the goal, completely skip USB integration and go to the network.



  • @DustinB3403 said in XenServer and APC UPS protection:

    I wonder if APCUPSD works with networked UPS as well..

    As that would be the goal, completely skip USB integration and go to the network.

    I think it can, but I haven't set that up. Would be silly to me if it couldn't, but I've seen to many silly missing things in my life already, one more wouldn't be a surprise.



  • Yeah.. my issue is that XS integration with USB means you either have to grant all VM's access to the device, or nothing at all.

    Which is what I'd want to avoid. Having to dedicate a Windows system just to operate XC in the event of losing power, while simple, seems really stupid and expensive, not to mention dangerous has you have to have a system connected to your hosts using the root credentials through XC, but it most likely would be completely un-monitored.

    XO's emergency mode is a good solution, but it requires action from an administrator.



  • @DustinB3403 said in XenServer and APC UPS protection:

    Yeah.. my issue is that XS integration with USB means you either have to grant all VM's access to the device, or nothing at all.

    Which is what I'd want to avoid. Having to dedicate a Windows system just to operate XC in the event of losing power, while simple, seems really stupid and expensive, not to mention dangerous has you have to have a system connected to your hosts using the root credentials through XC, but it most likely would be completely un-monitored.

    XO's emergency mode is a good solution, but it requires action from an administrator.

    Either you completely missed my point, or I wasn't very clear.

    XenServer shuts down the guests for you, no need for them all to have access to the usb.


  • Service Provider

    @travisdh1 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    Yeah.. my issue is that XS integration with USB means you either have to grant all VM's access to the device, or nothing at all.

    Which is what I'd want to avoid. Having to dedicate a Windows system just to operate XC in the event of losing power, while simple, seems really stupid and expensive, not to mention dangerous has you have to have a system connected to your hosts using the root credentials through XC, but it most likely would be completely un-monitored.

    XO's emergency mode is a good solution, but it requires action from an administrator.

    Either you completely missed my point, or I wasn't very clear.

    XenServer shuts down the guests for you, no need for them all to have access to the usb.

    Right, you tell the hypervisor to shut down. Its normal process should already be setup to handle graceful shutdown of the guests.


  • Service Provider

    @DustinB3403 also depending on the model of your UPS, you could go with an Raspberry Pi and either NUT or APCUPSD to monitor the UPS and send the shutdown command to XS.



  • @travisdh1 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    Yeah.. my issue is that XS integration with USB means you either have to grant all VM's access to the device, or nothing at all.

    Which is what I'd want to avoid. Having to dedicate a Windows system just to operate XC in the event of losing power, while simple, seems really stupid and expensive, not to mention dangerous has you have to have a system connected to your hosts using the root credentials through XC, but it most likely would be completely un-monitored.

    XO's emergency mode is a good solution, but it requires action from an administrator.

    Either you completely missed my point, or I wasn't very clear.

    XenServer shuts down the guests for you, no need for them all to have access to the usb.

    No I didn't miss the point, the official way to do this from Citrix is to dedicate a physical windows system. That was my point.



  • @JaredBusch said in XenServer and APC UPS protection:

    @DustinB3403 also depending on the model of your UPS, you could go with an Raspberry Pi and either NUT or APCUPSD to monitor the UPS and send the shutdown command to XS.

    I considered this, but don't have any to work with.



  • @DustinB3403 said in XenServer and APC UPS protection:

    @travisdh1 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    Yeah.. my issue is that XS integration with USB means you either have to grant all VM's access to the device, or nothing at all.

    Which is what I'd want to avoid. Having to dedicate a Windows system just to operate XC in the event of losing power, while simple, seems really stupid and expensive, not to mention dangerous has you have to have a system connected to your hosts using the root credentials through XC, but it most likely would be completely un-monitored.

    XO's emergency mode is a good solution, but it requires action from an administrator.

    Either you completely missed my point, or I wasn't very clear.

    XenServer shuts down the guests for you, no need for them all to have access to the usb.

    No I didn't miss the point, the official way to do this from Citrix is to dedicate a physical windows system. That was my point.

    They must have a reason for it, but, why? Just, why? Is this another "Software RAID is bad" scenario from them?



  • @travisdh1 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    @travisdh1 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    Yeah.. my issue is that XS integration with USB means you either have to grant all VM's access to the device, or nothing at all.

    Which is what I'd want to avoid. Having to dedicate a Windows system just to operate XC in the event of losing power, while simple, seems really stupid and expensive, not to mention dangerous has you have to have a system connected to your hosts using the root credentials through XC, but it most likely would be completely un-monitored.

    XO's emergency mode is a good solution, but it requires action from an administrator.

    Either you completely missed my point, or I wasn't very clear.

    XenServer shuts down the guests for you, no need for them all to have access to the usb.

    No I didn't miss the point, the official way to do this from Citrix is to dedicate a physical windows system. That was my point.

    They must have a reason for it, but, why? Just, why? Is this another "Software RAID is bad" scenario from them?

    Yeah I don't know, the ups monitoring solution is use a Windows system, install the software and connect xencenter to your servers.



  • @DustinB3403 said in XenServer and APC UPS protection:

    @travisdh1 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    @travisdh1 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    Yeah.. my issue is that XS integration with USB means you either have to grant all VM's access to the device, or nothing at all.

    Which is what I'd want to avoid. Having to dedicate a Windows system just to operate XC in the event of losing power, while simple, seems really stupid and expensive, not to mention dangerous has you have to have a system connected to your hosts using the root credentials through XC, but it most likely would be completely un-monitored.

    XO's emergency mode is a good solution, but it requires action from an administrator.

    Either you completely missed my point, or I wasn't very clear.

    XenServer shuts down the guests for you, no need for them all to have access to the usb.

    No I didn't miss the point, the official way to do this from Citrix is to dedicate a physical windows system. That was my point.

    They must have a reason for it, but, why? Just, why? Is this another "Software RAID is bad" scenario from them?

    Yeah I don't know, the ups monitoring solution is use a Windows system, install the software and connect xencenter to your servers.

    Which to me seems insane, the hypervisor should support this without the need to use a Windows system.

    Although it's simple, it just seems like a poor solution.


  • Service Provider

    @DustinB3403 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    @travisdh1 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    @travisdh1 said in XenServer and APC UPS protection:

    @DustinB3403 said in XenServer and APC UPS protection:

    Yeah.. my issue is that XS integration with USB means you either have to grant all VM's access to the device, or nothing at all.

    Which is what I'd want to avoid. Having to dedicate a Windows system just to operate XC in the event of losing power, while simple, seems really stupid and expensive, not to mention dangerous has you have to have a system connected to your hosts using the root credentials through XC, but it most likely would be completely un-monitored.

    XO's emergency mode is a good solution, but it requires action from an administrator.

    Either you completely missed my point, or I wasn't very clear.

    XenServer shuts down the guests for you, no need for them all to have access to the usb.

    No I didn't miss the point, the official way to do this from Citrix is to dedicate a physical windows system. That was my point.

    They must have a reason for it, but, why? Just, why? Is this another "Software RAID is bad" scenario from them?

    Yeah I don't know, the ups monitoring solution is use a Windows system, install the software and connect xencenter to your servers.

    Which to me seems insane, the hypervisor should support this without the need to use a Windows system.

    Although it's simple, it just seems like a poor solution.

    Does a shutdown command to XS from an SSH session initiate the guest shutdowns?

    If so, any UPS monitor tool will work because they can all initiate commands.



  • @JaredBusch Yes SSH works to shutdown a host and guest.



  • @DustinB3403

    This is what I started playing with. Have you seen this yet?

    Comes with a script and everything.

    https://pantsmanuk.org/2015/04/apcupsd-running-on-citrix-xenserver-7-0/



  • @BRRABill said in XenServer and APC UPS protection:

    @DustinB3403

    This is what I started playing with. Have you seen this yet?

    Comes with a script and everything.

    https://pantsmanuk.org/2015/04/apcupsd-running-on-citrix-xenserver-7-0/

    I haven't seen that, but I will definitely take a look, nice find.



  • Here is the original article that PantsManUK converted for his installation. The article is from 2013, so it is is out of date. This is very much worth trying. If I get the chance I'll test it in my lab at home.

    Quoted from with pertinent parts highlighted from

    Citrix Xenserver does not include UPS / UPS services or setting options.

    The Windows version:

    From a host with Xencenter installed, The following command posted to shut down a VM:

    Xe.exe -s <XenServer-IP> -u root -pw password vm-shutdown vm = VM name
    However, why should a VM host system be dependent on another Windows host for a shutdown in case of power failure?

    My conclusion: NOT recommended, if UPS can be operated directly at the Xenhost (USB, Network or Serial connection)

    The Linux variant:

    In Linux, the apcupsd solution is called , which is actually contained in each distribution, or can be installed by repository. Stupid only the Xenserver (stripped down CentOS) is not the case. However, it is possible to manually install and customize the RPM package from the official CentOS repository on the Xenserver. However, in order to shut down the VM guests, mail notification, message in the Xencenter, several steps, more precisely script adaptions are required.

    Apcupsd at the Xenserver, an overview:

    Apcupsd, Daemon from CentOS
    Apcupsd.conf, customized configuration file, calls vm_shutdown.sh, log entry in Xencenter application.
    Vm_shutdown.sh, Shutdown of all VM guests on the local Xenserver (only local VMs if Xenserver in pool !!)
    Sendemail, package for simple SMTP sending the UPS status mails
    Mailconfigs, changeme; commfailure; commok; offbattery; onbattery; sendemail.conf

    Xenserver apcupsd Installation Instructions (Using Tar File):

    As always, "at your own risk", the operation of a Linux host with shell commands should be common ๐Ÿ˜‰

    1. Download the tar file to the Xenhost

    Cd ~
    mkdir apc
    cd apc`````` wget http://www.flurweg.net/linux/xenserver/apcupsd/xenserver6_apcupsd.tar

    1. Unpack files

    Tar xvf xenserver6_apcupsd.tar

    1. Installing apcupsd

    Yum localinstall -nogpgcheck apcupsd-3.14.10-1.el5.i386.rpm

    1. Error message in Xenserver version 6.2: Error: Can not find a valid base for repo: citrix

    Solution: Open the /etc/yum.repos.d/Citrix.repo file and temporarily disable this repository:

    [ 
    Citrix ] name = XenServer 6.2.0 updates 
    mirrorlist = http: //updates.vmd.citrix.com/XenServer/6.2.0/domain0/mirrorlist #baseurl 
    = http: //updates.vmd.citrix.com/XenServer/ 6.2.0 / domain0 / 
    gpgcheck = 1 
    gpgkey = http: //updates.vmd.citrix.com/XenServer/RPM-GPG-KEY-6.2.0 
    enabled = 0
    
    1. Back up the existing / original configuration files

    Mkdir -p /etc/apcupsd/org
    cp /etc/apcupsd/ * /etc/apcupsd/org

    1. Copy the new configuration files (overwrite: YES [y])

    Cp -f /etc/apcupsd/ * /etc/apcupsd/

    1. Customize the mail settings in /etc/apcupsd/sendemail.conf

    Nano /etc/apcupsd/sendemail.conf

    1. Install the Sendemail

    Cp usr /bin/sendemail/usr/bin/sendmail
    chmod + x /usr/bin/sendemail

    1. Testing the notification via e-mail, for example. With:

    Sh /etc/apcupsd/changeme

    1. Customize the apcupsd.conf configuration

    (The included apcupsd.conf is configured for a Smart APC-650 via USB interface)

    About apcupsd:

    UPS Check communication, output values:

    Apcaccess
    Configure APC UPS:

    Apctest
    However, the service has to be terminated before, (do not forget after the configuration!)

    /etc/init.d/apcupsd stop
    apctest
    /etc/init.d/apcupsd start
    Other tips:

    Xenserver firewall, unblock port:

    If you want to read the values โ€‹โ€‹of the UPS connected to the Xenserver (NISIP) from another Linux host with installed CGI-Multimon, the Xenserver firewall stands in the way. You must open Tcp Port 3551 by editing the / etc / sysconfig / iptables file, the line: "-A RH-Firewall-1-INPUT -p tcp -m tcp -dport 631 -j ACCEPT" and Reinsert it. Change the port to 3551 in this copied line:

    -A RH firewall-1-INPUT -p tcp -m tcp -dport 3551 -j ACCEPT
    Then restart the iptables service:

    /etc/init.d/iptables restart
    On the Multimon host under /etc/apcupsd/hosts.conf enter the Xenserver IP.

    APCUPSD Multimon on Debian host with lighttpd:

    Installation:

    Apt-get install lighttpd apcupsd-cgi
    CGI on lighttpd Enable web server:

    Lighty-enable-mod cgi
    Cgi-bin Create symlink:

    Ln -s /usr/lib/cgi-bin/ /var/www/cgi-bin
    Create short line with redirection:

    Mkdir /var/www/apc
    /var/www/apc
    nano index.html
    The directory /var/www/apc creates an "index.html" with the following content:

    Enter the Xenserver Host into the Multimon Page in the /etc/apcupsd/hosts.conf file:

    MONITOR 192.168.8.6 "Xenserver"



  • @DustinB3403 That's a lot of stuff to do rather than just fixing the /etc/yum.repos.d/CentOS-Base.repo file. The line

    mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
    

    needs replaced. For XS7

    mirrorlist=http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os
    

    Then you just need to run

    yum --enablerepo=base install apcupsd sendmail


  • The link is more recent, because he mention XS 7.

    I got acancel AARP (done, should have check by 4/13 and no mailings by 6 weeks from 3/16)I got about 50% of the way into this, and had to move on to other projects. But I really need to get back to it.



Looks like your connection to MangoLassi was lost, please wait while we try to reconnect.