Git Product home page Git Product logo

Comments (4)

frhack avatar frhack commented on September 28, 2024

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

from zabbix-nut-template.

pokdo avatar pokdo commented on September 28, 2024

Bump of this same question. Can you give details on the script edit for using netclient mode? Thanks

from zabbix-nut-template.

thenebular avatar thenebular commented on September 28, 2024

Another bump of this question.

How do we add the hostname to ups_status.sh in that it pulls the hostname as a variable.

from zabbix-nut-template.

dmth avatar dmth commented on September 28, 2024

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
`` 

from zabbix-nut-template.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.