C++Guns – RoboBlog


ganglia lm-sensors

Filed under: Allgemein — Tags: — Thomas @ 14:09

thomas@H8QGL:~$ cat gmetric-cpu-temp 
# this script read the core(s) temperature using lm sensors then calculate the average
# and send it to the ganglia using gmetric
# assumes that the lines reported by lm sensors are formated like this
# Core 0: +46.0 C (high = +80.0 C, crit = +100.0 C)


let count=0
for temp in $($SENSORS | grep temp  |  grep -e '+.*C' | cut -f 2 -d '+'  | sed 's/°/ /g' | cut -f 1 -d ' '); do
    if (($(echo "$temp > 1.0" | bc) ))
      sum=$(echo $sum+$temp | bc);
#    echo $temp, $sum, $count
      let count+=1;
temp=$(echo "scale=1; $sum/$count" | bc)
#echo $temp
$GMETRIC -t float -n "avg temp" -u "Celcius" -v $temp

Fehlerhaftes Original here: http://computational.engineering.or.id/LM_Sensors#Integrasi_Dengan_Ganglia
In meiner Version wird das Grad-Celsius Zeichen rausgefiltert.
Es werden nur echte Temperaturen verrechnet, keine min und max Werte.
Falsche Temperaturen wie z.b. 0.8C werden ignoriert nud erst ab 1Grad verrechnet.

thomas@H8QGL:~$ cat /etc/cron.d/sensors 
* * * * * root /usr/local/bin/gmetric-cpu-temp 

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress