[rrd-users] Bash script behaves strangely while polling
Jens Haeuser
j.haeuser at gesotec.de
Fri Mar 7 19:28:12 CET 2008
Hi @all,
i wrote a simple bash script (ubuntu 7.10, cacti from repositories
0.8.6j-1.1ubuntu0.2) that reads out values from mbmon and sensors.
Depending on the given parameter to the script it only prints out the
desired value. E.g.:
sh pc_status.sh rpmfan1
prints out:
3214
the script works fine in the console, it also shows me the value when
calling cmd.php in the console correctly:
03/07/2008 10:25:39 PM - CMDPHP: Poller[0] Host[0] DS[26] CMD: sh
/usr/share/cacti/site/scripts/pc_status.sh rpmfan1, output: 3214
In the cacti log sometimes the values show up (most of the time at the
beginning of the poll), it also graphs 2 or three values and later on I
always get output U all the time:
03/07/2008 10:15:14 PM - CMDPHP: Poller[0] Host[0] DS[26] CMD: sh
/usr/share/cacti/site/scripts/pc_status.sh rpmfan1, output: U
and it stops graphing... :(
here is the script, what did I do wrong? Has someone a hint?
##########################################################################
#!/bin/sh
# Version 0.1 JH8035A: PC status values for cacti
##########################################################################
# fan1
# casefan1
casefan1="fan2"
# fan2
# casefan2
casefan2="fan3"
# cpu fan
cpufan="fan1"
# HDDs
hdd1="/dev/sda"
hdd2="/dev/sdb"
##########################################################################
# read out values
mb_temp=`sudo mbmon -T 7 -i -c1`
#read out temps and assign value to variable
cpu1_temp=`echo $mb_temp | awk '{print $2}'`
cpu2_temp=`echo $mb_temp | awk '{print $3}'`
hdd1_temp=`sudo hddtemp -n $hdd1`
hdd2_temp=`sudo hddtemp -n $hdd2`
# read out rpms
rpmfan1=`sudo sensors | grep $casefan1 | awk '{print $2}'`
rpmfan2=`sudo sensors | grep $casefan2 | awk '{print $2}'`
rpmcpufan=`sudo sensors | grep $cpufan | awk '{print $2}'`
# print out values depending on given parameter to the script
case "$1" in
rpmfan1)
printf $rpmfan1
;;
rpmfan2)
printf $rpmfan2
;;
rpmcpufan)
printf $rpmcpufan
;;
cpu1_temp)
printf $cpu1_temp
;;
cpu2_temp)
printf $cpu2_temp
;;
hdd1_temp)
printf $hdd1_temp
;;
hdd2_temp)
printf $hdd2_temp
;;
esac
More information about the rrd-users
mailing list