Zabbix-NUT-Template
Zabbix-NUT-Template copied to clipboard
Template only works with locally attached UPS
Today I figured out the template only works with locally attached UPSes.
If NUT is used in netclient mode, the script ups_status.sh
has to be extended with the hostname of the nut-server at three locations.
Today I figured out the template only works with locally attached UPSes.
If NUT is used in netclient mode, the script
ups_status.sh
has to be extended with the hostname of the nut-server at three locations.
I have the same issue, can you please show me how to change the script in order to use It in netclient mode ?
Thanks
Bump of this same question. Can you give details on the script edit for using netclient mode? Thanks
Another bump of this question.
How do we add the hostname to ups_status.sh in that it pulls the hostname as a variable.
ooooh, sorry guys I didn't check on my GH notifications for a long time. I didn't intend to keep you hanging. Apparently I figured it out but i never supplied a solution. Here's my patch for the problem. You need to replace YOURHOSTSIP
with the IP of your host. If you are not familiar with the patch format: Replace the lines beginning with -
by the lines beginning with +
in your ups_status.sh
and add the line below ups=$1
diff --git a/sh/ups_status.sh b/sh/ups_status.sh
index f450927..396a78e 100755
--- a/sh/ups_status.sh
+++ b/sh/ups_status.sh
@@ -1,12 +1,13 @@
#!/bin/bash
ups=$1
+host=YOURHOSTSIP # this should somehow be set by a Zabbix-Macro.
if [ $ups = ups.discovery ]; then
echo -e "{\n\t\"data\":["
first=1
- /bin/upsc -l 2>&1 | grep -v SSL | while read discovered ; do
+ /bin/upsc -l $host 2>&1 | grep -v SSL | while read discovered ; do
if [ $first -eq 0 ]; then
echo -e ","
fi
@@ -19,7 +20,7 @@ else
key=$2
if [[ $key = ups.status ]]; then
- state=`/bin/upsc $ups $key 2>&1 | grep -v SSL`
+ state=`/bin/upsc $ups@$host $key 2>&1 | grep -v SSL`
case "$state" in
"OL") echo 1 ;; #'On line (mains is present)' ;;
"OB") echo 2 ;; #'On battery' ;;
@@ -38,7 +39,7 @@ if [[ $key = ups.status ]]; then
* ) echo 0 ;; #'unknown state' ;;
esac
else
- /bin/upsc $ups $key 2>&1 | grep -v SSL
+ /bin/upsc $ups@$host $key 2>&1 | grep -v SSL
fi
fi
``