Nico and Co.
 

Syndication

Syndicate content

Filtrage ? - La Quadrature du Net

 


 
Check the status of an md device
Nicolas  01/06/2005 - 10:03   

The following script allows to check the satus of an md device, and therefore to know if a disc from a raid is faulty. It is done by storing the result of cat /proc/mdstat the first time the script is called, then by comparing it to the current output on following calls.

#!/bin/sh
#
# RAID monitor
#
BASE_FILE=/etc/mdstat.ok
DIFF_FILE=/tmp/mddiff$$.out
#
# make the comparison template
#
if [ ! -s ${BASE_FILE} ]
then
   if [ "0" != "`id -u`" ]
   then
      echo "Must be 'root' to run this script for the first time!"
       exit 0
   fi
   cat /proc/mdstat >${BASE_FILE}
fi
#
# compare current mdstat with saved good version
#
diff -C1 ${BASE_FILE} /proc/mdstat >${DIFF_FILE}
if [ -s ${DIFF_FILE} ]
then
   rm -f ${DIFF_FILE}
   echo "Raid problem ??"
   exit 1
fi
rm -f ${DIFF_FILE}
echo "Raid OK"
exit 0

Technorati Tags:

Répondre

Le contenu de ce champ ne sera pas affiché aux utilisateurs qui n'ont pas de droits d'administration sur ce site.
Captcha Image: you will need to recognize the text in it.
Veuillez saisir les lettres/chiffres apparaissant dans l'image ci dessus.
 

Connexion


Commentaires récents



Promouvoir et soutenir le logiciel libre


Eliminate DRM!
DRM ?


GeoURL

View blog reactions

Nethique.info