Citrix XenServer 5.5, 5.6 and 6.0 are based on CentOS 5.4, but the smartmontools package is not available in the default Citrix repository, so it can't be installed with yum install smartmontools (as it would be possible with any other CentOS distribution).
It is probably safest to use the same versions that were in the original CentOS 5.4 distribution. Since that release is no longer the latest, we have to go to an archive server to find the packages. The packages listed below are actually used in other CentOS releases too, so these are probably the latest versions anyway.
wget http://vault.centos.org/5.4/os/i386/CentOS/mailx-8.1.1-44.2.2.i386.rpm wget http://vault.centos.org/5.4/os/i386/CentOS/smartmontools-5.38-2.el5.i386.rpm rpm -hiv smartmontools-5.38-2.el5.i386.rpm mailx-8.1.1-44.2.2.i386.rpm
Checking the disk status
We can now retrieve the disk status using:
smartctl -d ata -a /dev/sda
The most important fields are: SMART overall-health self-assessment test result - that should always have a value of PASSED. Other important fields are:
- Reallocated_Sector_Ct, which counts the number of bad blocks that have been reallocated. It should be a low number. If this value increases, it is an alarm signal. Make a backup and replace the disk drive.
- Current_Pending_Sector, which is the number of blocks with read errors that are not yet reallocated.
Also check out the columns VALUE WORST THRESH. For each attribute, the current value of the field should never be lower than the threshold defined by the manufacturer.
Automatic monitoring of disk drives
The smartd daemon handles automatic testing for all drives, logs any status changes in /var/log/syslog or /var/log/messages and sends a status email in case of a problem (if mail is enabled, see below). It is configured in the file /etc/smartd.conf.
The following lines will run a short test every day between 02:00 and 03:00, and a long test on every Saturday between 03:00 and 04:00. If there is a problem, send an email to the configured address. The -M test option will send a test email whenever the smartd daemon is started.
The DEVICESCAN line would normally cause default test runs for all disks that smartd finds, but does not work on my system for some reason. So it is commented out and the tests will only run for explicitly listed devices.
/dev/sda -d ata -a -s (S/../.././02|L/../../6/03) -t -m email@example.com /dev/sdb -d ata -a -s (S/../.././02|L/../../6/03) -t -m firstname.lastname@example.org #DEVICESCAN -H -m root
After any change to the /etc/smartd.conf file the smartd daemon should be restarted:
Enabling email on Citrix XenServer
Citrix XenServer is not configured to run a mail server. Therefore without further configuration smartd might attempt to send out warning emails in case anything fails, but no mails will actually receive their destination.
It is fortunately not necessary to install a full-blown email package. XenServer comes with ssmtp preinstalled, which simply forwards emails to a real mail server.
To enable mail sending on Citrix XenServer, set up /etc/ssmtp/ssmtp.conf. You need to provide a real mail server and the local domain name.
# /etc/ssmtp.conf -- a config file for sSMTP sendmail.
After setting up /etc/ssmtp/ssmtp.conf, send a test email from the console to make sure that the email gets through:
echo "this is a test mail" | mailx -s "Test mail" email@example.com
If you are using the -M test option to a /etc/smartd.conf device definition, you can also restart the smartd daemon to have it send out test emails.