Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Send readynas cpu temperature, fan speed, disk temperature to influxdb
# initialize
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
for disk in ${DISKDIR}/*ternal/*
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}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment