[Plugin] NUT v2 - Network UPS Tools


dmacias

Recommended Posts

30 minutes ago, johnwhicker said:

How do I setup my UnRaid as the NUT master. I change the UPS mode to net server but I can't change the IP from 127.0.0.1 to actually the IP of this UnRaid?  I need this to be the master so I can have a client setup to this master.

 

image.thumb.png.eae2764bd03143916c5064697003bbbd.png

I use the manual config. but the IP address is not used for the master as far as I can remember. My two slaves have the master IP.

 

image.thumb.png.ce7959d986c326ed7a309d285e10a8b3.png

Link to comment
  • 1 month later...
On 9/5/2022 at 12:15 AM, cassiusdrow said:

I have 2.8.0 running on unraid 6.10.3.  I am using an APC SMT1000RM2U with a AP9630 network management card.  It uses the snmp-ups driver and it was failing with this error:

 

/usr/libexec/nut/snmp-ups: error while loading shared libraries: libnetsnmp.so.35: cannot open shared object file: No such file or directory
Driver failed to start (exit status=127)

 

This post suggested installing net-snmp v5.8, but the file no longer exists.  Instead I decided to try to get nut 2.8.0 to run.  I downloaded these package files to the flash drive:

 

https://ftp.sotirov-bg.net/pub/contrib/slackware/packages/slackware64-15.0/nut-2.8.0-x86_64-1gds.txz

https://slackware.uk/slackware/slackware64-15.0/patches/packages/net-snmp-5.9.3-x86_64-1_slack15.0.txz

 

Then added commands to the go script to install the packages and modify the NUT plugin to work with them:

...

 

I had problems with the plugin as well and ended up doing the above. I might start over and see if I can get away without this, but right now I'm also stuck on getting

Quote

UPS [email protected] is unavailable

 

messages repeatedly. I can use snmpwalk to talk to the UPS, which is a CyberPower PR2000RTXL2U. I'm trying to run in standalone mode. I'm not having any luck searching online for what's happening with this, even though it seems like it should be a straightforward configuration issue to sort out.

 

Does anyone know what's happening here?

Link to comment
2 minutes ago, Roland Roberts said:

 

I had problems with the plugin as well and ended up doing the above. I might start over and see if I can get away without this, but right now I'm also stuck on getting

UPS [email protected] is unavailable

messages repeatedly. I can use snmpwalk to talk to the UPS, which is a CyberPower PR2000RTXL2U. I'm trying to run in standalone mode. I'm not having any luck searching online for what's happening with this, even though it seems like it should be a straightforward configuration issue to sort out.

 

Does anyone know what's happening here?

 

Actually, I wonder if the issue is this

1479 root> upsc [email protected] ups.mfr
CYBERPOWER
1479 root> upsc [email protected] ups.status

1479 root>

Note that ups.status isn't returning the 0L message I was expecting.

Link to comment
  • 2 weeks later...
4 hours ago, wraith1385 said:

Does anyone know if this plugin can be used to monitor 2 different UPSs?  I'd like to have this monitor both UPS's and then provide that data to Home Assistant.

No it only supports one UPS. How are you UPS devices connected both into the unraid host?

Link to comment

For anyone interested I did a quick-and-dirty tweak to match the display formatting to 6.12's default:

916447433_Screenshot2023-03-19at9_43_55AM.png.a0efc1c5c23e8ba64309f3e2eed93a54.png

 

Requires changing two files, presented below in diff format.

 

nut_status.php:

Spoiler
44,45c48,49
<       $runtime   = gmdate("H:i:s", $val);
<       $status[2] = strtok($val/60,' ')<=5 && !in_array('ups.status: OL', $rows) ? "<td $red>$runtime</td>" : "<td $green>$runtime</td>";
---
>       $runtime   = strtok($val/60,' ');
>       $status[2] = strtok($val/60,' ')<=5 && !in_array('ups.status: OL', $rows) ? "<td $red>".intval($runtime)."m</td>" : "<td $green>".intval($runtime)."m</td>";
49a54,56
>     case 'input.voltage':
>       $voltage   = intval(strtok($val,' '));
>       break;
53a61,63
>     case 'ups.model':
>       $model     = $val;
>       break;
64c74
<   $status[3] = $power==0 ? "<td $red>{$power}w</td>" : "<td $green>{$power}w</td>";
---
>   $status[3] = $voltage<114 ? "<td $orange>${voltage}V</td>" : "<td $green>${voltage}V</td>";
66a77
>   $status[6] = "${model} ${power}W";

 

 

nutFooter.page:

Spoiler
32c32
< <tbody id="tblUPSNUTDash" title="_(UPS(NUT))_">
---
> <tbody id="tblUPSNUTDash" title="_(POWER)_">
34c34
< <div class='section'>_(UPS(NUT))_<br><span><i class='ups fa fa-line-chart'></i><span id='load'>Load: <span class='nut_loadpct' id='nut_loadpct'></span></span>
---
> <div class='section'>_(POWER)_<br><span><i class='ups fa fa-line-chart'></i><span id='model'>UPS Model: <span class='nut_model' id='nut_model'></span></span>
158,162c158,163
<         "<tr class='updated'><td><span class='w36 ups'>UPS status:</span><span class='nut_status'>"+data[0]+"</span></td></tr>" +
<         "<tr class='updated'><td><span class='w36 ups'>Battery charge:</span><span class='nut_bcharge'>"+data[1]+"</span></td></tr>" +
<         "<tr class='updated'><td><span class='w36 ups'>Runtime left:</span><span class='nut_timeleft'>"+data[2]+"</span></td></tr>" +
<         "<tr class='updated'><td><span class='w36 ups'>Nominal power:</span>"+data[3]+"</td></tr>");
<     $("#tblUPSNUTDash").find('.nut_loadpct').html(data[5]+' - '+data[4]);    
---
>         "<tr class='updated'><td><span class='w36 ups'>UPS Status:</span><span class='nut_status'>"+data[0]+"</span></td></tr>" +
>         "<tr class='updated'><td><span class='w36 ups'>UPS Load:</span><span class='nut_loadpct'>"+data[4]+" ("+data[5]+")</span></td></tr>" +
>         "<tr class='updated'><td><span class='w36 ups'>Battery Charge:</span><span class='nut_bcharge'>"+data[1]+"</span></td></tr>" +
> "<tr class='updated'><td><span class='w36 ups'>Runtime Left:</span><span class='nut_timeleft'>"+data[2]+"</span></td></tr>" +
>         "<tr class='updated'><td><span class='w36 ups'>Input Voltage:</span><span class='nut_voltage'>"+data[3]+"</span></td></tr>");
>       $("#tblUPSNUTDash").find('.nut_model').html(data[6]);
184c185
<       $("#db-box1").find('.nut_nompower').html(data[3]);
---
>       $("#db-box1").find('.nut_voltage').html(data[3]);

 

 

  • Thanks 1
Link to comment
1 hour ago, CS01-HS said:

For anyone interested I did a quick-and-dirty tweak to match the display formatting to 6.12's default:

916447433_Screenshot2023-03-19at9_43_55AM.png.a0efc1c5c23e8ba64309f3e2eed93a54.png

 

Requires changing two files, presented below in diff format.

 

nut_status.php:

  Reveal hidden contents
44,45c48,49
<       $runtime   = gmdate("H:i:s", $val);
<       $status[2] = strtok($val/60,' ')<=5 && !in_array('ups.status: OL', $rows) ? "<td $red>$runtime</td>" : "<td $green>$runtime</td>";
---
>       $runtime   = strtok($val/60,' ');
>       $status[2] = strtok($val/60,' ')<=5 && !in_array('ups.status: OL', $rows) ? "<td $red>".intval($runtime)."m</td>" : "<td $green>".intval($runtime)."m</td>";
49a54,56
>     case 'input.voltage':
>       $voltage   = intval(strtok($val,' '));
>       break;
53a61,63
>     case 'ups.model':
>       $model     = $val;
>       break;
64c74
<   $status[3] = $power==0 ? "<td $red>{$power}w</td>" : "<td $green>{$power}w</td>";
---
>   $status[3] = $voltage<114 ? "<td $orange>${voltage}V</td>" : "<td $green>${voltage}V</td>";
66a77
>   $status[6] = "${model} ${power}W";

 

 

nutFooter.page:

  Reveal hidden contents
32c32
< <tbody id="tblUPSNUTDash" title="_(UPS(NUT))_">
---
> <tbody id="tblUPSNUTDash" title="_(POWER)_">
34c34
< <div class='section'>_(UPS(NUT))_<br><span><i class='ups fa fa-line-chart'></i><span id='load'>Load: <span class='nut_loadpct' id='nut_loadpct'></span></span>
---
> <div class='section'>_(POWER)_<br><span><i class='ups fa fa-line-chart'></i><span id='model'>UPS Model: <span class='nut_model' id='nut_model'></span></span>
158,162c158,163
<         "<tr class='updated'><td><span class='w36 ups'>UPS status:</span><span class='nut_status'>"+data[0]+"</span></td></tr>" +
<         "<tr class='updated'><td><span class='w36 ups'>Battery charge:</span><span class='nut_bcharge'>"+data[1]+"</span></td></tr>" +
<         "<tr class='updated'><td><span class='w36 ups'>Runtime left:</span><span class='nut_timeleft'>"+data[2]+"</span></td></tr>" +
<         "<tr class='updated'><td><span class='w36 ups'>Nominal power:</span>"+data[3]+"</td></tr>");
<     $("#tblUPSNUTDash").find('.nut_loadpct').html(data[5]+' - '+data[4]);    
---
>         "<tr class='updated'><td><span class='w36 ups'>UPS Status:</span><span class='nut_status'>"+data[0]+"</span></td></tr>" +
>         "<tr class='updated'><td><span class='w36 ups'>UPS Load:</span><span class='nut_loadpct'>"+data[4]+" ("+data[5]+")</span></td></tr>" +
>         "<tr class='updated'><td><span class='w36 ups'>Battery Charge:</span><span class='nut_bcharge'>"+data[1]+"</span></td></tr>" +
> "<tr class='updated'><td><span class='w36 ups'>Runtime Left:</span><span class='nut_timeleft'>"+data[2]+"</span></td></tr>" +
>         "<tr class='updated'><td><span class='w36 ups'>Input Voltage:</span><span class='nut_voltage'>"+data[3]+"</span></td></tr>");
>       $("#tblUPSNUTDash").find('.nut_model').html(data[6]);
184c185
<       $("#db-box1").find('.nut_nompower').html(data[3]);
---
>       $("#db-box1").find('.nut_voltage').html(data[3]);

 

 

You just need to update to my version of NUT in CA for 6.12

  • Like 1
Link to comment
19 minutes ago, CS01-HS said:

 

Right these tweaks are to your plugin (thanks by the way, works beautifully.)

Did I post in the wrong thread?

Ah so your changes are to make it match the APC stock dashboard. May look to have as an option so people can choose.

 

Thanks for the Diffs I will review.

 

I thought the changes you posted where to fix old plugin version on Dashboard, hadn't looked at the code.

  • Like 1
Link to comment
5 hours ago, CS01-HS said:

 

Right these tweaks are to your plugin (thanks by the way, works beautifully.)

Did I post in the wrong thread?

Looking at your changes, With nut I think some of the devices will not report model mine doesnt as it will be dependant on the Vendor

 

image.thumb.png.f1838d556dc9e33a9ee30eda3c862a93.png

  • Upvote 1
Link to comment

Ah. I only have the one UPS so I can't test what's particular vs generic.

 

Something else that might affect it:

I have unRAID set up as client to a NUT server on an RPi.

 

While I have you (in case it's helpful) here are additional state codes I gathered:

>   'OL CHRG'        => 'Online: charging',
>   'OL CHRG LB'     => 'Online: charging',
>   'OL DISCHRG'     => 'Online: discharging',
>   'OL DISCHRG LB'  => 'Online: discharging',
>   'OL BOOST'       => 'Online: low voltage',
>   'OB DISCHRG'     => 'Offline: On battery',

 

Edited by CS01-HS
Link to comment
On 3/21/2023 at 1:25 PM, SimonF said:

My version on CA is ok for 6.12 same for IPMI

 

Out of curiosity, does your patched versions work on older 6.10.3 systems? I am wondering if I can switch over before hand, so when I do opt to move to 6.12 it eill be a couple less steps to do at that time.

 

Thanks for the updates.

Link to comment
4 minutes ago, BRiT said:

 

Out of curiosity, does your patched versions work on older 6.10.3 systems? I am wondering if I can switch over before hand, so when I do opt to move to 6.12 it eill be a couple less steps to do at that time.

 

Thanks for the updates.

Yes my main box is on 6.10.3 running my vers

  • Thanks 1
Link to comment

@SimonF I really appreciate that you are taking over maintenance of the NUT plugin.  Would you be willing to update your plugin to use NUT 2.8?  I am using dmacias's plugin with an APC SMT1000RM2U with a AP9630 network management card.  It uses the snmp-ups driver but the net-snmp package included dmacias's plugin does not work on Unraid 6.11.5.  I use some commands in my go script that alter dmacias's plugin scripts to use NUT 2.8 and net-snmp 5.9.3 as explained in this post:

 

 

Link to comment
  • Rysz featured this topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.