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

NUT package (2.8.0 and below)

UPS Tools
128
1.2k
4.0m
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.
  • N
    n3by
    last edited by Dec 23, 2016, 11:14 PM

    yes it is correct. ( I copied also to nut.sh.new in case it is recreated )

    60215 2 /usr/local/etc/rc.d/nut.sh.new
    
    1 Reply Last reply Reply Quote 0
    • D
      dennypage
      last edited by Dec 23, 2016, 11:57 PM

      Apologies. There was a typo in the pidfile name left over from my testing (based on usbhid-ups rather than blazer_usb).

      Updated version follows.

      #!/bin/sh
      # This file has been modified for special upsdrvctl restart
      
      rc_start() {
      	echo starting NUT
      	if [ -f /var/run/upsdrvctl_loop.pid ]
      	then
      		kill -9 `cat /var/db/nut/upsdrvctl_loop.pid`
      		rm /var/run/upsdrvctl_loop.pid
      	fi
      	/usr/bin/killall -q -9 upsmon
      	/usr/bin/killall -q -9 upsd
      	/usr/bin/killall -q -9 upsdrvctl
      	/usr/bin/killall -q -9 blazer_usb
      	/usr/local/sbin/upsmon
      	/usr/local/sbin/upsdrvctl start &
      	(
      		while true
      		do
      			sleep 15
      			kill -0 `cat /var/db/nut/blazer_usb.pid` > /dev/null 2>&1 && continue
      			/usr/local/sbin/upsdrvctl start
      		done
      	) &
      	echo $! > /var/db/nut/upsdrvctl_loop.pid
      	sleep 1
      	/usr/local/sbin/upsd -u root
      	return 0
      }
      
      rc_stop() {
      	echo stopping NUT
      	if [ -f /var/db/nut/upsdrvctl_loop.pid ]
      	then
      		kill -9 `cat /var/db/nut/upsdrvctl_loop.pid`
      		rm /var/db/nut/upsdrvctl_loop.pid
      	fi
      	/usr/bin/killall -q upsmon
      	/usr/bin/killall -q upsd
      	/usr/bin/killall -q upsdrvctl
      	/usr/bin/killall -q blazer_usb
      	return 0
      }
      
      case $1 in
      	start)
      		rc_start
      		;;
      	stop)
      		rc_stop
      		;;
      	restart)
      		rc_stop
      		rc_start
      		;;
      esac
      
      
      1 Reply Last reply Reply Quote 0
      • W
        w0w
        last edited by Dec 24, 2016, 5:12 AM Dec 24, 2016, 5:07 AM

        @n3by:

        strange …  If I did not made a mistake I think the script interfere with normal NUT because it will restart almost every time.

        #!/bin/sh
        # Script to restart NUT and USB UPS if UPS connection failed
        upsname=$(upsc -l)
        pattern="battery.charge:"
        check=$(upsc $upsname | grep -o "$pattern")
        if [ "$check" != "$pattern" ]; then
        echo "("$check" != "$pattern"), NUT must be restarted"
        else
        echo ""$pattern" found, NUT is running and OK"
        fi
        
        

        For me even if I change upsname=$(upsc -l) directly to ups name it works just fine and NEVER gives me message "NUT must be restarted". If your UPS does not answer to every query, then it is the root cause of the script behavior. You should manually test script, running this several times, looking for the answer.

        1 Reply Last reply Reply Quote 0
        • N
          n3by
          last edited by Dec 24, 2016, 6:57 AM Dec 24, 2016, 6:41 AM

          @dennypage:

          Apologies. There was a typo in the pidfile name left over from my testing (based on usbhid-ups rather than blazer_usb).

          Updated version follows.
          ….....

          9960 2 /usr/local/etc/rc.d/nut.sh
          

          New update it have the same behavior… restarting.

          Dec 24 07:37:26 	blazer_usb 	32252 	Signal 15: exiting
          Dec 24 07:37:26 	upsd 	26542 	Signal 15: exiting
          Dec 24 07:37:26 	upsd 	26542 	mainloop: Interrupted system call
          Dec 24 07:37:26 	upsd 	26542 	User monuser@127.0.0.1 logged out from UPS [ActiveJet]
          Dec 24 07:37:26 	upsmon 	25058 	Signal 15: exiting
          Dec 24 07:37:20 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxxxxx OK
          Dec 24 07:37:20 	upsmon 	25058 	Communications with UPS ActiveJet established
          Dec 24 07:37:17 	upsd 	26542 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
          Dec 24 07:37:15 	blazer_usb 	32252 	Startup successful
          Dec 24 07:37:15 	upsmon 	25058 	Poll UPS [ActiveJet] failed - Driver not connected
          Dec 24 07:37:10 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxxxxx OK
          Dec 24 07:37:10 	upsmon 	25058 	Communications with UPS ActiveJet lost
          Dec 24 07:37:10 	upsmon 	25058 	Poll UPS [ActiveJet] failed - Driver not connected
          Dec 24 07:37:08 	blazer_usb 	60207 	Signal 15: exiting
          Dec 24 07:37:00 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxxxxx OK
          Dec 24 07:37:00 	upsmon 	25058 	Communications with UPS ActiveJet established
          Dec 24 07:36:55 	upsd 	26542 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
          Dec 24 07:36:55 	upsmon 	25058 	Poll UPS [ActiveJet] failed - Driver not connected
          Dec 24 07:36:53 	blazer_usb 	60207 	Startup successful
          Dec 24 07:36:50 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxxxxx OK
          Dec 24 07:36:50 	upsmon 	25058 	Communications with UPS ActiveJet lost
          Dec 24 07:36:50 	upsmon 	25058 	Poll UPS [ActiveJet] failed - Driver not connected
          Dec 24 07:36:47 	blazer_usb 	26864 	Signal 15: exiting
          Dec 24 07:36:35 	upsd 	26542 	User monuser@127.0.0.1 logged into UPS [ActiveJet]
          Dec 24 07:36:35 	upsd 	26542 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
          Dec 24 07:36:33 	blazer_usb 	26864 	Startup successful
          Dec 24 07:36:33 	upsd 	26542 	Startup successful
          Dec 24 07:36:33 	upsd 	26332 	Can't connect to UPS [ActiveJet] (blazer_usb-ActiveJet): No such file or directory
          Dec 24 07:36:33 	upsd 	26332 	listening on 127.0.0.1 port 3493
          Dec 24 07:36:33 	upsd 	26332 	listening on ::1 port 3493
          Dec 24 07:36:32 	upsmon 	24793 	Startup successful 
          

          edit:

          only pid I have in /var/db/nut:
          blazer_usb-ActiveJet.pid
          upsmon.pid
          upsd.pid

          I try to use script with blazer_usb-ActiveJet.pid

          edit2:

          now it looks ok, will see in time how is doing.
          thank you.

          1 Reply Last reply Reply Quote 0
          • D
            dennypage
            last edited by Dec 24, 2016, 7:10 AM

            Did you stop the service before putting the new script in place? If not, the old script may still be running.

            The command to stop the script is:

            /usr/local/etc/rc.d/nut.sh stop

            After doing so, the following commands should find no processes:
              ps -axuw | grep ups
              ps -axuw | grep nut
              ps -axuw | grep blazer

            If that isn't the issue, please run the debug version below by hand. The command to do this is:

            /usr/local/etc/rc.d/nut.sh start

            Make sure the service is stopped before you start the debug script. Also understand that it will continue to product output even after the command prompt returns. To stop it, you again would execute:

            /usr/local/etc/rc.d/nut.sh stop

            Please let it run for a minute or two and post the output from the terminal. I'll have a look at it in the morning.

            #!/bin/sh
            # This file has been modified for special upsdrvctl restart
            
            rc_start() {
            	echo starting NUT
            	if [ -f /var/run/upsdrvctl_loop.pid ]
            	then
            		kill -9 `cat /var/db/nut/upsdrvctl_loop.pid`
            		rm /var/run/upsdrvctl_loop.pid
            	fi
            	/usr/bin/killall -q -9 upsmon
            	/usr/bin/killall -q -9 upsd
            	/usr/bin/killall -q -9 upsdrvctl
            	/usr/bin/killall -q -9 blazer_usb
            	/usr/local/sbin/upsmon
            	/usr/local/sbin/upsdrvctl start &
            	(
            		while true
            		do
            			sleep 15
            			echo "contents of /var/db/nut:"
            			ls -l /var/db/nut
            			echo "running pid of blazer_usb is" `cat /var/db/nut/blazer_usb.pid`
            			ps -fp `cat /var/db/nut/blazer_usb.pid`
            			kill -0 `cat /var/db/nut/blazer_usb.pid` && continue
            			echo "blazer_usb no longer running... restarting"
            			/usr/local/sbin/upsdrvctl start
            		done
            	) &
            	echo $! > /var/db/nut/upsdrvctl_loop.pid
            	sleep 1
            	/usr/local/sbin/upsd -u root
            	return 0
            }
            
            rc_stop() {
            	echo stopping NUT
            	if [ -f /var/db/nut/upsdrvctl_loop.pid ]
            	then
            		kill -9 `cat /var/db/nut/upsdrvctl_loop.pid`
            		rm /var/db/nut/upsdrvctl_loop.pid
            	fi
            	/usr/bin/killall -q upsmon
            	/usr/bin/killall -q upsd
            	/usr/bin/killall -q upsdrvctl
            	/usr/bin/killall -q blazer_usb
            	return 0
            }
            
            case $1 in
            	start)
            		rc_start
            		;;
            	stop)
            		rc_stop
            		;;
            	restart)
            		rc_stop
            		rc_start
            		;;
            esac
            
            
            1 Reply Last reply Reply Quote 0
            • N
              n3by
              last edited by Dec 24, 2016, 5:29 PM

              dennypage just to let you know that your script is working great until now, and I made your changes in nut.inc so it will survive a reboot or UPS parameter changes till package upgrade/reinstall.

              In case anybody else will need it; just make the appropriate changes for you in the line with "blazer_usb-ActiveJet.pid";
              you can find your "driver_usb-upsname.pid" in /var/db/nut/ when NUT is running…

              credit go to dennypage !

              part with changes I made in:
              /usr/local/pkg/nut/nut.inc

              function nut_write_rcfile($driver) {
              	nut_check_var_db();
              	$start .= "echo starting NUT";
              	$start .= "\n	if [ -f /var/run/upsdrvctl_loop.pid ]";
              	$start .= "\n	then";
              	$start .= "\n		kill -9 `cat /var/db/nut/upsdrvctl_loop.pid`";
              	$start .= "\n		rm /var/run/upsdrvctl_loop.pid";
              	$start .= "\n	fi";
              	$start .= "\n	/usr/bin/killall -q -9 upsmon";
              	$start .= "\n	/usr/bin/killall -q -9 upsd";
              	$start .= "\n	/usr/bin/killall -q -9 upsdrvctl";
              	if (isset($driver)) {
              		$start .= "\n	/usr/bin/killall -q -9 $driver";
              	}
              
              	/* Service status keys off upsmon, so start it first. */
              	$start .= "\n	/usr/local/sbin/upsmon";
              	if (isset($driver)) {
              		$start .= "\n	/usr/local/sbin/upsdrvctl start &";
              		$start .= "\n	(";
              		$start .= "\n		while true";
              		$start .= "\n		do";
              		$start .= "\n			sleep 15";
              		$start .= "\n			kill -0 `cat /var/db/nut/blazer_usb-ActiveJet.pid` > /dev/null 2>&1 && continue";
              		$start .= "\n			/usr/local/sbin/upsdrvctl start";
              		$start .= "\n		done";
              		$start .= "\n	) &";
              		$start .= "\n	echo $! > /var/db/nut/upsdrvctl_loop.pid";
              		/* Since we are starting the driver in backgroud, give it a moment to start. */
              		$start .= "\n	sleep 1";
              		$start .= "\n	/usr/local/sbin/upsd -u root";
              	}
              	$start .= "\n	return 0";
              
              	$stop .= "echo stopping NUT";
              	$stop .= "\n	if [ -f /var/db/nut/upsdrvctl_loop.pid ]";
              	$stop .= "\n	then";
              	$stop .= "\n		kill -9 `cat /var/db/nut/upsdrvctl_loop.pid`";
              	$stop .= "\n		rm /var/db/nut/upsdrvctl_loop.pid";
              	$stop .= "\n	fi";
              	$stop .= "\n	/usr/bin/killall -q upsmon";
              	if (isset($driver)) {
              		$stop .= "\n	/usr/bin/killall -q upsd";
              		$stop .= "\n	/usr/bin/killall -q upsdrvctl";
              		$stop .= "\n	/usr/bin/killall -q $driver";
              	}
              	$stop .= "\n	return 0";
              
              	write_rcfile(array(
              		"file" => "nut.sh",
              		"start" => $start,
              		"stop" => $stop
              		)
              	);
              

              Thank you very much for help to all that got involved to solve this/my problem !
              and
              Merry Christmas !

              1 Reply Last reply Reply Quote 0
              • D
                dennypage
                last edited by Dec 24, 2016, 6:37 PM

                @n3by:

                In case anybody else will need it; just make the appropriate changes for you in the line with "blazer_usb-ActiveJet.pid";
                you can find your "driver_usb-upsname.pid" in /var/db/nut/ when NUT is running…

                I forgot about the ups name in the pid file. It had to be something stupid.

                On the system I was testing on the ups is named "ups" and the driver name is "usbhid-ups". This results in a pid file named "usbhid-ups-ups.pid". I think I'll change the name of the ups to prevent this sort of mistake in the future. :)

                1 Reply Last reply Reply Quote 0
                • E
                  endy66
                  last edited by Jan 7, 2017, 8:34 AM

                  Yesterday i saw in my pfsense, that there is an update for the nut package (2.7.4_3). Is it save to hit the update button, or will the custom Settings be lost after the update?

                  Best Regards

                  1 Reply Last reply Reply Quote 0
                  • D
                    dennypage
                    last edited by Jan 7, 2017, 3:15 PM

                    What version of the nut package are you currently running? If you are already running 2.7.4, then there should no issue with the update. If you are running a version prior to 2.7.4, then the settings will be converted from the old package to the new package, and may require attention. See the beginning of this thread for more information. If you are still unsure, post some information about your settings.

                    The current version is 2.7.4_4

                    1 Reply Last reply Reply Quote 0
                    • E
                      endy66
                      last edited by Jan 8, 2017, 7:39 AM

                      @dennypage:

                      What version of the nut package are you currently running? If you are already running 2.7.4, then there should no issue with the update. If you are running a version prior to 2.7.4, then the settings will be converted from the old package to the new package, and may require attention. See the beginning of this thread for more information. If you are still unsure, post some information about your settings.

                      The current version is 2.7.4_4

                      Thank you for the answer. I'm using the Version 2.7.4_3. Do i Need to save some Settings? I have set custom Parameters on the following fileds:

                      • Extra Arguments to Driver (optional
                      • Additional configuration lines for upsd.conf
                      • Additional configuration lines for upsd.users

                      Best Regards

                      1 Reply Last reply Reply Quote 0
                      • D
                        dennypage
                        last edited by Jan 8, 2017, 7:42 AM

                        @endy66:

                        Thank you for the answer. I'm using the Version 2.7.4_3. Do i Need to save some Settings?

                        In moving from 2.7.4_3 to 2.7.4_4 there is nothing special you need to do. The settings will all be maintained.

                        1 Reply Last reply Reply Quote 0
                        • E
                          endy66
                          last edited by Jan 10, 2017, 3:34 PM

                          @dennypage:

                          @endy66:

                          Thank you for the answer. I'm using the Version 2.7.4_3. Do i Need to save some Settings?

                          In moving from 2.7.4_3 to 2.7.4_4 there is nothing special you need to do. The settings will all be maintained.

                          Perfect, thank you!

                          1 Reply Last reply Reply Quote 0
                          • A
                            athurdent
                            last edited by Feb 23, 2017, 10:46 AM

                            Thanks for this nice package, works fine and look great!

                            Forgive me for being slightly OT, but is it normal for a UPS to stay at 100% Charging? It's my first UPS ever and running like this for 2 days now (EATON 3S 550). Shouldn't it stop charging when it's at 100%?

                            1 Reply Last reply Reply Quote 0
                            • D
                              doktornotor Banned
                              last edited by Feb 23, 2017, 12:02 PM

                              That's Eaton special.

                              1 Reply Last reply Reply Quote 0
                              • A
                                athurdent
                                last edited by Feb 23, 2017, 12:07 PM

                                @doktornotor:

                                That's Eaton special.

                                So this is normal with EATON and I don't have to get it exchanged?

                                1 Reply Last reply Reply Quote 0
                                • D
                                  doktornotor Banned
                                  last edited by Feb 23, 2017, 12:11 PM

                                  Yes, it happens with any Eaton I tried. Whether or not it's charging, NFC. The package only reports what's reported by firmware.

                                  1 Reply Last reply Reply Quote 0
                                  • A
                                    athurdent
                                    last edited by Feb 23, 2017, 12:14 PM

                                    Thanks, doc! :)

                                    1 Reply Last reply Reply Quote 0
                                    • P
                                      poluket
                                      last edited by Mar 7, 2017, 1:43 PM Mar 6, 2017, 10:14 AM

                                      Hello,

                                      sorry for my English :)

                                      I think that I have the same problem than ecfx-xunil but I am a newbie.

                                      PFsense version : 2.3.3 amd 64

                                      NUT package version 2.7.4_4

                                      I have an UPS FSP EP 2000

                                      I use the nutdrv_qx driver. (without custom option)

                                      it work fine but after a time, I have this message "Failed to retrieve status". I click on top to restart the service on the gui and i have again the value.

                                      I have seen your message but I don't understand what to do to resolve the problem.

                                      I need to chage the code?

                                      Thank you  for your help.

                                      1 Reply Last reply Reply Quote 0
                                      • D
                                        dennypage
                                        last edited by Mar 6, 2017, 4:56 PM

                                        Have you checked the system log? In Status / System Logs / System / General, look for messages matching "ups" or "nut".

                                        1 Reply Last reply Reply Quote 0
                                        • P
                                          poluket
                                          last edited by Mar 7, 2017, 1:42 PM Mar 7, 2017, 12:53 PM

                                          thank you for your help :)

                                          the logs when I have the problem (newest entries on top):

                                          Mar 7 13:48:30 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:48:25 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:48:25 	kernel 		ugen3.2: <inno tech="">at usbus3
                                          Mar 7 13:48:22 	kernel 		ugen3.2: <inno tech="">at usbus3 (disconnected)
                                          Mar 7 13:48:20 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:48:17 	upsd 	90750 	Can't connect to UPS [UPS-Local-USB] (nutdrv_qx-UPS-Local-USB): No such file or directory
                                          Mar 7 13:48:15 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:48:14 	kernel 		ugen3.2: <inno tech="">at usbus3
                                          Mar 7 13:48:11 	kernel 		ugen3.2: <inno tech="">at usbus3 (disconnected)
                                          Mar 7 13:48:10 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:48:05 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:48:02 	kernel 		ugen3.2: <inno tech="">at usbus3
                                          Mar 7 13:48:00 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:48:00 	kernel 		ugen3.2: <inno tech="">at usbus3 (disconnected)
                                          Mar 7 13:47:55 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:47:51 	kernel 		ugen3.2: <inno tech="">at usbus3
                                          Mar 7 13:47:50 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:47:48 	kernel 		ugen3.2: <inno tech="">at usbus3 (disconnected)
                                          Mar 7 13:47:45 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:47:40 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:47:40 	kernel 		ugen3.2: <inno tech="">at usbus3
                                          Mar 7 13:47:37 	kernel 		ugen3.2: <inno tech="">at usbus3 (disconnected)
                                          Mar 7 13:47:35 	upsmon 	80446 	Communications with UPS UPS-Local-USB lost
                                          Mar 7 13:47:35 	upsmon 	80446 	Poll UPS [UPS-Local-USB] failed - Driver not connected
                                          Mar 7 13:47:33 	nutdrv_qx 	96269 	Permissions problem: Input/output error</inno></inno></inno></inno></inno></inno></inno></inno></inno></inno> 
                                          

                                          and after a service reboot:

                                          Mar 7 14:00:49 	upsd 	41029 	User monuser@::1 logged into UPS [UPS-Local-USB]
                                          Mar 7 14:00:49 	upsd 	41029 	Connected to UPS [UPS-Local-USB]: nutdrv_qx-UPS-Local-USB
                                          Mar 7 14:00:48 	nutdrv_qx 	41173 	Startup successful
                                          Mar 7 14:00:47 	upsd 	41029 	Startup successful
                                          Mar 7 14:00:47 	upsd 	40900 	Can't connect to UPS [UPS-Local-USB] (nutdrv_qx-UPS-Local-USB): No such file or directory
                                          Mar 7 14:00:47 	upsd 	40900 	listening on 127.0.0.1 port 3493
                                          Mar 7 14:00:47 	upsd 	40900 	listening on ::1 port 3493
                                          Mar 7 14:00:46 	upsmon 	39909 	Startup successful
                                          Mar 7 14:00:46 	upsd 	90750 	Signal 15: exiting
                                          Mar 7 14:00:46 	upsd 	90750 	mainloop: Interrupted system call
                                          Mar 7 14:00:46 	upsd 	90750 	User monuser@::1 logged out from UPS [UPS-Local-USB]
                                          Mar 7 14:00:46 	upsmon 	80446 	Signal 15: exiting 
                                          

                                          I have found this:

                                          https://www.nas4free.org/forums/viewtopic.php?t=946
                                          In port #17, he change the pollinterval to 10/15. Maybe a solution?

                                          https://forums.freenas.org/index.php?threads/2-issues-behaviours-with-attached-and-identified-ups.24033/
                                          or use a script with cron …

                                          like he say: "I would be very happy to know that there's another/better solution."

                                          thank for read my message

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