When does the UPS shutdown signal gets sent to other clients?

Status
Not open for further replies.

Scampicfx

Contributor
Joined
Jul 4, 2016
Messages
125
Hey guys,

Right now my FreeNAS is connected directly via USB to CyperPower UPS. It's working fine.
There are other servers in my network which are connected via NUT to FreeNAS.

My FreeNAS is configured to start its shutdown after 300 seconds of waiting after power failure!

Shutdown timer: 300
Shutdown command: /sbin/shutdown -p now

My question: When exactly is the shutdown-signal sent to other servers in the network? Will this shutdown-signal get delayed by 300 seconds as well? Or is it sent when the shutdown command gets triggered?
 
Last edited:

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
I think the status change is immediately sent to NUT clients, who then take action according to their own rules. So make sure to have them shut down earlier than the NUT master.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Hey guys,

Right now my FreeNAS is connected directly via USB to CyperPower UPS. It's working fine.
There are other servers in my network which are connected via NUT to FreeNAS.

My FreeNAS is configured to start its shutdown after 300 seconds of waiting after power failure!

Shutdown timer: 300
Shutdown command: /sbin/shutdown -p now

My question: When exactly is the shutdown-signal sent to other servers in the network? Will this shutdown-signal get delayed by 300 seconds as well? Or is it sent when the shutdown command gets triggered?
Why don't you test it and find out?

The NUT upsmon command supports the 'Forced Shut Down' option; upsmon -c fsd. This will shut your main FreeNAS system down without draining the battery. You can use it to test your setup, including signalling remote UPS hosts.

Additional details available in the Resources section "Configuring UPS support for single or multiple FreeNAS servers" thread.

Good luck!
 

Scampicfx

Contributor
Joined
Jul 4, 2016
Messages
125
Hey thanks for your replies,

you gave me a nice hint with your postings...

I have a quick question: Is it possible to enter multiple commands in the field "Shutdown command: /sbin/shutdown -p now"?

I'm thinking of shutdown command: ssh root@esxi-server poweroff; /sbin/shutdown -p 5... It's difficult to test right now, because I'm remote and can't unplug the power supply of FreeNAS.
However, in case multiple commands are possible, this would mean I have to configure RSA fingerprint authentication (in order to avoid entering the password).
AND... :) ... it would also mean, that I don't need any NUT client on the ESXi hosts and that FreeNAS sends shutdown commands itself to all other hosts in the network (in my network, there is only one "other" host ;)).
/sbin/shutdown -p 5 ... "5" would mean to delay the shutdown of FreeNAS host by 5 minutes in order to be the last-man-standing ;)

I think the status change is immediately sent to NUT clients, who then take action according to their own rules. So make sure to have them shut down earlier than the NUT master.
Thank you. Well... The point is... Right now I'm using http://rene.margar.fr/2012/05/client-nut-pour-esxi-5-0/ as NUT client for ESXi.
When being logged in in ESXi and typing upsc ups@freenas I'm able to see the details about the battery FreeNAS is connected to.
However, from my point of view, it's hard to tell, what exactly the shutdown of FreeNAS does on the ESXi host?
The ESXi host is not shuttding down when FreeNAS does. I don't know why ESXi is not shutting down....
Reasons could be:
- the shutdown command does not reach ESXi
- the shutdown command is not sent by FreeNAS
- the NUT client only shuts down ESXi when the battery is critical? (disregarding the timer of FreeNAS) - i don't know if that's possible... my "wish" would be to shutdown ESXi when FreeNAS is running command /sbin/shutdown -p 5... This would mean the "shutdown command on FreeNAS is triggered", however FreeNAS itself delays the shutdown by 5 minutes, and ESXi performs the shutdown immediately... i tested it, but i didn't work :/
 
Last edited:

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Hey thanks for your replies,

you gave me a nice hint with your postings...

I have a quick question: Is it possible to enter multiple commands in the field "Shutdown command: /sbin/shutdown -p now"?

I'm thinking of shutdown command: ssh root@esxi-server poweroff; /sbin/shutdown -p 5... It's difficult to test right now, because I'm remote and can't unplug the power supply of FreeNAS.
However, in case multiple commands are possible, this would mean I have to configure RSA fingerprint authentication (in order to avoid entering the password).
AND... :) ... it would also mean, that I don't need any NUT client on the ESXi hosts and that FreeNAS sends shutdown commands itself to all other hosts in the network (in my network, there is only one "other" host ;)).
/sbin/shutdown -p 5 ... "5" would mean to delay the shutdown of FreeNAS host by 5 minutes in order to be the last-man-standing ;)


Thank you. Well... The point is... Right now I'm using http://rene.margar.fr/2012/05/client-nut-pour-esxi-5-0/ as NUT client for ESXi.
When being logged in in ESXi and typing upsc ups@freenas I'm able to see the details about the battery FreeNAS is connected to.
However, from my point of view, it's hard to tell, what exactly the shutdown of FreeNAS does on the ESXi host?
The ESXi host is not shuttding down when FreeNAS does. I don't know why ESXi is not shutting down....
Reasons could be:
- the shutdown command does not reach ESXi
- the shutdown command is not sent by FreeNAS
- the NUT client only shuts down ESXi when the battery is critical? (disregarding the timer of FreeNAS) - i don't know if that's possible... my "wish" would be to shutdown ESXi when FreeNAS is running command /sbin/shutdown -p 5... This would mean the "shutdown command on FreeNAS is triggered", however FreeNAS itself delays the shutdown by 5 minutes, and ESXi performs the shutdown immediately... i tested it, but i didn't work :/
Are you running FreeNAS as a VM on ESXi? Or is ESXi running on another machine?
 

Scampicfx

Contributor
Joined
Jul 4, 2016
Messages
125
Hey,

- FreeNAS is a dedicated 4U server
- ESXi is a dedicated 1U server

However, FreeNAS is providing the iSCSI targets for ESXi, which means ESXi has to get the poweroff command about 5 minutes before FreeNAS is actually performing its final-shutdown. ;)
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Hey,

- FreeNAS is a dedicated 4U server
- ESXi is a dedicated 1U server

However, FreeNAS is providing the iSCSI targets for ESXi, which means ESXi has to get the poweroff command about 5 minutes before FreeNAS is actually performing its final-shutdown. ;)
Hmmm...

I would try something like this for your FreeNAS shutdown script:
Code:
#!/bin/sh
/usr/bin/ssh root@esxi-server poweroff
/bin/sleep 300
/sbin/shutdown -p now
This would power off the ESXi server then sleep for five minutes before powering down.

Note that you'll need a hefty UPS to keep both systems up and running this long, as it will take well over 5 minutes for both systems to completely shut down.
 

Scampicfx

Contributor
Joined
Jul 4, 2016
Messages
125
Hey Spearfoot,
thanks for your script! I tested it by running ...
sh /path/to/your/script
... and it worked well, thanks! :)
I also tested it with ESXi host being unreachable. The rest of the script was executed anyway, cool - so FreeNAS also performs a shutdown when ESXi is not available (there is no script abbortion when ESXi-host is unreachable!)

However... Erm... There is one thing which is not solved right now... hehe...

How can I make this script-file reboot-immune? After testing this shutdown script I remembered that FreeNAS deletes these files after rebooting... so... Is it necessary to move the shutdown script to /mnt/ folder? Or are there any other folders where files are kept after reboots? :D
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
However... Erm... There is one thing which is not solved right now... hehe...

How can I make this script-file reboot-immune? After testing this shutdown script I remembered that FreeNAS deletes these files after rebooting... so... Is it necessary to move the shutdown script to /mnt/ folder? Or are there any other folders where files are kept after reboots? :D
I don't understand what you mean by "making the script reboot-immune" or "FreeNAS deletes these files after rebooting..." -- AFAIK, FreeNAS doesn't arbitrarily delete scripts at boot time.

In any case, I would store the script on your pool -- that's where I store my system-related scripts.

There are refinements to the script that you could pursue: one would be to test for the remote ESXi host being available; you could skip the sleep command and just shut down if it's not available. But the script will probably work just fine 'as is', provided you have a UPS with enough run-time.
 
Status
Not open for further replies.
Top