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

    NUT package (2.8.0 and below)

    Scheduled Pinned Locked Moved UPS Tools
    1.2k Posts 128 Posters 4.1m 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.
    • N
      n3by
      last edited by

      This is what I did:

      because this is normal output if communication with UPS is working OK:

      upsc ActiveJet

      battery.charge: 100
      battery.charge.low: 50
      battery.runtime: 714
      battery.runtime.low: 600
      battery.voltage: 13.70
      battery.voltage.high: 13.7
      battery.voltage.low: 12
      device.type: ups
      driver.flag.norating: enabled
      driver.flag.novendor: enabled
      driver.name: blazer_usb
      driver.parameter.pollinterval: 10
      driver.parameter.port: auto
      driver.parameter.protocol: mustek
      driver.parameter.runtimecal: 180,100,320,50
      driver.parameter.synchronous: no
      driver.version: 2.7.4
      driver.version.internal: 0.12
      input.frequency: 50.0
      input.voltage: 241.2
      input.voltage.fault: 241.2
      output.voltage: 241.2
      ups.beeper.status: enabled
      ups.delay.shutdown: 30
      ups.delay.start: 180
      ups.load: 19
      ups.productid: 5161
      ups.status: OL
      ups.type: offline / line interactive
      ups.vendorid: 0665
      

      I changed your script to this one:

      #!/bin/sh

      Script to restart NUT and USB UPS if UPS connection failed on ActiveJet

      upsname="ActiveJet"
      pattern="battery.charge:"
      check=$(upsc $upsname | grep -o "$pattern")
      if [ "$check" != "$pattern" ]; then
      /usr/local/etc/rc.d/nut.sh stop

      usbconfig -d 5.1 set_config 255

      sleep 10

      usbconfig -d 5.1 set_config 0

      sleep 5
      /usr/local/etc/rc.d/nut.sh start
      fi

      and I added to cron to run it every 3 min.

      If you have a better suggestion please share.

      Thank you again !

      edit:
      changed the script and cron from 2 to 3 and now to 4 min because something is not ok and it restart to often.

      1 Reply Last reply Reply Quote 0
      • N
        n3by
        last edited by

        strange …  If I did not made a mistake I think the script interfere with normal NUT because it will restart almost every time.
        Maybe we can look in syslog for last NUT error messages and not try to interrogate NUT ??

        Dec 23 21:40:08 	upsd 	59705 	User monuser@127.0.0.1 logged into UPS [ActiveJet]
        Dec 23 21:40:06 	upsd 	59705 	Startup successful
        Dec 23 21:40:06 	upsd 	59382 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
        Dec 23 21:40:06 	upsd 	59382 	listening on 127.0.0.1 port 3493
        Dec 23 21:40:06 	upsd 	59382 	listening on ::1 port 3493
        Dec 23 21:40:05 	blazer_usb 	59211 	Startup successful
        Dec 23 21:40:05 	upsmon 	58620 	Startup successful
        Dec 23 21:40:00 	blazer_usb 	86268 	Signal 15: exiting
        Dec 23 21:40:00 	upsd 	86696 	Signal 15: exiting
        Dec 23 21:40:00 	upsd 	86696 	mainloop: Interrupted system call
        Dec 23 21:40:00 	upsd 	86696 	User monuser@127.0.0.1 logged out from UPS [ActiveJet]
        Dec 23 21:40:00 	upsmon 	86014 	Signal 15: exiting
        Dec 23 21:36:08 	upsd 	86696 	User monuser@127.0.0.1 logged into UPS [ActiveJet]
        Dec 23 21:36:06 	upsd 	86696 	Startup successful
        Dec 23 21:36:06 	upsd 	86543 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
        Dec 23 21:36:06 	upsd 	86543 	listening on 127.0.0.1 port 3493
        Dec 23 21:36:06 	upsd 	86543 	listening on ::1 port 3493
        Dec 23 21:36:05 	blazer_usb 	86268 	Startup successful
        Dec 23 21:36:05 	upsmon 	85553 	Startup successful
        Dec 23 21:36:00 	blazer_usb 	8319 	Signal 15: exiting
        Dec 23 21:36:00 	upsd 	8660 	Signal 15: exiting
        Dec 23 21:36:00 	upsd 	8660 	mainloop: Interrupted system call
        Dec 23 21:36:00 	upsd 	8660 	User monuser@127.0.0.1 logged out from UPS [ActiveJet]
        Dec 23 21:36:00 	upsmon 	7932 	Signal 15: exiting
        Dec 23 21:32:08 	upsd 	8660 	User monuser@127.0.0.1 logged into UPS [ActiveJet]
        Dec 23 21:32:06 	upsd 	8660 	Startup successful
        Dec 23 21:32:06 	upsd 	8388 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
        Dec 23 21:32:06 	upsd 	8388 	listening on 127.0.0.1 port 3493
        Dec 23 21:32:06 	upsd 	8388 	listening on ::1 port 3493
        Dec 23 21:32:05 	blazer_usb 	8319 	Startup successful
        Dec 23 21:32:05 	upsmon 	7510 	Startup successful
        Dec 23 21:32:00 	upsd 	33016 	Signal 15: exiting
        Dec 23 21:32:00 	upsd 	33016 	mainloop: Interrupted system call
        Dec 23 21:32:00 	upsd 	33016 	User monuser@127.0.0.1 logged out from UPS [ActiveJet]
        Dec 23 21:32:00 	upsmon 	32741 	Signal 15: exiting
        ... 
        
        1 Reply Last reply Reply Quote 0
        • dennypageD
          dennypage
          last edited by

          Remove any other scripts you have put in place and replace /usr/local/etc/rc.d/nut.sh with the script below. I would not add any USB configuration commands unless you encounter a situation in which the script does not restart the driver. If you do encounter such a situation, please run "usbconfig dump_device_desc" while the problem is happening and post the result.

          Note that the nut.sh script is automatically written every time the NUT configuration is saved This will happen anytime you change the UPS config or upgrade pfSense. When this happens, just copy this script back in place.

          I would keep the setting of "pollinterval = 10" in the ups.conf advanced section as this will significantly reduce the number of occurrences of driver failure. No other advanced settings are needed.

          #!/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-ups.pid` > /dev/null 2>&1 && continue
          			echo "needs restart"
          			/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
          • dennypageD
            dennypage
            last edited by

            Regarding the other settings you were doing:

            
            default.battery.voltage.high = 13.7
            default.battery.voltage.low = 11.5
            runtimecal = 180,100,360,50
            ignorelb
            override.battery.charge.low = 50
            override.battery.runtime.low = 600
            
            

            These are actually arguments to the UPS driver rather than global directives. As such, they should be in the (non-advanced) section entitled "Extra Arguments to driver" rather than in the advanced section.

            You should have nothing in the advanced section other than the pollinterval setting in ups.conf.

            Hope this works out for you.

            1 Reply Last reply Reply Quote 0
            • N
              n3by
              last edited by

              I did what you said but it looks like the script enter in a cyclic restart:

              Dec 23 23:36:51 	upsd 	15530 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
              Dec 23 23:36:50 	blazer_usb 	24413 	Startup successful
              Dec 23 23:36:48 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxx OK
              Dec 23 23:36:47 	upsmon 	14675 	Communications with UPS ActiveJet lost
              Dec 23 23:36:47 	upsmon 	14675 	Poll UPS [ActiveJet] failed - Driver not connected
              Dec 23 23:36:44 	blazer_usb 	55222 	Signal 15: exiting
              Dec 23 23:36:33 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxx OK
              Dec 23 23:36:32 	upsmon 	14675 	Communications with UPS ActiveJet established
              Dec 23 23:36:29 	upsd 	15530 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
              Dec 23 23:36:29 	blazer_usb 	55222 	Startup successful
              Dec 23 23:36:27 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxx OK
              Dec 23 23:36:27 	upsmon 	14675 	Communications with UPS ActiveJet lost
              Dec 23 23:36:27 	upsmon 	14675 	Poll UPS [ActiveJet] failed - Driver not connected
              Dec 23 23:36:22 	blazer_usb 	27723 	Signal 15: exiting
              Dec 23 23:36:12 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxx OK
              Dec 23 23:36:12 	upsmon 	14675 	Communications with UPS ActiveJet established
              Dec 23 23:36:09 	upsd 	15530 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
              Dec 23 23:36:07 	blazer_usb 	27723 	Startup successful
              Dec 23 23:36:07 	upsmon 	14675 	Poll UPS [ActiveJet] failed - Driver not connected
              Dec 23 23:36:03 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxx OK
              Dec 23 23:36:02 	upsmon 	14675 	Communications with UPS ActiveJet lost
              Dec 23 23:36:02 	upsmon 	14675 	Poll UPS [ActiveJet] failed - Driver not connected
              Dec 23 23:36:00 	blazer_usb 	90201 	Signal 15: exiting
              Dec 23 23:35:47 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxx OK
              Dec 23 23:35:47 	upsmon 	14675 	Communications with UPS ActiveJet established
              Dec 23 23:35:46 	upsd 	15530 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
              Dec 23 23:35:45 	blazer_usb 	90201 	Startup successful
              Dec 23 23:35:43 	php-cgi 		nut_email.php: Message sent to xxxxxxxxxxx OK
              Dec 23 23:35:42 	upsmon 	14675 	Communications with UPS ActiveJet lost
              Dec 23 23:35:42 	upsmon 	14675 	Poll UPS [ActiveJet] failed - Driver not connected
              Dec 23 23:35:39 	blazer_usb 	15841 	Signal 15: exiting
              Dec 23 23:35:27 	upsd 	15530 	User monuser@127.0.0.1 logged into UPS [ActiveJet]
              Dec 23 23:35:27 	upsd 	15530 	Connected to UPS [ActiveJet]: blazer_usb-ActiveJet
              Dec 23 23:35:25 	blazer_usb 	15841 	Startup successful
              Dec 23 23:35:25 	upsd 	15530 	Startup successful
              Dec 23 23:35:25 	upsd 	15312 	Can't connect to UPS [ActiveJet] (blazer_usb-ActiveJet): No such file or directory
              Dec 23 23:35:25 	upsd 	15312 	listening on 127.0.0.1 port 3493
              Dec 23 23:35:25 	upsd 	15312 	listening on ::1 port 3493
              Dec 23 23:35:24 	upsmon 	14123 	Startup successful 
              
              1 Reply Last reply Reply Quote 0
              • dennypageD
                dennypage
                last edited by

                That looks like kill is missing the -0.

                Just to confirm the script is correct, could you run a sum on it please?

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

                The result should be 60215.

                1 Reply Last reply Reply Quote 0
                • N
                  n3by
                  last edited by

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

                    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
                    • w0wW
                      w0w
                      last edited by

                      @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

                        @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
                        • dennypageD
                          dennypage
                          last edited by

                          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

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

                              @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

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

                                  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

                                    @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
                                    • dennypageD
                                      dennypage
                                      last edited by

                                      @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

                                        @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

                                          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

                                            That's Eaton special.

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