Last Tested 03/30/2017
<color #ff7f27>Notice:</color> I am going to assume that you have you ups connected via usb and passed to the FreeNAS VM.
<color #00a2e8>Testing 1:</color> Run the following command in CLI upsc ups@localhost it should output information about the current battery level.
<color #b5e61d>Testing 2:</color> I would test the full configuration. Set Shutdown Mode to BATT then set shutdown time to a low number then unplug the ups and see if FreeNAS goes for shutdown.
#!/bin/bash apt-get purge nut && apt-get purge nut-client && apt-get purge nut-server rm -r * /etc/nut # simple script to setup a NUT netclient config # assumptions are Ubuntu 14.04.1, and that the nut server has only one UPS attached # and is accessible by an already configured nut user+pass. read -e -p "Do you wish to install and configure NUT from scratch (y/n): " -i "y" SETUP_NUT echo if [ ! "$SETUP_NUT" = "y" ]; then echo "OK exiting script" exit -1 fi if ! dpkg -s nut >/dev/null; then echo "installing nut package" apt-get install -q nut -y # Get the ups and server name as well as the nut user credentials needed echo "Pleae input the following info" read -e -p "Nut SERVER NAME or IP ADDRESS (needed to construct the local MONITOR line): " -i "nutserver" NUT_SERVER read -e -p "The nut UPS NAME you wish to monitor on the above server: " -i "ups" UPS_NAME read -e -p "Nut servers MONITOR USER (defined in /etc/nut/upsd.users): " -i "monmaster" NUT_USER read -e -p "and the monitor users PASSWORD: " -i "mmpass" USER_PASS # most basic of sanity checks (are any of the above empty if so exit script if [ -z "$NUT_SERVER" ]; then echo "No server name given. Exiting."; exit -1; fi if [ -z "$UPS_NAME" ]; then echo "No ups name given. Exiting."; exit -1; fi if [ -z "$NUT_USER" ]; then echo "No username given. Exiting."; exit -1; fi if [ -z "$USER_PASS" ]; then echo "No password given. Exiting."; exit -1; fi # now to construct the MONITOR line from the above info and put it on the end of /etc/nut/upsmon.conf echo "MONITOR $UPS_NAME@$NUT_SERVER 1 $NUT_USER $USER_PASS slave" | tee -a /etc/nut/upsmon.conf >/dev/null # now to replace the MODE=none with MODE=netclient in nut.conf sed -i 's/MODE=none/MODE=netclient/g' /etc/nut/nut.conf echo "starting nut-client" /etc/init.d/nut-client restart # fsd is normally called when a ups is OB (On Battery) and LB (Low Battery) # fsd = Full Shut Down echo "the following command should list current information about your ups" echo "upsc $UPS_NAME@$NUT_SERVER" echo "To test this setup it is best to reboot first then execute the following command" echo "sudo upsmon -c fsd" echo "If all is functioning correctly this will simulate the ups being in both the following states:" echo "On Battery (OB) & Low Battery (LB)" echo "In that situation the system should perform an automatic power-fail shutdown" else echo "nut package already installed, please consider removing nut first" echo "as this script expects to install and configure nut itself" echo "sudo apt-get purge nut" echo "N.B. WARNING this will remove all previous configurations" fi
<color #ff7f27>Testing 0:</color> upsc ups@serverip
<color #00a2e8>Testing 1:</color> Run the following command upsmon -c fsd it should simulate the shutdown because of a battery low alert.
<color #b5e61d>Testing 2:</color> Again I would test the full configuration. Set Shutdown Mode to BATT then set shutdown time to a low number then unplug the ups and see if FreeNAS and the Debian box go for a shutdown.