UPS NUT plugin Collectd data fields

jinu

Dabbler
Joined
Feb 11, 2021
Messages
15
Hi folks
I have configured the UPS configuration in TrueNAS in slave mode to use a UPS running on another server. Everything works fine except for the UPS tab in Reporting in TrueNAS. That is staying blank. I checked to see if rrd files are getting generated and found rrd files getting generated for a few parameters of the remote UPS. The following parameters are being recorded as rrd files:

percent.charge
percent.load
timeleft.battery
voltage.battery
voltage.input

I know the UPS returns a lot more parameters which also i would like to capture/record, but i cannot seem to find a configuration file where i can configure these values. Can anyone help me with the following
- identify the config file that is used to determine which data fields are stored in the rrd files for the NUT plugin. or how to capture the additional parameters
- understand why the UPS tab in Reporting is coming blank.

Thanks
 

Traveller42

Cadet
Joined
Feb 28, 2021
Messages
1
I am seeing this same behavior, totally blank Reporting > UPS page.

Looking at the data in /var/log/nut/ups.log, I only see Date, Rime, Battery Charge, Input Voltage, UPS state, and two more fields that are NA on my system (they will be UPS temperature and Input Frequency, but my UPS does not report those values).

Looking at the RRD files, I don't find any actual data in the files. They appear to be getting updated, but the values are all NaN (Not a Number).

Also, the RRD files are in a different directory from the rest of the files when you are monitoring a remote UPS. It is under the IP address of the server actually connected to the UPS in my case. Everything else seems to be under localhost.

The simplest explanation is that there is no useful data in the RRD, so the drawing process cannot produce a graph. This only pushes the problem back to why there is no data.
 

jinu

Dabbler
Joined
Feb 11, 2021
Messages
15
In my case there is data in the RRD files and i can see that if i push it to influxDB and view it thru grafana. But i wish there was way to configure it to read more parameters
 

RedVortex

Cadet
Joined
Apr 26, 2021
Messages
3
Also, the RRD files are in a different directory from the rest of the files when you are monitoring a remote UPS. It is under the IP address of the server actually connected to the UPS in my case. Everything else seems to be under localhost.

I also see the same. Instead of having the RRD files under the localhost like everything else, it is under the IP address of the UPS. Since my UPS is in SLAVE mode in the NUT configurations, the RRD files seems to be created under the IP address of the UPS instead of putting them in localhost.

I created a cronjob that basically copies every minute the files from the wrong folder to the right folder and I now have graphs under Reporting/UPS so this is most likely a bug.

Reporting only checks for what is under /var/db/collectd/rrd/localhost/nut-UPSNAME and since the RRD files for NUT are not there but under /var/db/collectd/rrd/IP.OF.UPS.OR.HOSTNAME/nut-UPSNAME it's not graphing anything.

So my cron job is simple, it copies all files that are under /var/db/collectd/rrd/IP.OF.UPS.OR.HOSTNAME/nut-UPSNAME to /var/db/collectd/rrd/localhost/nut-UPSNAME every minute.

That's not prefect (for some reason only the runtime and battery level show up) but I now have a little something under Reporting->UPS instead of nothing until they fix this bug I guess.

1619451903852.png
 
Joined
Jun 2, 2019
Messages
591
Rather than copying the data, I simply added a symbolic link in the /var/db/collectd/rrd/localhost folder

Code:
ln -sf  /var/db/collectd/rrd/{IP or Hostname}/nut-{UPS Name} nut-{UPS Name}


Screen Shot 2021-05-10 at 10.27.45.png
 
Last edited:

RedVortex

Cadet
Joined
Apr 26, 2021
Messages
3
I also tried that at first but it seems like the folder/symbolic link get deleted/overwritten when you restart the nut service so I was losing my data every time and that's why I went the cron/copy way unfortunately. :-/

In the end, this is a bug and I think TrueNAS should get this fixed. Plus, we're missing many metrics, that are present on disk, in the UI whether we use the copy cron or the symbolic link.
 
Joined
Jun 2, 2019
Messages
591
The symbolic link persists on NUT stop/restart or reboot on my NAS. You just loose historical data, but I think that is as intended.
 

RedVortex

Cadet
Joined
Apr 26, 2021
Messages
3
I retested using the symbolic like you did and it seems to stay now, unsure what triggered the folder / symbolic link to go away last time.

I think I may have created the symlink differently during my debugging. I think I may have pointed the /var/db/collectd/rrd/IP_OF_NUT_UPS/ folder to the /localhost/ folder globally so that the nut-UPSNAME folder would get created directly under the /localhost/ instead of /IP_OF_NOT_UPS/. Maybe NUT or the UPS script checks to make sure it is a valid folder and if not, drops/recreates it properly.

Thanks for your help, it's much better this way !
 

jinu

Dabbler
Joined
Feb 11, 2021
Messages
15
Rather than copying the data, I simply added a symbolic link in the /var/db/collectd/rrd/localhost folder

Code:
ln -sf  /var/db/collectd/rrd/{IP or Hostname}/nut-{UPS Name} nut-{UPS Name}

Thanks a lot. This resolved the issue.
 
Joined
Jun 2, 2019
Messages
591

furmek

Cadet
Joined
Aug 11, 2022
Messages
1
For me running TrueNAS-SCALE-22.02.3 creating a symbolic link doesn't work.
What works is creating a "stub" file in ups master host folder.
eg:
cd /var/db/collectd/rrd/192.168.0.2/
touch empty.rrd

Say I run my nut master on 192.168.0.2 with ups named apc
Truenas will create folder `/var/db/collectd/rrd/192.168.0.2/nut-apc`
if I create an empty file `/var/db/collectd/rrd/192.168.0.2/whatever.rrd` the graphs will show up.
I think the culprit is this bit: middleware - what happens here is `_base_path` looks recursively for folder containing .rrd files so it will return: `/var/db/collectd/rrd/192.168.0.2/nut-apc` but when we try to get graphs we still append `nut-[ups_name]` to the base path so we will endup with `/var/db/collectd/rrd/192.168.0.2/nut-apc/nut-apc`

I get the same effect if I link nut-apc in nut-apc
root@my_nas[...ectd/rrd/192.168.0.2/nut-apc]# ls -al
total 158
drwxr-xr-x 2 root root 12 Aug 12 11:52 .
drwxr-xr-x 3 root root 3 Aug 12 11:50 ..
-rw-r--r-- 1 root root 148648 Aug 12 11:51 current-output.rrd
-rw-r--r-- 1 root root 148648 Aug 12 11:51 frequency-input.rrd
-rw-r--r-- 1 root root 148648 Aug 12 11:51 frequency-output.rrd
lrwxrwxrwx 1 root root 49 Aug 12 11:52 nut-apc -> /var/db/collectd/rrd/192.168.0.2/nut-apc
-rw-r--r-- 1 root root 148648 Aug 12 11:48 percent-charge.rrd
...
 

ploplop

Cadet
Joined
Jan 25, 2022
Messages
3
@furmek thank you, that helped fix the same issue I had on Truenas Scale. However the empty.rrd or whatever file did not work, adding a symlink in the directory to itself solved it. In my case it gets deleted everytime the service restarts which I think makes sense. So i just added a post init command to recreate it every time.
 
Top