-
Trying to setup my pfsense to connect to a remote UPS and need some help with the upssched.conf / upssched-cmd files please. I keep getting a forced shutdown instead of waiting the 15min
I want the config to do following;
- if comms lost > 15min then shutdown
- if comms restored <= 15min then cancel
- if fsd shutdown from host, then force shutdown
- if lowbatt ignore - lost comms will kickin if primary is gone
upssched.conf
AT ONBATT * START-TIMER onbattery 30 AT ONLINE * CANCEL-TIMER onbattery AT ONBATT * START-TIMER powerdown 1800 AT ONLINE * CANCEL-TIMER powerdown AT LOWBATT * EXECUTE powerdown 1800 AT ONLINE * CANCEL-TIMER powerdown AT FSD * EXECUTE shutdowncritical AT SHUTDOWN * EXECUTE powerdown AT NOCOMM * EXECUTE COMMBAD AT COMMBAD * START-TIMER upsgone 30 AT COMMOK * CANCEL-TIMER upsgone AT COMMBAD * START-TIMER powerdown 1800 AT COMMOK * CANCEL-TIMER powerdown
upssched-cmd
#!/bin/sh case $1 in onbattery) logger -t upssched-cmd "The UPS has been on battery for awhile ;; powerdown) logger -t upssched-cmd "UPS on battery too long, forced shutdown" /usr/sbin/upsmon -c fsd ;; shutdowncritical) logger -t upssched-cmd "UPS on battery critical, forced shutdown" /usr/sbin/upsmon -c fsd ;; upsgone) logger -t upssched-cmd "The UPS has been gone for awhile" ;; *) logger -t upssched-cmd "Unrecognized command: $1" ;; esac
cheers
-
@gwaitsi said in NUT Package upssched setup:
Trying to setup my pfsense to connect to a remote UPS and need some help with the upssched.conf / upssched-cmd files please. I keep getting a forced shutdown instead of waiting the 15min
I want the config to do following;
- if comms lost > 15min then shutdown
- if comms restored <= 15min then cancel
- if fsd shutdown from host, then force shutdown
- if lowbatt ignore - lost comms will kickin if primary is gone
Couple of things…
Item 1 isn’t really an good idea. Loosing connection to the remote but server causing a firewall shutdown? Forcing a manual act to recover? Not recommend. But if you want to persist on this path, you should ask for help on the nut users mailing list rather than in a pfSense forum. This isn’t something that the pfSense nut package supports.
Item 4 doesn’t make sense. Ignorelb is a driver function. Not something you can use remotely.
Unless you have very good reason to interfere, it’s best to let nut do it’s job as intended.
-
@dennypage It probably doesn't make sense, because you don't know the use case.
-
My pfsense doesn't have a connection to the UPS, which is on another floor.
-
It has a power pack to provide some running time to all for a controlled shutdown in the event power fails.
-
Power fails will only be recognized because the switches will lose power, so the comms to the UPS will fail (but any loss of comms will be treated the same i.e. switch reboot, etc)
I therefore need to;
- consider a communications loss, firstly as a routine event and wait a period of time before shutting down
- shutdown before the powerpack battery fails
- cancel the shutdown if the communications is restored before the shutdown moment.
So, if;
- normally reboot of a device, system will not shutdown because comms will be restored
- power fails is only short interruption, system will not shutdown because comms will be restored
- power fails, but is longer than the battery time of the power pack full shutdown will occur and system will need to be manually restarted (netgear switches don't provide Wake on LAN)
But I rather have the system shutdown in a controlled way, that cut off due to power failure. I lost a full pfsense config once, hence the reason i bought the power pack
-
-
@gwaitsi Put your switch on the ups. Or use a direct connection.
-
@dennypage the UPS is 3 floors higher and there is no space/place for me to put a UPS where the pfsense is. The UPS protects my NAS in critical computers during an outage. given the switches, modems and access points have no protection, the pfsense does not a UPS. It only needs to stay up long enough for a controlled shutdown.
-
@gwaitsi So the ups is not powering the pfSense box?
-
@dennypage no
-
@gwaitsi Then don’t use nut. A simple shell script running on pfSense will do. Ping the switch, and if the ping fails for X min, execute a shutdown.
Btw, looking back at your first post, item 3 (fsd) would not work either. If the switch fails when the power fails, you would loose comms and never receive an fsd notice from the nut server.
-
@dennypage It would be could if you could include these two files as part of the configuration options in the package.
I have the use case almost working as desired, but i have to add these files to make it work
-
@gwaitsi This isn’t a reasonable use case for nut.
-
@dennypage @jimp the use case is irrelavent in terms of these two files.
upssched.conf is the configuration for upssched timer program which is triggered through upsmon
The 2nd file /usr/local/bin/upssched-cmd is the CMDSCRIPT used for action events that have been triggered via the timer.
It's all in the documentation, and a quick seach on google shows many people using this for different kinds of use cases, particularly where multiple UPS's are involved.
https://networkupstools.org/docs/man/upssched.conf.html
https://networkupstools.org/docs/man/upssched.htmlWe shouldn't need to create outside the application, files that should be part of the package.
-
@gwaitsi I don’t know what else to say to you. You are pursuing something that doesn’t make any sense to use nut for. Just write a simple shell script and move on.
-
@dennypage i already have it working, and that is the whole point of nut remote monitoring. i.e. to shutdown other systems. but neither of those points have anything to do with the fact the nut package, does not include an editor for two files that form part of the package e.g. upssched.conf and upssched-cmd
-
@gwaitsi said in NUT Package upssched setup:
@dennypage i already have it working
Congratulations. Super cool.
-