dailyCheck.sh

Met dit scriptje check ik elke dag automatisch of de harde schijven van de server nog werken, of er geen hardware probleem is, en of de RAID-configuratie nog OK is.
Indien dit niet zo is, dan wordt er een mailtje gestuurd. Allé, dat zou toch moeten.

!/bin/bash

Email settings

email_recipient=”support@oniria.be”

Current datetime in YYYY-MM-DD_HH-MM-SS
date= date +%Y-%m-%d_%H-%M-%S

#Make sure the log directory exists.
log_filename=/diy/log/$date.log
hostname= hostname
email_subject=”Hardware Failed On $hostname”

if omreport storage pdisk controller=0 | grep State | grep -v Online;
then
echo -e “Harddrive Check Run: $date” > $log_filename
omreport storage pdisk controller=0 >> $log_filename
/usr/bin/mail -s “$email_subject” “$email_recipient” < $log_filename else echo -e “Harddrive check ran: $date” > /diy/log/check_disks_moni.log
fi

if omreport chassis | grep : | grep -v SEVERITY | grep -v Ok
then
echo -e “Hardware Check Run: $date” > $log_filename
omreport chassis >> $log_filename
/usr/bin/mail -s “$email_subject” “$email_recipient” < $log_filename else echo -e “Hardware check ran: $date” > /diy/log/check_hardware_moni.log
fi

if omreport storage vdisk | grep “State” | grep -v “Fluid” | grep -v “Ready”
then
echo -e “Harddrive Check Run: $date” > $log_filename
omreport storage vdisk >> $log_filename
/usr/bin/mail -s “$email_subject” “$email_recipient” < $log_filename else echo -e “Harddrive check ran: $date” > /diy/log/check_disks_moni.log
fi

Manueel

Wil je dit script nu manueel draaien? Voer dan volgend commando uit op de server (Audrey):

/diy/dailyCheck.sh