-
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
-
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.
-
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
-
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.
-
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
-
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
-
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.
-
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.pidI try to use script with blazer_usb-ActiveJet.pid
edit2:
now it looks ok, will see in time how is doing.
thank you. -
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 blazerIf 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
-
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.incfunction 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 ! -
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. :)
-
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
-
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
-
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
-
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.
-
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!
-
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%?
-
That's Eaton special.
-
That's Eaton special.
So this is normal with EATON and I don't have to get it exchanged?
-
Yes, it happens with any Eaton I tried. Whether or not it's charging, NFC. The package only reports what's reported by firmware.