How to monitor & log server hardware temperatures & load

Solution 1:

If you want something that does not depend on a desktop:

Have a look at lm-sensors Install lm-sensors. From the description:

Lm-sensors is a hardware health monitoring package for Linux. It allows 
you to access information from temperature, voltage, and fan speed 
sensors. It works with most newer systems.

This package contains programs to help you set up and read data from
lm-sensors.

From their project page (2016 edit: project is dead. Our own wiki has some info):

  • Unattended high-end server, router or other mission-critical machine automated monitoring. Easily create a cron job to query the status of your hardware and email you in the event of a problem before it becomes critical. That way, you can be alerted within seconds of a failing critical component such as a power supply, fan, other cooling mechanism, or even detect if the case has been opened.
  • Embedded systems running Linux. These can use this package to monitor voltages, temperatures, fan speeds, etc. using off-the-shelf components and utilizing a range of bus interfaces (e.g. ISA, SMBus, I2C or SPI).
  • More generally, data acquisition. Easily measure various types of data (rotational speeds, voltages, temperatures, etc.) using cheap off-the-shelf parts. Very useful for systems automation (in the home, workshop, weather station, you name it).

lm-sensors has a daemon, called sensord, that uses RRDtool for 'data logging and graphing system for time series data'. So it includes graphics like this that can be shown through a webserver:

im1

(taken from lm-sensors project page).

To install the sensord daemon you will likely have to install the sensord package.

Example from my notebook:

im2

The config file for this is located at /etc/sensors3.conf

lm-sensors is sort of the basic of any temperature measuring. Desktop items are more than likely to get their information from this package. An example If you want something that depends on a desktop

psensor.

  • motherboard and CPU sensors (requires lm-sensors to be installed).
  • NVidia GPUs
  • Hard Disk Drives (requires hddtemp to be installed).
  • Fan speed (again, requires lm-sensors to be installed).

Installation by adding a PPA:
sudo add-apt-repository ppa:jfi/ppa
sudo apt-get update && sudo apt-get install psensor

(Oneiric will have psensor included)

(old) example from ubuntugeek.com: im6

Solution 2:

If programs like Cacti are too much then you could use a script which just logs to text file by day - run it with crontab. You need to have lm-sensors installed.

#!/bin/bash
_now=$(date +"%Y_%m_%d")
_file="temp_log_$_now.txt"
(date; sensors; echo '-----------') | cat >> "/var/log/temperatures/$_file"

This only works if there is a directory /var/log/temperatures which may need to be created first (sudo mkdir /var/log/temperatures) and which only root can write to (so you would need to use the root crontab. If you want to use the per user crontab you could instead create /home/user/temperatures (mkdir ~/temperatures) and use that path in the script (use the full path in the script).

Solution 3:

For logging of cpu/ram/temperatures/traffic on a server, I recommended Cacti. It is advertised as a 'complete frontend for RRDtool', and can have multipled data sources such as lm-sensors, SNMP or even custom scripts. Data is stored in RRD, and used to create daily, weekly, monthly and yearly graphs.

See the Cacti website for more details, screenshots and links to live example sites. It can be tricky to set up the very first time, but is worth it in the end.