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:
 

Trucs et astuces

L'enregistrement sur le site est gratuit, et apporte de nombreuses fonctionalités supplémentaires. inscrivez vous...

Connexion


Commentaires récents



Promouvoir et soutenir le logiciel libre


Eliminate DRM!
DRM ?


GeoURL

View blog reactions

Nethique.info