I'm not sure what the 'best' way to monitor a geom is but this should,
in theory, work. I wrote it while eating lunch, so obviously it hasn't
been tested much and probably contains bugs. If someone, perhaps here
on the list, could offer suggested changes (or a better way), that'd
be great! Hopefully the indentation won't get screwed up too badly in
transit. If so, ask and I can email it as a plain-text attachment.

# Script below:
#!/bin/sh
# DESCRIPTION:
#   Heartbeat script to check the status of geoms. If a geom is degraded,
#   This script will email the administrator.
#
# USAGE:
#   Place this script in a directory which will be writable by the UID who will
#   be executing this script via cron. Setup a cron job to execute it at
#   regular intervals.
#
# BUGS:
#   THIS SCRIPT HAS NOT BEEN TESTED! USE AT YOUR OWN RISK!
#

admin="y...@example.com"
host=`hostname`
subject="Gmirror is degraded on $host"
output=`gmirror status`
count=`gmirror status | grep -i -c "degraded"`
stateFile="gmirror.emailSent"

if [ $count -gt 0 ]
then # The geom is degraded.
   if [ ! -w "$stateFile" ]
   then # Send an  email and remember that we sent an email:
      gmirror status | mail -s "$subject" "$admin"
      touch "$stateFile"
   fi
fi

# The geom is fine, remove the email state file.
if [ $count -eq 0 ]
then
   if [ -w "$stateFile" ]
   then
      rm "$stateFile"
   fi
fi
#  End Script

It's a thought, anyway.
-Modulok-


On 3/5/09, Mister Olli <mister.o...@googlemail.com> wrote:
> Hi hi...
>
> What is the best way to monitor geom software raids (gmirror & gvinum
> raid5)???
>
> The solution I'm searching for should be a kind of script which checks
> the status, and drops me an email if something is wrong.
>
> I found a nagios plugin, but currently I'm unable to invest enough time
> to get nagios up and running for the customer...
>
> Thanks a lot...
>
> greetz
> Olli
>
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"
>
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to