Skip to content

Instantly share code, notes, and snippets.

@cotdp
Created November 22, 2011 22:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cotdp/1387192 to your computer and use it in GitHub Desktop.
Save cotdp/1387192 to your computer and use it in GitHub Desktop.
this script read the core(s) temperature using lm sensors then calculate the average and send it to the ganglia using gmetric
#!/bin/sh
# this script read the core(s) temperature using lm sensors then calculate the average
# and send it to the ganglia using gmetric
# Based on the original from: http://computational.engineering.or.id/LM_Sensors#Integrasi_Dengan_Ganglia
# assumes that the lines reported by lm sensors are formated like this
# Core 0: +48.0°C (high = +90.0°C, crit = +100.0°C)
SENSORS=/usr/bin/sensors
GMETRIC=/usr/bin/gmetric
let count=0
sum=0.0
for temp in $($SENSORS | grep "^Core" | grep -e '+.*C' | cut -f 2 -d '+' | cut -f 1 -d ' ' | sed 's/°C//'); do
sum=$(echo $sum+$temp | bc)
# echo $temp, $sum
let count+=1
done
temp=$(echo "$sum/$count" | bc)
$GMETRIC -t float -n "cpu_temp" -u "Celcius" -v $temp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment