Skip to content

Instantly share code, notes, and snippets.

@marton
Created March 26, 2010 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marton/344939 to your computer and use it in GitHub Desktop.
Save marton/344939 to your computer and use it in GitHub Desktop.
#!/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