RAID monitoring

Discussion in 'Technical' started by TheRudy, Jul 19, 2006.

  1. TheRudy

    TheRudy ISPConfig Developer ISPConfig Developer

    Hey

    Anyone knows a nice RAID monitoring tool? I know that md's tools have build-in raid tool that informs you when something is wrong but i would also like some weblike tool. Similar to munin for example where it shows status of array, detailed info of all arrays and so on.. Been searching for it for quite a while yet i can't find anything usefull..
     
  2. falko

    falko Super Moderator ISPConfig Developer

  3. TheRudy

    TheRudy ISPConfig Developer ISPConfig Developer

    omg i'm so stupid, yes, a script that's checking that and cronjob that checks it every 10 min! If raid array is broken, it emails me..

    That's not a big cpu and memory consumer if i'm checking small text file every 10 min with cronjob is it?

    And we have a solution!
     
  4. edge

    edge Active Member Moderator

    Nice one.. Zabbix .. Now all we need is a good Howto for Debian :)
    I've done the zabbix_network_monitoring severall times now (on a virtual Debian), but till now with no luck :/
     
  5. TheRudy

    TheRudy ISPConfig Developer ISPConfig Developer

    Code:
    #!/bin/bash
    # Usage: check_raid.sh
    
    ra=(md0 md1 md2) #all available raid arrays
    count_ra=${#ra}
    
    for ((i=0;i<$count_ra;i++)); do
    if [ $(grep -A1 ${ra[${i}]} /proc/mdstat | grep UU | wc -l) -eq 0 ]; then
    
    #send email if one the raid arrays fails..
    mdadm --detail /dev/${ra[${i}]} | mail -s "${ra[${i}]} RAID Array failed" [email protected]
    
    fi
    done
    
    Probably not the best code but hey.. If someone can make it better it would be cool..
    It works if you change it from -eq 0 to -eq 1 and it sends out emails for all raid arrays, haven't tested with 0 :D

    10 min cron job will be fine right?
     
  6. falko

    falko Super Moderator ISPConfig Developer

    I don't see any problems with that. :)
     
  7. TheRudy

    TheRudy ISPConfig Developer ISPConfig Developer

    hmm a bit of a problem i might have :D

    Any idea why it doesn't send data with email? To test it, i set 1 so if the arrays are OK, i get 3 emails, each email contains data about raid array (--detail /dev/md0 and so on...). Now the thing is, if i run this script manually, i receive 3 emails with raid data about each array! But if the cronjob does it, it sends 3 emails with subject as it should be but without any content!

    cron looks like:
    Code:
    0,10,20,30,40,50 * * * * /usr/local/bin/check_raid.sh &> /dev/null
    
    tested also with:
    Code:
    0,10,20,30,40,50 * * * * (/usr/local/bin/check_raid.sh | mail -s "test" [email protected])
    as 4th email, i get:

    Code:
    Null message body; hope that's ok
    Null message body; hope that's ok
    Null message body; hope that's ok
    I don't get it! mdadm --detail command isn't run with cronjob cause?
    I set the ownership to root, script is 755, no errors..

    :confused:

    edit: i put the file in /usr/local/bin, could that be a problem? Don't see how since i can run it manually from there without any problems and getting emails with data..
     
  8. TheRudy

    TheRudy ISPConfig Developer ISPConfig Developer

    Duh! :rolleyes:

    You need full path in script else mdadm can't be found when the script is run by cronjob... Duh again..

    Code:
    /sbin/mdadm --detail /dev/${ra[${i}]} | mail -s "${ra[${i}]} RAID Array failed" [email protected]
    Also moved file from old location to /root and hmm, well, it works ;)
     
  9. falko

    falko Super Moderator ISPConfig Developer

    Or you put something like this at the beginning of your script:

    Code:
    PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin
    :)
     
  10. TheRudy

    TheRudy ISPConfig Developer ISPConfig Developer

    I'll just stick with my way.. :D
     

Share This Page