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

NUT with CyberPower UPS

pfSense Packages
4
23
6.9k
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
    last edited by Oct 14, 2020, 6:43 AM

    just to add a little more if I remember correctly. I could delay the UPS powering off using one of the variables related to delay load power (can't remember the actual variable). But could not get the UPS to recycle power properly when wall outlet power returned.

    1 Reply Last reply Reply Quote 0
    • B
      bhjitsense @pppd
      last edited by Oct 14, 2020, 2:33 PM

      @pppd
      Can you point me in the right direction in scripting something like this in pfSense? I'm not sure what to utilize, or how, in order to automate something like this in pfSense.

      P 1 Reply Last reply Oct 15, 2020, 2:00 AM Reply Quote 0
      • C
        chrcoluk
        last edited by chrcoluk Oct 14, 2020, 2:54 PM Oct 14, 2020, 2:50 PM

        The issue is NUT is hard coded to do the shutdown on critical instead of low power, unlike APCUPSD you cannot configure a battery remaining %. One guy solved this by editing the source code but he never shared his work.

        Ironically a new windows NUT client been worked on (is independent to the NUT project itself) does support using a configured battery % as a trigger. But this is only good for clients not so much pfSense itself, unless you written a windows script to login to pfSense and send a shutdown command.

        I have just reported this on the NUT github issue page.

        pfSense CE 2.7.2

        1 Reply Last reply Reply Quote 0
        • ?
          A Former User
          last edited by A Former User Oct 14, 2020, 3:04 PM Oct 14, 2020, 2:58 PM

          I have an APS UPS but I think this would work with any UPS connected by local USB.

          I chose 35% to leave some battery in case the power flickers on and off. I also use NUT as my network master, my NAS (synology) goes into safe mode at the same battery level.

          login-to-view

          C 1 Reply Last reply Oct 14, 2020, 3:20 PM Reply Quote 1
          • C
            chrcoluk @A Former User
            last edited by chrcoluk Oct 14, 2020, 3:26 PM Oct 14, 2020, 3:20 PM

            @jwj said in NUT with CyberPower UPS:

            I have an APS UPS but I think this would work with any UPS connected by local USB.

            I chose 35% to leave some battery in case the power flickers on and off. I also use NUT as my network master, my NAS (synology) goes into safe mode at the same battery level.

            login-to-view

            Hmm, have you confirmed this changes the behaviour, if yes then thank you this is great. but does raise questions about the guy who claimed the issue was that it was using critical instead of low battery value.

            According to the NUT docs these are recognised but in ups.conf not the driver. Not sure if pfSense uses the NUT client (for local ups), I think it just uses upsmon daemon?

            pfSense CE 2.7.2

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User
              last edited by A Former User Oct 14, 2020, 3:42 PM Oct 14, 2020, 3:39 PM

              Yes, tested. I pull the plug and when my UPS hits 35% (reported by NUT) my pfsense box shuts down. I've had it setup like this for a year+. Lots and lots of power outages without issue.

              What happens when power is restored is dependent on you UPS and the BIOS settings of your pfsense HW.

              If you can, give it a try with some bigger percentage so you don't have to wait ages. Report back here what happens.

              1 Reply Last reply Reply Quote 1
              • C
                chrcoluk
                last edited by chrcoluk Oct 14, 2020, 3:45 PM Oct 14, 2020, 3:43 PM

                I have checked as well, it does work, this is good news.

                For the benefit of others, you can test without pulling the battery, make the change as jwl described, and then click on UPS status, the value of 'battery.charge.low' does indeed change.

                I am going to edit the github issue report to ask them to fix the documentation.

                jwl I changed mine to this (the poll line was already there, to poll much more frequently), default is 10% low and 20% warning on my ups.

                pollfreq=5 -i 5
                ignorelb
                override.battery.charge.low = 20
                override.battery.charge.warning = 50
                

                pfSense CE 2.7.2

                ? 1 Reply Last reply Oct 14, 2020, 3:44 PM Reply Quote 0
                • ?
                  A Former User @chrcoluk
                  last edited by A Former User Oct 14, 2020, 4:03 PM Oct 14, 2020, 3:44 PM

                  @chrcoluk said in NUT with CyberPower UPS:

                  I have checked as well, it does work, this is good news.

                  For the benefit of others, you can test without pulling the battery, make the change as jwl described, and then click on UPS status, the value of 'battery.charge.low' does indeed change.

                  I am going to edit the github issue report to ask them to fix the documentation.

                  Good news and good work!

                  I can't claim any real skill on my part configuring it that way. There was some google foo involved, long enough ago that I don't recall any specifics. Maybe as a byproduct of looking for the config to get it to use the monuser that is hardwired into Synology NASs...

                  I'll put that here in case it's useful to someone (change the IPs to match your setup). This is security malpractice on Synology's part!

                  login-to-view

                  login-to-view

                  1 Reply Last reply Reply Quote 1
                  • B
                    bhjitsense
                    last edited by Oct 14, 2020, 4:11 PM

                    What about the issue (could just be related to CyberPower) that when the UPS shuts off due to running out of battery (all plugged in items power down) then immediately the UPS powers back on as if it decided "no wait, I do have a LITTLE more battery left. THis causes everything to turn BACK on only to be cut from power when the UPS ACTUALLY drains it's battery. How can I avoid this?

                    ? P 5 Replies Last reply Oct 14, 2020, 4:18 PM Reply Quote 0
                    • ?
                      A Former User @bhjitsense
                      last edited by A Former User Oct 14, 2020, 4:27 PM Oct 14, 2020, 4:18 PM

                      @bhjitsense That's going to vary from one UPS to another. Some UPS's can be told to shut off when some battery level is reached. Of course you will have to configured things to safe/power off at a level higher than that. Some UPS's will not power on (provide power to attached devices) after power is restored until the battery level reaches some value.

                      I do recall that NUT can tell a UPS to power down with some delay as the last thing before the service is stopped during a shutdown of the host machine. My recollection is fuzzy, google searching is required to nail down the specifics... I would have to pull the plug on mine to see what happens, I don't exactly remember if the UPS shuts off or just runs the battery down. Kids are home and in online class, not going to happen today...

                      Some threads here on that subject. Not going to wade into that today either...

                      1 Reply Last reply Reply Quote 0
                      • P
                        pppd @bhjitsense
                        last edited by Oct 15, 2020, 2:00 AM

                        @bhjitsense look for one of the variables in the UPS settings displayed on the UPS service in pfSense. Run your finger down the list and look for something related to load.off.delay. (it may not be exactly this as my memory is not great nowadays). If I remember correctly it defaults to 59 seconds which Cyberpower UPS doesn't recognize as a valid number so ignores it and thus the cause of your UPS suddenly powering off. Instead set it to something like 300 (5 mins) by adding an override statement in the extra settings sections of the UPS settings which is recognized by your UPS as a valid setting. So your extra settings should look like:

                        override.load.off.delay=300

                        save and restart the service. Test your new settings by going to shell and entering:

                        upsmon -c FSD

                        this will simulate a low battery situation and call the shutdown scripts. If your settings are correct your pfSense should have enough time to shutdown gracefully. If the UPS powers off before pfSense completes its shutdown then recheck your settings. If your pfsense shutdown ungracefully you might need to first boot into single user mode and fsck -F just to do a check on your volume before proceeding further.

                        Now, if your load on the UPS is greater than lets say 30% you might want to adjust the time when the UPS begins its shutdown by adding another line to the extra settings as such:

                        override.battery.low=50
                        ignorelb

                        The ignorelb is required if you want the above settings to take effect. Again I am not sure of my variable names so you will need to check the actual variable names listed in the UPS service on pfsense.

                        Like I said, the native apcsd daemon on pfsense is just much easier to use than NUT thus the reason I decided to purchase APC for my pfsense box. The Cyberpower has native drivers for Windows and Linux so I repurposed it to those boxes. You might want to consider the same.

                        1 Reply Last reply Reply Quote 0
                        • P
                          pppd @bhjitsense
                          last edited by Oct 15, 2020, 2:19 AM

                          @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 Oct 15, 2020, 2:23 AM

                            @bhjitsense correction: IF < 50 then poweroff

                            1 Reply Last reply Reply Quote 0
                            • P
                              pppd @bhjitsense
                              last edited by Oct 15, 2020, 9:01 AM

                              @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 Oct 15, 2020, 11:20 AM

                                @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 Oct 15, 2020, 11:59 AM

                                  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 Oct 16, 2020, 12:53 AM Reply Quote 0
                                  • P
                                    pppd @bhjitsense
                                    last edited by Oct 16, 2020, 12:53 AM

                                    @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 Oct 16, 2020, 12:57 AM

                                      @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 Oct 16, 2020, 8:43 PM Oct 16, 2020, 8:43 PM

                                        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 Oct 17, 2020, 1:01 AM Reply Quote 0
                                        • P
                                          pppd @chrcoluk
                                          last edited by Oct 17, 2020, 1:01 AM

                                          @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
                                          12 out of 23
                                          • First post
                                            12/23
                                            Last post
                                          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.