Nach ein wenig suchen habe ichs dann auch raus gefunden, der User dogma-sam von www.serversupportforum.de hat auch ein kleines PHP Script geschrieben um den Status zu prüfen und bei einem Fehler eine Mail rauszuschicken, das Script nutzen wir dann auch gleich weiter unten.
Server: Serverloft PerfectServer L ( Fujitsu Siemens Primergy Econel 230R S1)
Raid: Controller: LSI 1068
Fangen wir an:
Wir Installieren mpt-status
apt-get update apt-get install mpt-status
Nun aktivieren wir das Kernel Modul
modprobe mptctl oder mpt-status --autoload
So nun sollte wir mit mpt-status ein ergebniss bekommen was etwa so auschaut:
# mpt-status ioc0 vol_id 0 type IM, 2 phy, 465 GB, state OPTIMAL, flags ENABLED ioc0 phy 1 scsi_id 8 ATA ST3500620AS SD25, 465 GB, state ONLINE, flags NONE ioc0 phy 0 scsi_id 1 ATA ST3500620AS SD25, 465 GB, state ONLINE, flags NONE
Gut, nun noch das php Script einrichten :
Erstmal prüfen wir ob wir php-cli auch installiert haben damit wir auch wirklich ne Status Mail bekommen:
# php5 -v //wenn wir keine php Version angezeigt bekommen dann müssen wir noch eben PHP5-CLI Installieren # apt-get install php5-cli
So hier das Script von dogma-sam, im scipt eben die email adresse und evtl. die config anpassen.
<?</span> /** * raidhealth.php - RAID Health monitoring script for LSI raid controllers that can be * controlled via mpt-status. * Checks the health of the raid set and sends an e-mail to the given address if something * is wrong. If called in a configurable hour of the day, it will also send an e-mail if * everything is okay so that you know the monitor is running. * * Prerequisites: * - Installed mpt-status module. Beware: some controllers need a version >= 1.2.0, if your * distribution contains an older version by default, look for a backport. * - mptctl kernel module. Can be loaded with mpt-status --autoload. * - /dev/mptctl in place and ready. * - a RAID set to be monitored in the right place */ // Configuration ////////////////////////////////////////////////////////// $cfg_scsi_id = 0; // The scsi id of the raid set, usually 0. Get it via 'mpt-status -p' $cfg_pinghour = 8; // The hour in which the okay-email is sent (0-23, set to -1 to disable) $cfg_email = "server@example.com"; // The e-mail address to send the e-mails to $cfg_emailfrom = "raid@example.com"; // The sender e-mail address // Script ///////////////////////////////////////////////////////////////// // Get the human readable status description and return code $cmd = "mpt-status -i ".escapeshellarg($cfg_scsi_id); exec($cmd, $humanoutput, $ret); $humanmsg = implode("\n", $humanoutput); // Get the hostname $hostname = exec("hostname"); // Check the return value - if everything is okay, exit if ($ret == 0) { if ($cfg_pinghour >= 0 && date("G") == $cfg_pinghour) sendMail("RAID Health Status OK for $hostname", "Der Status des RAID Sets auf $hostname ist OK. Weiter so!\r\n\r\n$humanmsg"); exit; } // If we are here, something is not okay. Simply send an e-mail with the human message. sendMail("RAID Health Warning for $hostname", "Der Status des RAID Sets auf $hostname ist nicht OK, bitte untersuchen.\r\n\r\n$humanmsg"); // The E-Mail function //////////////////////////////////////////////////// function sendMail ($subject, $body) { global $cfg_email, $cfg_emailfrom; mail($cfg_email, $subject, $body, "From: $cfg_emailfrom"); } ?>
Script erstellen und einfügen (evtl. noch anpassen):
# nano /etc/cron.hourly/raidhealth.php
Rechte setzen:
# chmod 755 /etc/cron.hourly/raidhealth.php
Nun können wir die Platten am Raid mit guten gewissen laufen lassen, wir bekommen ja ne E-Mail wenn was nicht stimmt (-;