Jump to content
dmacias

[Plugin] NUT v2 - Network UPS Tools

235 posts in this topic Last Reply

Recommended Posts

5 hours ago, dmacias said:

But the missing button only happens if the service is enabled and started.

 

What happens is that the service being started keeps hold of the executing plugin script, and hence the done button is not displayed because the script never finishes.

 

A workaround is to start a service using an event trigger ('at' command) and let it run detached in the background.

The following is an extract from the cache_dirs plugin script.

<!-- WORKAROUND -->
<FILE Name="/tmp/start_service" Mode="0770">
<INLINE>
#!/bin/bash
/usr/local/emhttp/plugins/dynamix.cache.dirs/scripts/rc.cachedirs start
</INLINE>
</FILE>

The above is a temporary file created first and which is called to start the cache_dirs service. A post installation script in the plugin does the actual execution, like this:

<!-- POST-INSTALL SCRIPT -->
<FILE Run="/bin/bash">
<INLINE>
...
# Start service
at -M -f /tmp/start_service now 2>/dev/null

# Remove temp file
rm -f /tmp/start_service
...
</INLINE>
</FILE>

 

Edited by bonienl

Share this post


Link to post
  What happens is that the service being started keeps hold of the executing plugin script, and hence the done button is not displayed because the script never finishes.

 

A workaround is to start a service using an event trigger ('at' command) and let it run detached in the background.

The following is an extract from the cache_dirs plugin script.

 

<!-- WORKAROUND --><FILE Name="/tmp/start_service" Mode="0770"><INLINE>#!/bin/bash/usr/local/emhttp/plugins/dynamix.cache.dirs/scripts/rc.cachedirs start</INLINE></FILE>

The above is a temporary file created first and which is called to start the cache_dirs service. A post installation script in the plugin does the actual execution, like this:

 

<!-- POST-INSTALL SCRIPT --><FILE Run="/bin/bash"><INLINE>...# Start serviceat -M -f /tmp/start_service now 2>/dev/null# Remove temp filerm -f /tmp/start_service...</INLINE></FILE>

 

Thanks, that worked. Should have looked through your plugins.

 

 

Share this post


Link to post

I updated my server to  6.4.0rc10b but during boot / plugin install when the nut usb driver loaded my usb would reset. 

Server kernel: usb 1-1.3:reset high-speed USB device number 4 using ehci-pci

Which is not good for the unRAID usb. So  this would basically hang start up.. I downgraded the plugin to 2.7.4 and everything works fine now.

Share this post


Link to post

I am trying to figure out how to remove NUT as it conflicts with the built in UPS tool  but I can't get it to work. I have tried going into the plugin manager and clicking remove but get the following:

Any suggestions would be appreciated.

plugin: removing: nut.plg
Writing nut config
nut group already configured
nut user already configured
UDEV lines already exist in rc.0,6
UPS shutdown lines already exist in rc.0,6
Stopping the UPS services... 
Network UPS Tools upsd 2.7.4
Network UPS Tools - UPS driver controller 2.7.4
plugin: run failed: /bin/bash retval: 2

 

A

Share this post


Link to post

Give me a few. I'll update the plugin. You can then update then remove it.

Share this post


Link to post
44 minutes ago, mhjackson123 said:

I am trying to figure out how to remove NUT as it conflicts with the built in UPS tool  but I can't get it to work. I have tried going into the plugin manager and clicking remove but get the following:

Any suggestions would be appreciated.

plugin: removing: nut.plg
Writing nut config
nut group already configured
nut user already configured
UDEV lines already exist in rc.0,6
UPS shutdown lines already exist in rc.0,6
Stopping the UPS services... 
Network UPS Tools upsd 2.7.4
Network UPS Tools - UPS driver controller 2.7.4
plugin: run failed: /bin/bash retval: 2

 

A

Update the plugin and then you can remove it. If the built in UPS tool works for you then use that. But if you want to use NUT then disable the built in UPS. I have the built in set to:

Start APC UPS daemon: No

UPS cable: Custom

UPS type: Dumb

Edited by dmacias

Share this post


Link to post
How does this compare with the built in UPS tool? [mention=11874]dmacias[/mention]
It's has the same functionality. However, NUT has network capability and more drivers for other UPS that aren't supported by apcupsd. The network mode allows it to be run as master. Then you could connect other machines or vm's as slaves. They could monitor the ups too and be shut down.
  • Upvote 1

Share this post


Link to post

Thanks for the updated plugin! I've been running without integration w/ my UPS since development of the v1 plugin was stalled a couple years ago. Much appreciated!

 

One bit of feedback: you seem to have put a constraint on the length of the text field for "port". I have a networked TrippLite SMART5000RT, which can be polled via SNMP. However, the allowed length of the port field when the snmp-ups driver is selected is too short to enter "192.168.0.31". I got it to work by configuring the plugin for "manual only" mode and putting the following into the ups.conf file:

 

[ups]
driver = snmp-ups
port = 192.168.0.31
community = public
snmp_version = v2c
pollfreq = 15

 

If you increased the allowed length of the port text box I'd be able to use auto config as well ;)

 

Thanks again,

 

-A

  • Like 1

Share this post


Link to post
6 hours ago, Ambrotos said:

Thanks for the updated plugin! I've been running without integration w/ my UPS since development of the v1 plugin was stalled a couple years ago. Much appreciated!

 

One bit of feedback: you seem to have put a constraint on the length of the text field for "port". I have a networked TrippLite SMART5000RT, which can be polled via SNMP. However, the allowed length of the port field when the snmp-ups driver is selected is too short to enter "192.168.0.31". I got it to work by configuring the plugin for "manual only" mode and putting the following into the ups.conf file:

 


[ups]
driver = snmp-ups
port = 192.168.0.31
community = public
snmp_version = v2c
pollfreq = 15

 

If you increased the allowed length of the port text box I'd be able to use auto config as well ;)

 

Thanks again,

 

-A

Should be fixed now.

Share this post


Link to post

I am having trouble getting this to plugin to detect and use my UPS.

  • When I use the AutoDetect button it chooses Blazer_usb for the UPS Driver. From looking on the internet it should be choosing usbhid-ups.
    • When i run nut-scanner from the console i get the following
    • nut-scanner
      Neon library not found. XML search disabled.
      Scanning USB bus.
      No start IP, skipping SNMP
      No start IP, skipping NUT bus (old connect method)
      [nutdev1]
              driver = "usbhid-ups"
              port = "auto"
              vendorid = "0764"
              productid = "0501"
              product = "CP1000PFCLCD"
              serial = "000000000000"
              vendor = "CPS"
              bus = "004"

       

  • Regardless of which driver I choose, the autodetected or the one i believe to be correct, I cannot get the service to start. No matter what settings I apply the Status remains Stopped.

I would be grateful for any help you could provide.

Share this post


Link to post



I am having trouble getting this to plugin to detect and use my UPS.
  • When I use the AutoDetect button it chooses Blazer_usb for the UPS Driver. From looking on the internet it should be choosing usbhid-ups.
    • When i run nut-scanner from the console i get the following
    • nut-scanner
      Neon library not found. XML search disabled.
      Scanning USB bus.
      No start IP, skipping SNMP
      No start IP, skipping NUT bus (old connect method)
      [nutdev1]
              driver = "usbhid-ups"
              port = "auto"
              vendorid = "0764"
              productid = "0501"
              product = "CP1000PFCLCD"
              serial = "000000000000"
              vendor = "CPS"
              bus = "004"
       
  • Regardless of which driver I choose, the autodetected or the one i believe to be correct, I cannot get the service to start. No matter what settings I apply the Status remains Stopped.
I would be grateful for any help you could provide.


I have the 850 and the 1500 of the same model. You should use the usbhid-ups diver. Try running "/etc/rc.d/rc.nut start" What's your upsmon.conf look like? Also try a different usb port and not usb3.

Share this post


Link to post

Here is the output of /etc/rc.d/rc.nut start

Writing nut config
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
Can't claim USB device [0764:0501]: No such file or directory
Driver failed to start (exit status=1)

 

upsmon.conf is as follows

MONITOR ups@127.0.0.1 1 monuser monpass master
SHUTDOWNCMD "/sbin/poweroff"
POWERDOWNFLAG /etc/nut/no_killpower
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYCMD "/usr/sbin/nut-notify"

 

I have tried a different port it did not help the situation, no USB3 on the server.

 

Share this post


Link to post
3 hours ago, primeval_god said:

Here is the output of /etc/rc.d/rc.nut start

Writing nut config
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
Can't claim USB device [0764:0501]: No such file or directory
Driver failed to start (exit status=1)

 

I have tried a different port it did not help the situation, no USB3 on the server.

Is the builtin APCUPSD turned off. I have No, Custom, empty and Dumb set? Check "ps aux | grep ups" for any running ups commands. Usb isn't assigned to a vm? udev rules set for something else?

This is what my /etc/rc.d/rc.nut start looks like

Writing nut config
Updating permissions...
Network UPS Tools - UPS driver controller 2.7.4
Network UPS Tools - Generic HID driver 0.41 (2.7.4)
USB communication driver 0.33
Using subdriver: CyberPower HID 0.4
Network UPS Tools upsd 2.7.4
fopen /var/run/nut/upsd.pid: No such file or directory
listening on 0.0.0.0 port 3493
Connected to UPS [CyberPower850]: usbhid-ups-CyberPower850
Network UPS Tools upsmon 2.7.4
fopen /var/run/nut/upsmon.pid: No such file or directory
UPS: CyberPower850@127.0.0.1 (master) (power value 1)
Using power down flag file /etc/nut/killpower

 

Share this post


Link to post

I got it working! Thanks dmacias. Turns out that even though i had APCUPSD turned off as you described there was a leftover process hanging around.

Share this post


Link to post

Can you add multiple UPS'es to be monitored with your script, but only have unraid react to one of them in order to shutdown.

The second and third ups'es would also be on usb ports.

 

 

Share this post


Link to post
Can you add multiple UPS'es to be monitored with your script, but only have unraid react to one of them in order to shutdown.
The second and third ups'es would also be on usb ports.
 
 
I may add support to the Nut Details page (e.g a drop down based on the ups.conf) for monitoring other defined ups but that's about it. You could use the manual mode and add all the info to the conf files. The ups' would have to distinguishable from each other. From the manual:
some combination of the "vendor", "product", "serial", "vendorid", and "productid" options. For instance: e.g.
[mge]driver = usbhid-upsport = autovendorid = 0463[tripplite]driver = usbhid-upsport = autovendorid = 09ae

  • Like 1

Share this post


Link to post

guys

bought a new UPS 

FSP FP1000.  

I dont know what I am doing actually.  what needs to be the configuration ? I didnt do any changes in the conf files.

should I ?

 

nut-scanner  shows:

         

Neon library not found. XML search disabled.

Scanning USB bus.

No start IP, skipping SNMP

No start IP, skipping NUT bus (old connect method)

[nutdev1]

driver = "nutdrv_qx"

port = "auto"

vendorid = "0665"

productid = "5161"

product = "USB to Serial"

vendor = "INNO TECH"

bus = "002"

 

when I set the type to Blazer_usb the driver starts but shows errors.

 

Dec 6 21:44:43 Tower upsmon[4274]: UPS [ups@127.0.0.1]: connect failed: Connection failure: Connection refused
 

 

root@Tower:~# /etc/rc.d/rc.nut start

Writing nut config

Updating permissions...

Network UPS Tools - UPS driver controller 2.7.4

Network UPS Tools - Megatec/Q1 protocol USB driver 0.12 (2.7.4)

Supported UPS detected with mustek protocol

Vendor information unavailable

No values provided for battery high/low voltages in ups.conf

 

Using 'guestimation' (low: 20.800000, high: 26.000000)!

Battery runtime will not be calculated (runtimecal not set)

nut upsd is running...

Network UPS Tools upsmon 2.7.4

fopen /var/run/nut/upsmon.pid: No such file or directory

UPS: ups@127.0.0.1 (master) (power value 1)

Using power down flag file /etc/nut/no_killpower

                                                                               

Broadcast message from root@Tower (somewhere) (Wed Dec  6 21:43:48 2017):      

                                                                               

Communications with UPS ups@127.0.0.1 lost                                     

                                                                               

                                                                               

Broadcast message from root@Tower (somewhere) (Wed Dec  6 21:43:53 2017):      

                                                                               

UPS ups@127.0.0.1 is unavailable      

 



 

Share this post


Link to post

 

 

 

 

 

 

 

guys bought a new UPS  FSP FP1000.   I dont know what I am doing actually.  what needs to be the configuration ? I didnt do any changes in the conf files. should I ?

 

nut-scanner  shows:

         

Neon library not found. XML search disabled.

Scanning USB bus.

No start IP, skipping SNMP

No start IP, skipping NUT bus (old connect method)

[nutdev1]

driver = "nutdrv_qx"

port = "auto"

vendorid = "0665"

productid = "5161"

product = "USB to Serial"

vendor = "INNO TECH"

bus = "002"

 

when I set the type to Blazer_usb the driver starts but shows errors.

 

Dec 6 21:44:43 Tower upsmon[4274]: UPS [ups@127.0.0.1]: connect failed: Connection failure: Connection refused

 

 

root@Tower:~# /etc/rc.d/rc.nut start

Writing nut config

Updating permissions...

Network UPS Tools - UPS driver controller 2.7.4

Network UPS Tools - Megatec/Q1 protocol USB driver 0.12 (2.7.4)

Supported UPS detected with mustek protocol

Vendor information unavailable

No values provided for battery high/low voltages in ups.conf

 

Using 'guestimation' (low: 20.800000, high: 26.000000)!

Battery runtime will not be calculated (runtimecal not set)

nut upsd is running...

Network UPS Tools upsmon 2.7.4

fopen /var/run/nut/upsmon.pid: No such file or directory

UPS: ups@127.0.0.1 (master) (power value 1)

Using power down flag file /etc/nut/no_killpower

                                                                               

Broadcast message from root@Tower (somewhere) (Wed Dec  6 21:43:48 2017):      

                                                                               

Communications with UPS ups@127.0.0.1 lost                                     

                                                                               

                                                                               

Broadcast message from root@Tower (somewhere) (Wed Dec  6 21:43:53 2017):      

                                                                               

UPS ups@127.0.0.1 is unavailable      

 



 

 

 

 

 

 Try using custom driver and type in nutdrv_qx. If that didn't work, edit the ups.conf and add the info from the scanner so it looks like this.

 

driver = "nutdrv_qx"

port = "auto"

vendorid = "0665"

productid = "5161"

product = "USB to Serial"

vendor = "INNO TECH"

bus = "002" 

 

 

 

 

 

 

Share this post


Link to post

I assumed I need to choose Manual config ?   

otherwise the ups.conf is overwritten. 

in any case it didnt work. both changes I get :

Dec 6 22:52:11 Tower upsmon[22300]: UPS [ups@127.0.0.1]: connect failed: Connection failure: Connection refused

BTW in the upsd.conf I have

listen  0.0.0.0

is it ok? 

 

digging and googling , I have seen someone suggesting to use subdriver definition ?!?!   phoenix, ippon,krauler.   

dont know if makes sense and how to do it

Share this post


Link to post

found this:  http://www.evilbox.ro/linux/how-to-monitor-mustek-powermust-2012-ups-with-ubuntu-server-14/

how can it help?

 

 

You may receive the error message below :

1
2
3
Can't claim USB device [0665:5161]: could not detach kernel driver from
interface 0: Operation not permitted
Driver failed to start (exit status=1)

This means that there is a problem with permissions, so we need to set the permission and then reboot.

Set permissions for UPS, remember the descriptor noted above, 0665:5161 in my case:

root@erp:/# nano /etc/udev/rules.d/10-must-pa-2012.rules
Add the line :

1
SYSFS{idVendor}=='0665', SYSFS{idProduct}=='5161', MODE='0666'
 
 
 

Share this post


Link to post

Use manual mode.
ups.conf should look like this

[ups]
driver = "nutdrv_qx"
port = "auto"
vendorid = "0665"
productid = "5161"
product = "USB to Serial"
vendor = "INNO TECH"
bus = "002"


upsmon.conf should look like this

MONITOR ups@127.0.0.1 1 monuser monpass master
SHUTDOWNCMD "/sbin/poweroff"
POWERDOWNFLAG /etc/nut/no_killpower
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYCMD "/usr/sbin/nut-notify"

Run /etc/rc.d/rc.nut start and post the output.

Share this post


Link to post

hi

bellow is the output

 

but I think there is currently a problem in the system. it started only a few hours ago. something to do with all the back and forth I am doing with the system.

the messages run all the time while the UPS is connected to the USB port...

Dec 7 10:07:28 Tower kernel: usb 2-1.2: USB disconnect, device number 123
Dec 7 10:07:29 Tower kernel: usb 2-1.2: new low-speed USB device number 124 using ehci-pci
Dec 7 10:07:30 Tower kernel: hid-generic 0003:0665:5161.0730: hiddev0,hidraw0: USB HID v1.00 Device [INNO TECH USB to Serial] on usb-0000:00:1d.0-1.2/input0
Dec 7 10:07:39 Tower kernel: usb 2-1.2: USB disconnect, device number 124
Dec 7 10:07:41 Tower kernel: usb 2-1.2: new low-speed USB device number 125 using ehci-pci
Dec 7 10:07:41 Tower kernel: hid-generic 0003:0665:5161.0731: hiddev0,hidraw0: USB HID v1.00 Device [INNO TECH USB to Serial] on usb-0000:00:1d.0-1.2/input0

 

after I configured as suggested, the messages are now diffrent

 

Dec 7 10:09:17 Tower upsmon[10803]: UPS [ups@127.0.0.1]: connect failed: Connection failure: Connection refused
 

 

 

d# /etc/rc.d/rc.nut start 

Writing nut config

Updating permissions...

Network UPS Tools - UPS driver controller 2.7.4

Network UPS Tools - Generic Q* USB/Serial driver 0.28 (2.7.4)

USB communication driver 0.33

Using protocol: Voltronic-QS 0.07

No values for battery high/low voltages

Using 'guesstimation' (low: 20.800000, high: 26.000000)!

Battery runtime will not be calculated (runtimecal not set)

nut upsd is running...

Network UPS Tools upsmon 2.7.4

fopen /var/run/nut/upsmon.pid: No such file or directory

UPS: ups@127.0.0.1 (master) (power value 1)

Using power down flag file /etc/nut/no_killpower

                                                                               

Broadcast message from root@Tower (somewhere) (Thu Dec  7 10:07:47 2017):      

                                                                               

Communications with UPS ups@127.0.0.1 lost                                     

                                                                               

                                                                               

Broadcast message from root@Tower (somewhere) (Thu Dec  7 10:07:52 2017):      

                                                                               

UPS ups@127.0.0.1 is unavailable         

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now