Bash Script doesnt work for Cacti

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
Brenner
Posts: 29
Joined: Thu Apr 19, 2007 9:58 am

Bash Script doesnt work for Cacti

Post by Brenner »

Hi there...
little big problem. My calculated $z doesnt work for Cacti (no values to seen). If I define $z directly (i.e. z=8) everything is fine.
Script is in 777 and in the Cacti script folder



Here the whole script
#!/bin/bash

#Datei einlesen
d=$(head -2 ../share/cacti/site/scripts/ESA1000WZ-log.txt)
#echo $d

#Reinen METER-Wert rauscutten
c=$(echo CGET CUX2711110:1 | nc localhost 6770 -q 1 | awk -F " " '{print $2}' | awk -F ":" '{print $2}')
echo $c >../share/cacti/site/scripts/ESA1000WZ-log.txt

z=$(echo "$c $d" | awk '{ print(($1 - $2) * 1000) }')

x=1

#Gesamtausgabe:
echo "METER:"$c" DIFF:"$z" TEST:"$x" "
bash print out:
root@cacti01:/usr/bin/X11# ../share/cacti/site/scripts/ESA1000WZforCacti.sh
METER:43010.59 DIFF:140 TEST:1
root@cacti01:/usr/bin/X11# ../share/cacti/site/scripts/ESA1000WZforCacti.sh
METER:43010.95 DIFF:360 TEST:1
root@cacti01:/usr/bin/X11# ../share/cacti/site/scripts/ESA1000WZforCacti.sh
METER:43010.95 DIFF:0 TEST:1
root@cacti01:/usr/bin/X11#

Cacti (see picture) :(
Attachments
Unbenannt.JPG
Unbenannt.JPG (67.82 KiB) Viewed 1205 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Bash Script doesnt work for Cacti

Post by gandalf »

Please use /full/path/to/awk etc. Don't rely on $PATH
R.
Brenner
Posts: 29
Joined: Thu Apr 19, 2007 9:58 am

Re: Bash Script doesnt work for Cacti

Post by Brenner »

Will try. Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests