SOLVED Monitoring UPS via Zabbix?

ragametal

Contributor
Joined
May 4, 2021
Messages
188
I’m not sure if this is a TrueNAS question or if I should ask this in the FreeBSD and Zabbix forums but here it goes.

I want to monitor TrueNAS via Zabbix but I’m having issues monitoring its UPS.

I have installed the Zabbix server and agent in a jail and I added a host to monitor Truenas via a SNMP agent (there is no zabbix agent in TrueNAS). All this is working properly.

TrueNAS has an UPS connected via USB that is currently configured and monitored by TrueNAS (which uses nut internally).

If I SHH into the jail and run the command
Code:
$UPS_NAME@$TrueNASIP|grep 'battery.charge:' | cut -d ' ' -f 2

The response I get is the numeric value of the current battery charge of the UPS.

Based on this I want to add items to my Zabbix server host to issue commands that will read the ups parameters on truenas.
But if I try to create an item in my zabbix server that issues the same command, as follows
image1.jpg



The result i get is “Permission Denied” and “sh: upsc: not found”
Image2.jpg


I have already enabled remote command in Zabbix agent by adding the line
Code:
AllowKey=system.run[*]

to the file “/usr/local/etc/zabbix6/zabbix_agentd.conf”.

It seems as if root has access to the “upsc” command but the user “zabbix” (running the zabbix server and agent) does not.

Can anybody help me with this?

I have successfully done this approach with my PFSense machine so I know it is possible. But I believe PFSense installs the Zabbix agent on baremetal and not in its own jail like I’m doing in TrueNAS.

Help?
 

ragametal

Contributor
Joined
May 4, 2021
Messages
188
I figured it out.
Zabbix was complaining that it couldn't find the command "upsc". so i indicated the full path of it.

Therefore, the solution for the "UPS Battery Charge" is to change the "key" from
system.run[upsc {$UPS_NAME}@10.0.0.20|grep 'battery.charge:' | cut -d ' ' -f 2]
to
system.run[/usr/local/bin/upsc {$UPS_NAME}@10.0.0.20|grep 'battery.charge:' | cut -d ' ' -f 2]

now, when i run that key i get the following
ZAbbix1.jpg


this is correct because the battery is 100% charged.

I hope my waste of time can help somebody else down the line.
 
Top