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

    NUT with CyberPower UPS

    Scheduled Pinned Locked Moved pfSense Packages
    23 Posts 4 Posters 7.3k 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.
    • P
      pppd @bhjitsense
      last edited by

      @bhjitsense for your issue related to your UPS suddenly powering back up while still on battery I never solved that issue thus the reason I switched to APC.

      I believe one of the settings controls that function but I never figured it out and since my systems are in production there is the possibility in future that something else will screw up and corrupt the pfsense box. My advice to you is that NUT and cyberpower don't get along well and since there are no native FreeBSD drivers I switched to APC. APC works exactly as predicted thanks to its native driver.

      I wrote a shell script to overcome this failing and put it in CRON running every minute. I can't remember the command but I think it was upscmd -l which will list out the current settings of the UPS including battery levels. Pipe that into GREP and IF battery level < 50 call shutdown (upsmon -c FSD).

      1 Reply Last reply Reply Quote 0
      • P
        pppd @bhjitsense
        last edited by

        @bhjitsense correction: IF < 50 then poweroff

        1 Reply Last reply Reply Quote 0
        • P
          pppd @bhjitsense
          last edited by

          @bhjitsense if you really want to script the shutdown yourself something as simple as the following in CRON every minute will do the job:

          upsc | grep 'OB' && poweroff

          the above will gracefully shut down pfsense as soon as the system goes on battery.

          if you want to shutdown on low battery

          upsc | grep 'LB' && poweroff

          but you will need to shut off NUT while still being able to query the UPS status so that you don't find yourself in competition with NUT issuing the shutdown command itself

          1 Reply Last reply Reply Quote 0
          • P
            pppd @bhjitsense
            last edited by

            @bhjitsense correction:

            upsc <upsname> | grep 'OB' && shutdown

            if you want to shutdown at a certain level then:

            (( $(upsc <upsname> | grep 'battery.charge' | grep -oe '([0-9.]*)') < 60 )) && shutdown

            will shutdown your firewall when battery level drops below 60%

            1 Reply Last reply Reply Quote 0
            • B
              bhjitsense
              last edited by

              I really appreciate your help @pppd! I can't believe I didn't realize I could just get the CRON package to make stuff like this.
              I've considered switching to APC. Now that I know it has a native driver, i'll probably be pulling that trigger.

              P 2 Replies Last reply Reply Quote 0
              • P
                pppd @bhjitsense
                last edited by

                @bhjitsense smart move with getting APC for pfsense (or freebsd for that matter). NUT is great and has hundreds of options but it needs to be correctly configured to work properly. Repurpose your cyberpower to Linux or Windows boxes which have native drivers.

                1 Reply Last reply Reply Quote 0
                • P
                  pppd @bhjitsense
                  last edited by

                  @bhjitsense I notice a wrong bracket in the command...correction:

                  (( $(upsc <upsname> | grep 'battery.charge' | grep -oe '([0-9.]*') < 60 )) && shutdown

                  where <upsname> is the name of the UPS you entered in the UPS settings.

                  1 Reply Last reply Reply Quote 0
                  • C
                    chrcoluk
                    last edited by chrcoluk

                    All this seems a bit overkill? jwj has a non hacky solution already with adding the flags to the driver section in the UI which he has personally tested to work.

                    My cyberpower UPS auto shuts itself down to protect its battery according to the documentation so shouldnt need a command to tell it to turn off, or have I misunderstood something?

                    pfSense CE 2.7.2

                    P 1 Reply Last reply Reply Quote 0
                    • P
                      pppd @chrcoluk
                      last edited by

                      @chrcoluk the solution is a stop/gap measure to deal with the cyberpower UPS suddenly coming back online while still on battery.

                      If you know all the commands of the cyberpower UPS please publish them so we don't have to use these hack methods.

                      1 Reply Last reply Reply Quote 0
                      • C
                        chrcoluk
                        last edited by

                        I dont know any :(

                        Since none of my devices auto power on when power is restored I think I will be ok luckily.

                        pfSense CE 2.7.2

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.