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 37.2k 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.
    • 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
            • dennypageD
              dennypage
              last edited by

              Also if you still see an issue with service restart, please post fresh system log file entries for ups*. Thanks.

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

                I have reinstalled package completely and now it's a bit different error appears.
                Looked at nut.sh
                You forgot to remove ampersand at /usr/local/sbin/upsdrvctl start & 
                when I remove it, all is working as it should!

                some_new.jpg
                some_new.jpg_thumb

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

                  Yes, that makes much more sense, and what I was expecting to see.

                  Removing the ampersand was a testing item to ensure I understood what was happening on your system. I wasn't intending to remove it from the production package as it is required to support the startup retry.

                  The thing that I fixed was the service status issue (the restart vs start button at the top). The "Failed to retrieve status" is kind of a fact of life because it is taking a very long time to initialize via SNMP. About the only thing that I could do about that is to have it report "pending", but then you would still have to press refresh in the page because the UI pages don't auto-refresh.

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

                    Hmm… startup retry? Why do we need that?

                    Without ampersand, all working.

                    
                     Aug 2 09:35:23 	upsd 	5793 	User monuser@::1 logged into UPS [SMK-1000A]
                    Aug 2 09:35:23 	upsd 	5793 	Startup successful
                    Aug 2 09:35:23 	upsd 	5467 	Connected to UPS [SMK-1000A]: snmp-ups-SMK-1000A
                    Aug 2 09:35:23 	upsd 	5467 	listening on 127.0.0.1 port 3493
                    Aug 2 09:35:23 	upsd 	5467 	listening on ::1 port 3493
                    Aug 2 09:35:21 	snmp-ups 	5221 	Startup successful
                    Aug 2 09:35:14 	upsmon 	3642 	Startup successful
                    Aug 2 09:35:14 	snmp-ups 	49799 	Signal 15: exiting
                    Aug 2 09:35:14 	upsd 	64420 	Signal 15: exiting
                    Aug 2 09:35:14 	upsd 	64420 	mainloop: Interrupted system call
                    Aug 2 09:35:14 	upsd 	64420 	User monuser@::1 logged out from UPS [SMK-1000A]
                    Aug 2 09:35:14 	upsmon 	48594 	Signal 15: exiting 
                    
                    

                    With ampersand (Failed to retrieve status)

                    
                    Aug 2 09:39:33 	upsmon 	96136 	Communications with UPS SMK-1000A established
                    Aug 2 09:39:30 	upsd 	96547 	Connected to UPS [SMK-1000A]: snmp-ups-SMK-1000A
                    Aug 2 09:39:29 	snmp-ups 	97935 	Startup successful
                    Aug 2 09:39:28 	upsmon 	96136 	UPS SMK-1000A is unavailable
                    Aug 2 09:39:28 	upsmon 	96136 	Poll UPS [SMK-1000A] failed - Driver not connected
                    Aug 2 09:39:23 	upsmon 	96136 	Communications with UPS SMK-1000A lost
                    Aug 2 09:39:23 	upsmon 	96136 	Poll UPS [SMK-1000A] failed - Driver not connected
                    Aug 2 09:39:23 	upsd 	96547 	User monuser@::1 logged into UPS [SMK-1000A]
                    Aug 2 09:39:21 	upsd 	96547 	Startup successful
                    Aug 2 09:39:21 	upsd 	96511 	Can't connect to UPS [SMK-1000A] (snmp-ups-SMK-1000A): No such file or directory
                    Aug 2 09:39:21 	upsd 	96511 	listening on 127.0.0.1 port 3493
                    Aug 2 09:39:21 	upsd 	96511 	listening on ::1 port 3493
                    Aug 2 09:39:20 	upsmon 	95585 	Startup successful
                    Aug 2 09:39:20 	snmp-ups 	5221 	Signal 15: exiting
                    Aug 2 09:39:20 	upsd 	5793 	Signal 15: exiting
                    Aug 2 09:39:20 	upsd 	5793 	mainloop: Interrupted system call
                    Aug 2 09:39:20 	upsd 	5793 	User monuser@::1 logged out from UPS [SMK-1000A]
                    Aug 2 09:39:20 	upsmon 	4091 	Signal 15: exiting 
                    
                    
                    1 Reply Last reply Reply Quote 0
                    • w0wW
                      w0w
                      last edited by

                      Looks like this "retry" thing not working at all with SNMP connection, just causes it to re-establish twice.

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

                        Increased sleep
                        ….......................................................
                        /usr/local/sbin/upsdrvctl start &
                        sleep 12
                        /usr/local/sbin/upsd -u root
                        ..........................................................

                        
                        Aug 2 09:49:14 	upsd 	31334 	User monuser@::1 logged into UPS [SMK-1000A]
                        Aug 2 09:49:13 	upsd 	31334 	Startup successful
                        Aug 2 09:49:13 	upsd 	31056 	Connected to UPS [SMK-1000A]: snmp-ups-SMK-1000A
                        Aug 2 09:49:13 	upsd 	31056 	listening on 127.0.0.1 port 3493
                        Aug 2 09:49:13 	upsd 	31056 	listening on ::1 port 3493
                        Aug 2 09:49:12 	snmp-ups 	30987 	Startup successful
                        Aug 2 09:49:01 	upsmon 	9616 	Startup successful
                        Aug 2 09:49:01 	snmp-ups 	6655 	Signal 15: exiting
                        Aug 2 09:49:01 	upsd 	7053 	Signal 15: exiting
                        Aug 2 09:49:01 	upsd 	7053 	mainloop: Interrupted system call
                        Aug 2 09:49:01 	upsd 	7053 	User monuser@::1 logged out from UPS [SMK-1000A]
                        Aug 2 09:49:01 	upsmon 	5726 	Signal 15: exiting 
                        
                        

                        Is it OK for you?

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

                          @w0w:

                          Hmm… startup retry? Why do we need that?

                          It was requested: https://forum.pfsense.org/index.php?topic=114871.msg638897#msg638897

                          It's necessary to address the case of the ups being unreachable at pfSense startup.

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

                            I am sorry  :'(, but may be I have tested it in wrong way. If I unplug SNMP card from the network and then restart the service — it does not reconnects to the UPS. All I get in logs is

                            
                            endless....
                            Aug 2 10:22:46 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                            Aug 2 10:22:41 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                            Aug 2 10:22:36 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                            Aug 2 10:22:31 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                            Aug 2 10:22:26 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                            Aug 2 10:22:21 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                            Aug 2 10:22:16 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                            Aug 2 10:22:11 	upsmon 	50160 	UPS SMK-1000A is unavailable 
                            
                            

                            Looks like it does not matter sleep 1 or 12 is applied.

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

                              Do you still have maxretry and retrydelay in the advanced section?

                              https://forum.pfsense.org/index.php?topic=114871.msg640123#msg640123

                              You should be seeing a stream of messages from the snmp driver…

                              @w0w:

                              If I unplug SNMP card from the network and then restart the service — it does not reconnects to the UPS. All I get in logs is

                              
                              endless....
                              Aug 2 10:22:46 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                              Aug 2 10:22:41 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                              Aug 2 10:22:36 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                              Aug 2 10:22:31 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                              Aug 2 10:22:26 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                              Aug 2 10:22:21 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                              Aug 2 10:22:16 	upsmon 	50160 	Poll UPS [SMK-1000A] failed - Driver not connected
                              Aug 2 10:22:11 	upsmon 	50160 	UPS SMK-1000A is unavailable 
                              
                              
                              1 Reply Last reply Reply Quote 0
                              • w0wW
                                w0w
                                last edited by

                                Double checked my setup and config and found that I am an idiot.
                                maxretry=60
                                retrydelay=60
                                was placed into upsmon.conf instead of ups.conf
                                I have removed both ampersand and sleep from nut.sh
                                Testing again

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

                                  Looks like all working without ampersand and sleep.
                                  But when ampersand removed it takes a while to load status page with disconnected UPS ;).
                                  So I ask you again, is it OK for you if sleep would be 12 seconds instead of 1?
                                  With this value all seems OK on my side. Reconnection after SNMP down and service restart  with SNMP online on status page is OK. No issues currently!

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

                                    I really can't do a 12 second sleep in service start. The 95% case is that UPS startup takes well under 1 second. An additional delay in service start affects everyone and everything including system startup (boot). Introducing a 10+ second delay to system startup would not be generally acceptable. It also creates a situation in which there can be multiple service starts underway at the same time, which can result in all sorts of problems with nut. And of course, 12 seconds works in this specific case, but what happens when a case comes along that requires 20 seconds for UPS initialization?

                                    The backgrounding for driver start is required to support initialization retries. Without backgrounding, status page load (and system startup) will hang until driver initilization completes. With the maxretry/retrydelay example previously posted, this could be 1 hour. Note that maxretry/retrydelay only affects driver initialization (startup). It does not affect disconnect/reconnect.

                                    About the only thing I can do is have the status be "pending" like what is shown in the widget following system boot.

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

                                      I sent out a beta 6 version to everyone. The only change is the ups “pending” change discussed above. To avoid any confusion, please delete the prior version via pkg delete prior to installing the new version.

                                      If you have time to give this version a test, I would really appreciate it. I'd like to put this to bed. Thanks!

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

                                        
                                        Aug 3 07:11:33 	pkg 		pfSense-pkg-nut-2.7.4b6 installed
                                        Aug 3 07:11:33 	php 		/etc/rc.packages: Successfully installed package: nut.
                                        Aug 3 07:11:33 	check_reload_status 		Syncing firewall
                                        Aug 3 07:11:29 	php 		/etc/rc.packages: Starting service nut
                                        Aug 3 07:11:29 	check_reload_status 		Syncing firewall
                                        Aug 3 07:11:28 	php 		/etc/rc.packages: Beginning package installation for nut .
                                        Aug 3 07:11:28 	pkg 		nut-2.7.4 installed
                                        Aug 3 07:11:18 	pkg 		nut-2.7.4 deinstalled 
                                        
                                        

                                        But… NUT service itself does not start automatically after installation. Only on saving config or reboot.

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

                                          @w0w:

                                          But… NUT service itself does not start automatically after installation. Only on saving config or reboot.

                                          This is expected: https://forum.pfsense.org/index.php?topic=114871.msg643281#msg643281

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

                                            Ok then. It works.

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