So I got into this kick with gathering data and graphing it, I have been playing with flot for a bit and wanted to see what else I could graph.
I run hddtemp on my fileserver and while living in Vegas it gets pretty hot out, and my AC kicks on and off all day. I decided there has got to be a way for me to database the temp change on my hard drives through the
day and make it look nice. I put together this simple bash script that writes to the local MySQL server, then once I finish the web interface I will be making use of flot to graph the data. I thought I would share the simple script in case anyone else is interested in this as well.
#!/bin/sh HOST=localhost USER=username PASS=password DB=database NOW=$(date +"%Y-%m-%d %k:%M:%S") TEMP=`sudo hddtemp -uF /dev/sdb|cut -c 31-33` mysql -u$USER -h$HOST --password=$PASS $DB -e "INSERT INTO data (id, temp, date) VALUES ('NULL', '$TEMP', '$NOW')"
As you can see the script is very simple. For your usage, you might need to change the date format to suite your needs but for my instance, it works great. The temp is cut so it will only display the 3 digit temp, in Fahrenheit.