• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

NUT Package upssched setup

Scheduled Pinned Locked Moved UPS Tools
14 Posts 2 Posters 1.8k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 4
    4o4rh
    last edited by Feb 13, 2023, 10:12 PM

    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

    D 1 Reply Last reply Feb 14, 2023, 1:40 AM Reply Quote 0
    • D
      dennypage @4o4rh
      last edited by Feb 14, 2023, 1:40 AM

      @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.

      4 1 Reply Last reply Feb 14, 2023, 4:09 PM Reply Quote 0
      • 4
        4o4rh @dennypage
        last edited by Feb 14, 2023, 4:09 PM

        @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

        D 1 Reply Last reply Feb 14, 2023, 5:12 PM Reply Quote 0
        • D
          dennypage @4o4rh
          last edited by Feb 14, 2023, 5:12 PM

          @gwaitsi Put your switch on the ups. Or use a direct connection.

          4 1 Reply Last reply Feb 14, 2023, 6:52 PM Reply Quote 0
          • 4
            4o4rh @dennypage
            last edited by Feb 14, 2023, 6:52 PM

            @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.

            D 1 Reply Last reply Feb 14, 2023, 7:04 PM Reply Quote 0
            • D
              dennypage @4o4rh
              last edited by Feb 14, 2023, 7:04 PM

              @gwaitsi So the ups is not powering the pfSense box?

              4 1 Reply Last reply Feb 14, 2023, 7:41 PM Reply Quote 0
              • 4
                4o4rh @dennypage
                last edited by Feb 14, 2023, 7:41 PM

                @dennypage no

                D 1 Reply Last reply Feb 14, 2023, 9:59 PM Reply Quote 0
                • D
                  dennypage @4o4rh
                  last edited by Feb 14, 2023, 9:59 PM

                  @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.

                  4 1 Reply Last reply Feb 15, 2023, 5:00 PM Reply Quote 0
                  • 4
                    4o4rh @dennypage
                    last edited by Feb 15, 2023, 5:00 PM

                    @dennypage It would be could if you could include these two files as part of the configuration options in the package.
                    ddb927d0-87ac-41d9-9bc5-d89ac6f3935b-image.png

                    I have the use case almost working as desired, but i have to add these files to make it work

                    D 1 Reply Last reply Feb 15, 2023, 6:34 PM Reply Quote 0
                    • D
                      dennypage @4o4rh
                      last edited by Feb 15, 2023, 6:34 PM

                      @gwaitsi This isn’t a reasonable use case for nut.

                      4 1 Reply Last reply Feb 15, 2023, 7:04 PM Reply Quote 0
                      • 4
                        4o4rh @dennypage
                        last edited by 4o4rh Feb 15, 2023, 7:28 PM Feb 15, 2023, 7:04 PM

                        @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.html

                        We shouldn't need to create outside the application, files that should be part of the package.

                        D 1 Reply Last reply Feb 15, 2023, 9:32 PM Reply Quote 0
                        • D
                          dennypage @4o4rh
                          last edited by Feb 15, 2023, 9:32 PM

                          @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.

                          4 1 Reply Last reply Feb 15, 2023, 10:43 PM Reply Quote 0
                          • 4
                            4o4rh @dennypage
                            last edited by 4o4rh Feb 15, 2023, 10:49 PM Feb 15, 2023, 10:43 PM

                            @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

                            21c88c6f-019c-450d-b36b-705f15609594-image.png

                            D 1 Reply Last reply Feb 15, 2023, 11:59 PM Reply Quote 0
                            • D
                              dennypage @4o4rh
                              last edited by Feb 15, 2023, 11:59 PM

                              @gwaitsi said in NUT Package upssched setup:

                              @dennypage i already have it working

                              Congratulations. Super cool.

                              1 Reply Last reply Reply Quote 0
                              • S stephenw10 moved this topic from pfSense Packages on Apr 2, 2024, 7:19 PM
                              14 out of 14
                              • First post
                                14/14
                                Last post
                              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                                This community forum collects and processes your personal information.
                                consent.not_received