APC Smart-UPS with NIC - which service to use apcupsd or NUT?
-
@Ajmind-0 apcupsd will be most straightforward way.
I'm currently use apcupsd on xcp-ng hypervisors. One of them connected to UPS cable and other take information from apcupsd netserver.
I also have NUT that take information from apcupsd via apcupsd-ups driver. This NUT I need for synology and qnap NASes. -
Last weekend I had tested my new pool with XCP-NG 8.2.1 with apcupsd and the scripts I have found and later modified to my needs. (We use vAPPs groups to manage the start and stop order and timing of most VMs.)
We have a two node pool with the HA-Lizard extention.
(DELL R6515 / AMD EPYC 7313P 16-Core Processor)We use a APC Smart-UPS RT 8000 RM XL online ups.
We communicate via NIC /snmp.The shutdown script will shutdown first the vAPP group, second allremaining VMs third the slave host and finally the master host.
The test was performed twice and finally with the expected result.
However, as I have disovered some missing point in the test preparation, (daemon was not enabled, server BIOS no restart after AC loss selected), I have to repeat the test once again in the next two weeks.
I am sure that this will not change anything on the success of this solution and as Alexander has also confirmed that apcupsd is the most straightforward way I vote also for it.
-
@Ajmind-0 Care to share the shutdown script used to shutdown the VMs and the host?
-
Please note that the script below is a combination of various scripts found in the web. I have modified it to my needs as far as I am able to do so.
We use a two node shared storage pool with the HALizard extention in combination with the 'vapp' function, (in order to start and stop VMs in a defined order and time). If you do not use it, you could strip off these portions of the script below. Also 'sleep' is not really needed, however I am felling better with it
If you find something to improve I am happy to learn from you.
#!/bin/bash # XenCenter Custom Field for HA-Lizard HA XC_FIELD_NAME=ha-lizard-enabled # Put your pool uuid here POOL_UUID="you_pool_UUID" # get uuid of pool master MASTER_UUID=`xe pool-list params=master --minimal` # get uuid of current host CURRENT_HOST_UUID=`cat /etc/xensource-inventory | grep -i installation_uuid |egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"` # Check if current host is pool master, as only pool master should run this script if [ $CURRENT_HOST_UUID != $MASTER_UUID ] then ###(uncomment following line to exit the script) exit fi # This is supposed to switch off HA-Lizard VM restart xe pool-param-set uuid=$POOL_UUID other-config:XenCenter.CustomFields.$XC_FIELD_NAME=false sleep 5s ###enumerate uuid's of all _running_ VAPPs in the pool for VAPP in `xe appliance-list params=uuid | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"` do xe appliance-shutdown uuid=$VAPP done sleep 10s ###enumerate uuid's of all _running_ VMs in the pool for VM in `xe vm-list is-control-domain=false power-state=running params=uuid | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"` do ###(uncomment following line to perform actual shutdown) xe vm-shutdown vm=$VM done sleep 5s ###enumerate of all XCP NG hosts in the pool except master for HOST in `xe host-list params=uuid --minimal | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"` do if [ $HOST != $MASTER_UUID ] then ###(uncomment following line to put any host except master in maintenance) xe host-disable uuid=$HOST sleep 10s elif [ $HOST = $MASTER_UUID ] then ###(uncomment following line to put master in maintenance) xe host-disable uuid=$HOST fi done sleep 10s ###Shutdown all XCP NG hosts in the pool except master for HOST in `xe host-list params=uuid --minimal | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"` do if [ $HOST != $MASTER_UUID ] then ###(uncomment following line to perform actual shutdown) xe host-shutdown host=$HOST fi done sleep 10s # Before we perform the shutdown sequence we turn on again HA-Lizard HA # as after restarting we want to have the VMs in the pool running again!!! xe pool-param-set uuid=$POOL_UUID other-config:XenCenter.CustomFields.$XC_FIELD_NAME=true ###finally shutdown pool master for HOST in `xe host-list params=uuid --minimal | egrep -o "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"` do if [ $HOST = $MASTER_UUID ] then ###(uncomment following line to perform actual shutdown) xe host-shutdown host=$HOST fi done
-
-
@Ajmind-0
Thanks for the script.How does one enumerate the pool uuid for a given pool? I see what I believe to be the pool uuid right below the title of the pool in the XOA Pool page but I'd like to be sure it is indeed the correct pool uuid. I searched for the correct command but failed. xe something? xe pool-param-get what?
-
xe pool-param-list uuid=
thenTAB
key twice. -
@olivierlambert
Thanks. I was able to confirm the pool uuid. -
Hi,
Interesting topic. Is there a best-practice for installing apcupsd on XCP-ng hosts? I would like to keep things as clean as possible.
-
@Strebor
You can download it from here:
https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/a/apcupsd-3.14.14-18.el7.x86_64.rpm
and install.
That is easiest way.
Or you may enable epel repository and install from it. -
@Alexander-0 Thanks!
I'll compare this to my original notes (still from Xenserver 6 era, but used on 7 and 8 too)