Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/bin/bash
#
# Before using, change the hostname, and emailadresses
#
# Script is created by Frode Marton Meling, 2010
#
#
# TODO!
# - run the cli as deamon so it can run in the background and poll more frequently
# - do not re-send messages unless RAID statuses are changing
# - send email when system is back online
hostname='<put in your exact hostname>'
statusfile='/var/log/raidstatus'
logdrv=`/usr/sbin/cli logdrv -v`
phydrv=`/usr/sbin/cli phydrv -v`
clilog=`/usr/bin/tail /var/log/messages | grep "$hostname cli:"`
/usr/sbin/cli logdrv -v > $statusfile
/usr/sbin/cli phydrv -v >> $statusfile
check=`cat $statusfile | grep "Array functional status" | grep -v Online | wc -l`
if [ "$check" -gt 0 ]
then
/usr/sbin/ssmtp -oi <your sender email adress> << EOF
From: "XenServer Monitoring" <your sender email adress>
To: <the email receiving notifications>
Subject: ALERT!! - XenServer: EX8350 - POSSIBLE RAID PROBLEMS
CLI Log
=======================================================
$clilog
Logical drive information
=======================================================
$logdrv
Physical drive information
=======================================================
$phydrv
EOF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment