Monitoring multiple redundant UPSs

Status
Not open for further replies.

marksibert

Cadet
Joined
Jun 5, 2018
Messages
7
Hi! I tried searching to see if anyone else had successfully gotten FreeNAS configured to monitor multiple redundant UPSs, but couldn't find an answer. I was able to find the following information:
  • UPS configuration files are in /etc/local/nut
  • The files are created automatically on boot/service restart/service config by the /etc/ix.rc.d/ix-ups script (so directly modifying the files in /etc/local/nut will not work.)
I used the web UI to configure monitoring for UPS1, and it works fine. So no issues there. Tested and verified.

I was able to get UPS2 added to /etc/local/nut/ups.conf by simply adding some lines to the "Auxiliary parameters (ups.conf)" section in the UPS service configuration:
Code:
[ups2]
	driver = usbhid-ups
	port = /dev/ugen4.3
	desc = "UPS 2"


I stopped/restarted the UPS service and verified the changes showed up in ups.conf.

upsmon.conf was trickier, since there is no "auxillary parameters" section in the UI for that file. So I added a line to the ix-ups script:
MONITOR ups2 1 ${user} ${passwd} ${ups_mode}

I stopped/restarted the UPS service and verified the changes showed up in upsmon.conf.

I pulled the power cord on UPS1, and got *two* email notifications, indicating that both UPS1 and UPS2 were on battery. Only UPS1 was on battery. When I restored power, I again got two email notifications that UPS1 and UPS2 were "online".

I then pulled the power cord on UPS2, and no email notification was sent at all.

The console logs show the same thing. So I obviously have something configured wrong. I just can't figure out what it is.

/etc/local/nut/ups.conf:
Code:
[ups1]
	driver = usbhid-ups
	port = /dev/ugen4.2
	desc = "UPS 1"
[ups2]
	driver = usbhid-ups
	port = /dev/ugen4.3
	desc = "UPS 2"

/etc/local/nut/upsmon.conf:
Code:
MONITOR ups1 1 upsmon ******** master
MONITOR ups2 1 upsmon ******** master
NOTIFYCMD "/usr/local/sbin/upssched"
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+EXEC
NOTIFYFLAG FSD SYSLOG+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+EXEC
SHUTDOWNCMD "/sbin/shutdown -p now"
POWERDOWNFLAG /etc/nokillpower

/etc/local/nut/upssched.conf:
Code:
CMDSCRIPT   /usr/local/bin/custom-upssched-cmd
PIPEFN	  /var/db/nut/upssched.pipe
LOCKFN	  /var/db/nut/upssched.lock

AT NOCOMM   * EXECUTE EMAIL
AT COMMBAD  * START-TIMER COMMBAD 10
AT COMMOK   * CANCEL-TIMER COMMBAD COMMOK
AT FSD	  * EXECUTE EMAIL
AT LOWBATT  * EXECUTE EMAIL
AT ONBATT   * START-TIMER ONBATT 30
AT ONBATT   * EXECUTE EMAIL
AT ONLINE   * CANCEL-TIMER ONBATT ONLINE
AT ONLINE   * EXECUTE EMAIL
AT REPLBATT * EXECUTE EMAIL
AT SHUTDOWN * EXECUTE EMAIL

/etc/local/nut/upsd.conf:
Code:
LISTEN 127.0.0.1

/etc/local/nut/upsd.users:
Code:
[upsmon]
	password = ********
	upsmon master

/etc/ix.rc.d/ix-ups (partial):
Code:
generate_upsmon()
{
	local IFS="|"
	local f="ups_mode ups_remotehost ups_remoteport ups_monuser ups_monpwd ups_identifier ups_shutdown ups_shutdowntimer ups_shutdowncmd ups_nocommwarntime ups_emailnotify ups_toemail ups_subject ups_powerdown"
	eval local $f
	local sf=$(var_to_sf $f)
	local user passwd ident powerdown
	${FREENAS_SQLITE_CMD} ${RO_FREENAS_CONFIG} \
		"SELECT $sf FROM services_ups ORDER BY -id LIMIT 1" | \
		while eval read $f; do

				user=`echo ${ups_monuser}|sed -E 's/([#$])/\\\1/g'`
				passwd=`/usr/local/bin/midclt call notifier.pwenc_decrypt ${ups_monpwd}|sed -E 's/([#$])/\\\1/g'`
				if [ "${ups_mode}" = "master" ]; then
						ident="${ups_identifier}"
				else
						ident="${ups_identifier}@${ups_remotehost}:${ups_remoteport}"
				fi
				if [ "${ups_powerdown}" = "1" ]; then
						powerdown="/etc/killpower"
				else
						powerdown="/etc/nokillpower"
				fi

				cat <<EOF
FINALDELAY ${ups_shutdowntimer}
MONITOR ${ident} 1 ${user} ${passwd} ${ups_mode}
MONITOR ups2 1 ${user} ${passwd} ${ups_mode}
NOTIFYCMD "/usr/local/sbin/upssched"
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+EXEC
NOTIFYFLAG FSD SYSLOG+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+EXEC
SHUTDOWNCMD "${ups_shutdowncmd}"
POWERDOWNFLAG ${powerdown}
EOF

				if [ -n "${ups_nocommwarntime}" ]; then
						echo "NOCOMMWARNTIME ${ups_nocommwarntime}"
				fi

	done
}

Any ideas on what else I need to change? My hardware setup is a Supermicro server with redundant power supplies. Each power supply is plugged into its own UPS. (Each UPS is plugged into a separate power circuit.) While it's unlikely that UPS2 would lose power without UPS1, it would be nice to have the monitoring working properly.

Aside from usb.conf and usbmon.conf man pages, I also read the "bigservers.txt" file where it describes configuring UPS monitoring for multiple redundant UPSs. (http://www.susaaland.dk/sharedoc/nut-2.0.3/docs/big-servers.txt) As far as I can tell, what I have should work.

Any help is greatly appreciated! Thanks!!
 

Chris Moore

Hall of Famer
Joined
May 2, 2015
Messages
10,080
Any ideas on what else I need to change? My hardware setup is a Supermicro server with redundant power supplies. Each power supply is plugged into its own UPS. (Each UPS is plugged into a separate power circuit.) While it's unlikely that UPS2 would lose power without UPS1, it would be nice to have the monitoring working properly.
FreeNAS is only designed to monitor one UPS. Just monitor one and if it gets to low battery state shutdown the NAS.
Redundant power supplies are more about protecting yourself from a power supply failure and are usually plugged to the same power source, not to three separate UPS units.
 

Dieter Toews

Dabbler
Joined
Jul 21, 2016
Messages
21
Hi! I tried searching to see if anyone else had successfully gotten FreeNAS configured to monitor multiple redundant UPSs, but couldn't find an answer. I was able to find the following information:
  • UPS configuration files are in /etc/local/nut
  • The files are created automatically on boot/service restart/service config by the /etc/ix.rc.d/ix-ups script (so directly modifying the files in /etc/local/nut will not work.)
I used the web UI to configure monitoring for UPS1, and it works fine. So no issues there. Tested and verified.

I was able to get UPS2 added to /etc/local/nut/ups.conf by simply adding some lines to the "Auxiliary parameters (ups.conf)" section in the UPS service configuration:
Code:
[ups2]
	driver = usbhid-ups
	port = /dev/ugen4.3
	desc = "UPS 2"


I stopped/restarted the UPS service and verified the changes showed up in ups.conf.

upsmon.conf was trickier, since there is no "auxillary parameters" section in the UI for that file. So I added a line to the ix-ups script:
MONITOR ups2 1 ${user} ${passwd} ${ups_mode}

I stopped/restarted the UPS service and verified the changes showed up in upsmon.conf.

I pulled the power cord on UPS1, and got *two* email notifications, indicating that both UPS1 and UPS2 were on battery. Only UPS1 was on battery. When I restored power, I again got two email notifications that UPS1 and UPS2 were "online".

I then pulled the power cord on UPS2, and no email notification was sent at all.

The console logs show the same thing. So I obviously have something configured wrong. I just can't figure out what it is.

/etc/local/nut/ups.conf:
Code:
[ups1]
	driver = usbhid-ups
	port = /dev/ugen4.2
	desc = "UPS 1"
[ups2]
	driver = usbhid-ups
	port = /dev/ugen4.3
	desc = "UPS 2"

/etc/local/nut/upsmon.conf:
Code:
MONITOR ups1 1 upsmon ******** master
MONITOR ups2 1 upsmon ******** master
NOTIFYCMD "/usr/local/sbin/upssched"
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+EXEC
NOTIFYFLAG FSD SYSLOG+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+EXEC
SHUTDOWNCMD "/sbin/shutdown -p now"
POWERDOWNFLAG /etc/nokillpower

/etc/local/nut/upssched.conf:
Code:
CMDSCRIPT   /usr/local/bin/custom-upssched-cmd
PIPEFN	  /var/db/nut/upssched.pipe
LOCKFN	  /var/db/nut/upssched.lock

AT NOCOMM   * EXECUTE EMAIL
AT COMMBAD  * START-TIMER COMMBAD 10
AT COMMOK   * CANCEL-TIMER COMMBAD COMMOK
AT FSD	  * EXECUTE EMAIL
AT LOWBATT  * EXECUTE EMAIL
AT ONBATT   * START-TIMER ONBATT 30
AT ONBATT   * EXECUTE EMAIL
AT ONLINE   * CANCEL-TIMER ONBATT ONLINE
AT ONLINE   * EXECUTE EMAIL
AT REPLBATT * EXECUTE EMAIL
AT SHUTDOWN * EXECUTE EMAIL

/etc/local/nut/upsd.conf:
Code:
LISTEN 127.0.0.1

/etc/local/nut/upsd.users:
Code:
[upsmon]
	password = ********
	upsmon master

/etc/ix.rc.d/ix-ups (partial):
Code:
generate_upsmon()
{
	local IFS="|"
	local f="ups_mode ups_remotehost ups_remoteport ups_monuser ups_monpwd ups_identifier ups_shutdown ups_shutdowntimer ups_shutdowncmd ups_nocommwarntime ups_emailnotify ups_toemail ups_subject ups_powerdown"
	eval local $f
	local sf=$(var_to_sf $f)
	local user passwd ident powerdown
	${FREENAS_SQLITE_CMD} ${RO_FREENAS_CONFIG} \
		"SELECT $sf FROM services_ups ORDER BY -id LIMIT 1" | \
		while eval read $f; do

				user=`echo ${ups_monuser}|sed -E 's/([#$])/\\\1/g'`
				passwd=`/usr/local/bin/midclt call notifier.pwenc_decrypt ${ups_monpwd}|sed -E 's/([#$])/\\\1/g'`
				if [ "${ups_mode}" = "master" ]; then
						ident="${ups_identifier}"
				else
						ident="${ups_identifier}@${ups_remotehost}:${ups_remoteport}"
				fi
				if [ "${ups_powerdown}" = "1" ]; then
						powerdown="/etc/killpower"
				else
						powerdown="/etc/nokillpower"
				fi

				cat <<EOF
FINALDELAY ${ups_shutdowntimer}
MONITOR ${ident} 1 ${user} ${passwd} ${ups_mode}
MONITOR ups2 1 ${user} ${passwd} ${ups_mode}
NOTIFYCMD "/usr/local/sbin/upssched"
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+EXEC
NOTIFYFLAG FSD SYSLOG+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+EXEC
SHUTDOWNCMD "${ups_shutdowncmd}"
POWERDOWNFLAG ${powerdown}
EOF

				if [ -n "${ups_nocommwarntime}" ]; then
						echo "NOCOMMWARNTIME ${ups_nocommwarntime}"
				fi

	done
}

Any ideas on what else I need to change? My hardware setup is a Supermicro server with redundant power supplies. Each power supply is plugged into its own UPS. (Each UPS is plugged into a separate power circuit.) While it's unlikely that UPS2 would lose power without UPS1, it would be nice to have the monitoring working properly.

Aside from usb.conf and usbmon.conf man pages, I also read the "bigservers.txt" file where it describes configuring UPS monitoring for multiple redundant UPSs. (http://www.susaaland.dk/sharedoc/nut-2.0.3/docs/big-servers.txt) As far as I can tell, what I have should work.

Any help is greatly appreciated! Thanks!!

@marksibert
I'm trying to do the same thing. Did you ever get nut/freenas to work with redundant UPSs?
 
Status
Not open for further replies.
Top