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

    Beta test of new NUT UPS package

    Scheduled Pinned Locked Moved pfSense Packages
    114 Posts 15 Posters 39.7k 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.
    • D
      DownloadDeviant
      last edited by

      I'm not testing this but was hoping I could add some food for thought. Just speaking from my personal experience from running about 5 different pfSense routers for myself, my small business and a family member's small biz. I've used NUT and my typical setup is to have it remotely access the UPS connected directly to my Synology and/or FreeNAS devices. Obviously, because I'm dealing with small spaces and cannot have a dedicated UPS for every device.

      My biggest headache has been when things go bad. Example - A pfSense router goes whacky and a fresh install then restore from backup config has to be performed. Typically, this is simple enough. However, I've always had trouble with NUT causing odd behavior with the recovery. I've had to manually edit the config file and remove all traces of NUT content.  For the record, I've learned to create backup configs that do not include package data

      I'd like to see this new version play nice on recovery if a config does happen to include package data…if possible.

      Also, I'm very excited to see a new version and continued development of this package! Thanks DennyPage!

      System: pfSense 2.4.3p1 - ZFS CPU: AMD Athlon 5350 (Kabini) MOBO: ASRock AM1H-ITX HD: 60GB SSD Patriot Inferno RAM: G.SKILL 8GB DDR3 2133 NIC: Intel I350-T2 PS: Lite-On 75W AC PACKAGES: Cron, NUT

      1 Reply Last reply Reply Quote 0
      • dennypageD
        dennypage
        last edited by

        Yea, that makes sense. Theres a bit of a catch-22 as the async startup for the driver is required to support the use of startup retry (maxretry/retrydelay) in ups.conf. It's taking a long time for the initial connect to the SNMP UPS.

        1 Reply Last reply Reply Quote 0
        • S
          Starrbuck
          last edited by

          Beta 4 appears to have the same problem with Snort.

          1 Reply Last reply Reply Quote 0
          • dennypageD
            dennypage
            last edited by

            Can you confirm the checksum on the following files please?

            32332 22 /usr/local/www/nut_settings.php
            14138 5 /usr/local/www/nut_status.php
            47031 3 /usr/local/pkg/nut.xml
            3633 12 /usr/local/pkg/nut/nut.inc

            @Starrbuck:

            Beta 4 appears to have the same problem with Snort.

            1 Reply Last reply Reply Quote 0
            • S
              Starrbuck
              last edited by

              I uninstalled and reinstalled the package and it's ok now.

              1 Reply Last reply Reply Quote 0
              • dennypageD
                dennypage
                last edited by

                Kinda figured that would do it. Thanks for confirming.

                @Starrbuck:

                I uninstalled and reinstalled the package and it's ok now.

                1 Reply Last reply Reply Quote 0
                • w0wW
                  w0w
                  last edited by

                  This modification works for me.

                  
                  $status = nut_ups_status();
                  if ($status['_alert']) {
                  	sleep(10);
                  	$status = nut_ups_status();
                  		if ($status['_alert']) {
                  		print_info_box("Status Alert: The UPS requires attention", "alert-danger");
                  }
                  }
                  
                  

                  The other issue I have — head.inc does not show restart service button anymore after successful  restart, but if I  unplug cable from SNMP card then it shows.

                  some_bug.jpg_thumb
                  some_bug.jpg

                  1 Reply Last reply Reply Quote 0
                  • w0wW
                    w0w
                    last edited by

                    
                    $status = nut_ups_status();
                    if ($status['_alert']) {
                    	sleep(10);
                    }
                    
                    $pgtitle = array(gettext("Services"), gettext("UPS"), gettext("Status"));
                    include("head.inc");
                    $tab_array = array();
                    $tab_array[] = array(gettext("UPS Status"), true, "/nut_status.php");
                    $tab_array[] = array(gettext("UPS Settings"), false, "/nut_settings.php");
                    display_top_tabs($tab_array);
                    
                    $status = nut_ups_status();
                    		if ($status['_alert']) {
                    		print_info_box("Status Alert: The UPS requires attention", "alert-danger");
                    }
                    
                    

                    This way both problems fixed, with buttons and wait for service be ready on page load.

                    1 Reply Last reply Reply Quote 0
                    • dennypageD
                      dennypage
                      last edited by

                      Yea, there isn't much ill that a 10 second sleep doesn't fix. However I don't think I can introduce a 10 second sleep in the UX. It creates a delay in communicating the error condition for local UPSs.

                      1 Reply Last reply Reply Quote 0
                      • w0wW
                        w0w
                        last edited by

                        @dennypage:

                        Yea, there isn't much ill that a 10 second sleep doesn't fix. However I don't think I can introduce a 10 second sleep in the UX. It creates a delay in communicating the error condition for local UPSs.

                        Sleep activated only if first $status query return '_alert', else NO DELAY applied. In normal condition if I understand your
                        nut.inc correctly this never should return '_alert' if connection is OK, it does not matter local or remote connection established.

                        1 Reply Last reply Reply Quote 0
                        • dennypageD
                          dennypage
                          last edited by

                          It introduces a ten second delay in all alert circumstances. However the issue we are trying to address only occurs on service start and only with a slow (remote) UPS.

                          1 Reply Last reply Reply Quote 0
                          • dennypageD
                            dennypage
                            last edited by

                            Btw, forgot to ask this earlier: Is the use of v2c a holdover from the prior NUT package, or did you explicitly configure it? Have you tried running without it?

                            1 Reply Last reply Reply Quote 0
                            • w0wW
                              w0w
                              last edited by

                              @dennypage:

                              It introduces a ten second delay in all alert circumstances. However the issue we are trying to address only occurs on service start and only with a slow (remote) UPS.

                              I am not sure are we talking about the same thing? I have tested it with firefox and it works as it should in UX. If UPS connection is OK and established there is no delay in loading status page, I mean delay is less then 1 second and if there is a problem with connection (cable unplugged or whatever), then it returns "Status Alert: The UPS requires attention" as it should be but after 10 seconds delay or returns UPS data if connection is established during this 10sec sleep. Why sleep should be called in all alert circumstances? I don't understand. I am sorry. I am not an PHP programmer, but if logiс is the same for all languages I know. If I do something wrong, then feel free to tell me :)

                              @dennypage:

                              Btw, forgot to ask this earlier: Is the use of v2c a holdover from the prior NUT package, or did you explicitly configure it? Have you tried running without it?

                              It's not from prior, it's required for some other clients on network.

                              EDIT:
                              Now I understand what you mean, forgive me please for my stupidity. Looked deeply into nut.inc
                              Yes we need some other way to fix it.

                              1 Reply Last reply Reply Quote 0
                              • dennypageD
                                dennypage
                                last edited by

                                I'm not a PHP guy either. I'm a C and assembler programmer. :)

                                The proposed change introduces a 10 second delay to page processing if there is any alert condition. Let's say you have a local UPS, either local or remote, which has been running fine and then goes into alert state. You click on the widget header to go to the UPS status page. That page load will experience a 10 second delay, which it shouldn't.

                                The core issue comes from the delay between service start and service availability due to the time taken in driver initialization when talking to the SNMP UPS. It is only during this interval that a delay would be appropriate.

                                @w0w:

                                @dennypage:

                                It introduces a ten second delay in all alert circumstances. However the issue we are trying to address only occurs on service start and only with a slow (remote) UPS.

                                I am not sure are we talking about the same thing? I have tested it with firefox and it works as it should in UX. If UPS connection is OK and established there is no delay in loading status page, I mean delay is less then 1 second and if there is a problem with connection (cable unplugged or whatever), then it returns "Status Alert: The UPS requires attention" as it should be. Why sleep shoud be called in all alert circumstances?

                                1 Reply Last reply Reply Quote 0
                                • w0wW
                                  w0w
                                  last edited by

                                  Now I understand what you mean, forgive me please for my stupidity. Looked deeply into nut.inc
                                  Yes we need some other way to fix it.

                                  1 Reply Last reply Reply Quote 0
                                  • dennypageD
                                    dennypage
                                    last edited by

                                    Okay. Just to make sure I understand, driver initialization fails if you remove the snmp_version=v2c from the Extra Arguments? What is in the log file?

                                    1 Reply Last reply Reply Quote 0
                                    • w0wW
                                      w0w
                                      last edited by

                                      No, not the driver init, but I am using SNMP card with other devices, one of them polls in SNMP v2.1c, so I decided to configure SNMP card with this version and configure all clients to use it.

                                      Ok, I have isolated sleep function to only when "UPS Monitor not running" condition. This looks much better ;)

                                      
                                      $status = nut_ups_status();
                                      		if ($status['_summary'] == "UPS Monitor not running") {
                                      		sleep(10);
                                      }
                                      
                                      $pgtitle = array(gettext("Services"), gettext("UPS"), gettext("Status"));
                                      include("head.inc");
                                      $tab_array = array();
                                      $tab_array[] = array(gettext("UPS Status"), true, "/nut_status.php");
                                      $tab_array[] = array(gettext("UPS Settings"), false, "/nut_settings.php");
                                      display_top_tabs($tab_array);
                                      
                                      $status = nut_ups_status();
                                      		if ($status['_alert']) {
                                      		print_info_box("Status Alert: The UPS requires attention", "alert-danger");
                                      }
                                      
                                      
                                      1 Reply Last reply Reply Quote 0
                                      • dennypageD
                                        dennypage
                                        last edited by

                                        I sent out a new version to everyone. If you have a moment, please give it a run and let me know if you see any issues. Thanks!

                                        1 Reply Last reply Reply Quote 0
                                        • w0wW
                                          w0w
                                          last edited by

                                          Nothing changed for me.

                                          same.jpg
                                          same.jpg_thumb

                                          1 Reply Last reply Reply Quote 0
                                          • dennypageD
                                            dennypage
                                            last edited by

                                            Yes, the changes affect service status on restart and reboot. Please confirm the checksum of nut.inc:

                                            49946 12 /usr/local/pkg/nut/nut.inc

                                            If you haven't already, please go to the settings page and re-save before testing again. Thanks.

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