In an effort to keep an eye on my new server build, I installed lm-sensors and hddtemp to let me monitor the temperatures.
sudo apt-get install lm-sensors hddtemp
After that, make hddtemp excutable without root privilages using
sudo chmod u+s /usr/sbin/hddtemp
And attempt to find your computers sensors with
Personally, I just select yes for everything, but do so at your own risk.
After that I set up a script which greps and cuts its way to being readable
#! /bin/bash echo echo -n "CPU >> " sensors | grep Temp1 | cut -c 15-21 echo -n "Fan >> " sensors | grep Fan2 | cut -c 13-20 echo -n "M/B >> " sensors | grep Temp2 | cut -c 15-21 echo -n "HD >> " hddtemp /dev/sdb | cut -c 24-28 echo -n "Device Total Used Free Mount" echo df -h | grep /home
This also displays the space used on my /home drive, and the output looks like this;
CPU >> 36.0°C Fan >> 3060 RPM M/B >> 37.0°C HD >> 33°C Device Total Used Free Mount /dev/sdb1 459G 53G 407G 12% /home
EDIT: It was rather inconvenient to SSH into the server everytime I wanted to check the sensors, so using the root cron, and a simple script, I rigged it to run the sensors script every five minutes, and to copy that to the web directory on my server. That lets me just check the script report through my web browser, much more convenient.
This is the script executed by the root crontab every five minutes;
#! /bin/bash bash /home/dave/.sensors.sh > /home/dave/.sensors.txt sleep 100 cp /home/dave/.sensors.txt /var/www/sensors.txt
And here’s the entry called by the root crontab. The root privileges are needed to get the size of the Apt and Squid caches;
#Run sensors script */5 * * * * root /home/dave/.cron_sensors.sh
In the meantime, I also modified the script a bit, for more features, and to look better on a web browser. You may or may not prefer it :)
#! /bin/bash echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo echo ">> Run .trash.sh as root to manually clear trash <<" echo ">> Run .squint.sh as root to generate an instantaneous report <<" echo echo -n "CPU >> " sensors | grep Temp1 | cut -c 15-18,20-21 echo -n "FAN >> " sensors | grep Fan2 | cut -c 13-20 echo -n "M/B >> " sensors | grep Temp2 | cut -c 15-18,20-21 echo -n "HD >> " /usr/sbin/hddtemp /dev/sdb | cut -c 24-25,27-28 echo echo -n "Apt-Cache >> " du -hs /home/dave/.apt-cacher-ng/ | cut -c 1-5 echo -n "Squid Cache >> " du -hs /home/squid/ | cut -c 1-5 echo echo -n "Device Total Used Free Mount" echo df -h | grep /home echo free -m echo uptime echo date echo echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
After all that, it ends up looking like this in a web browser, and updates itself every five minutes.
Filed under: Server, Ubuntu | 2 Comments
Tags: Sensors, Server, Ubuntu