Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Send readynas cpu temperature, fan speed, disk temperature to influxdb
# initialize
INFLUXDBADRR="http://hostname.local:8086/write?db=server"
hostname=`hostname | tr '[:upper:]' '[:lower:]'`
cpu_name="Marvell\ Armada\ 370/XP"
fan_name="main\ fan"
# get cpu temperature and fan RPM
cpu_temp=`sensors | grep CPU | sed -r "s/CPU.*?\+([0-9\.]*?)°C/\1/" | sed -e "s/[ \t]*$//"`
fan_rpm=`sensors | grep System | sed -r "s/System.*?\s([0-9]+)\ RPM.*?$/\1/"`
# send cpu temperature and fan RPM
query="cpu_temperature,hostname=${hostname},devece_name=${cpu_name} value=${cpu_temp}
fan_rpm,hostname=${hostname},devece_name=${fan_name} value=${fan_rpm}"
echo ${query}
curl -i -XPOST ${INFLUXDBADRR} --data-binary "${query}"
# get disks temperature
DISKDIR="/dev/disk"
for disk in ${DISKDIR}/*ternal/*
do
diskname=`echo ${disk} | sed -r "s/\/dev\/disk\/.*?\/(.*?)$/\1/"`
disktype=`echo ${disk} | sed -r "s/\/dev\/disk\/(.*?)\/.*?$/\1/"`
disktemp=`/usr/sbin/smartctl -a ${disk} | grep Temp | sed -r "s/^.*\s([0-9]+)$/\1/"`
# send disks temperature
query="disk_temperature,hostname=${hostname},disk_type=${disktype},disk_name=${diskname} value=${disktemp}"
echo $query
curl -i -XPOST ${INFLUXDBADRR} --data-binary "${query}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment