Date: Tue, 8 May 2018 11:00:34 +0200 From: Miroslav Lachman <000.fbsd@quip.cz> To: Andrea Brancatelli <abrancatelli@schema31.it>, freebsd-stable <freebsd-stable@freebsd.org> Subject: Re: Notification for gmirror failures Message-ID: <f271c8ef-36a7-0a93-9e0b-4bf01ac5552a@quip.cz> In-Reply-To: <e792884d579cd1f2c8d05ff4002ad1a3@schema31.it> References: <e792884d579cd1f2c8d05ff4002ad1a3@schema31.it>
next in thread | previous in thread | raw e-mail | index | archive | help
Andrea Brancatelli wrote on 2018/05/08 09:28: > Hi, > > out of curiosity, does any kind of GMirror-failure notification tools > exist? > > Either native... SNMP... external ports... whatever? I don't know any daemon like solution so I wrote some simple shell script. Its used on all our machines. It should be run be cron in some sane interval (like each 5 or 10 minutes) #!/bin/sh ## $Id: check_gmirror.sh 8c1f418ba7f5 2017-06-15 12:36 +0200 lachman $ export PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" mailto="you@example.com" subject_pref="$(hostname) gmirror" notify_state="/var/run/${0##*/}.notified" cmd_out=$(gmirror status -s) components="$(echo "$cmd_out" | grep -F -v COMPLETE)" if [ -n "$components" ]; then if [ ! -f "$notify_state" ]; then subject="$subject_pref FAILED - $(date '+%Y-%m-%d %H:%M:%S')" echo "$cmd_out" | sed -E 's/(SYNCHRONIZING,) [0-9]+%/\1 x%/' > "$notify_state" echo "$cmd_out" | mail -s "$subject" "$mailto" echo "$subject" | logger else subject="$subject_pref FAILED - $(date '+%Y-%m-%d %H:%M:%S')" echo "$cmd_out" | sed -E 's/(SYNCHRONIZING,) [0-9]+%/\1 x%/' > "$notify_state.now" diff -u -b -B "$notify_state" "$notify_state.now" > "$notify_state.diff" if [ -s "$notify_state.diff" ]; then ## if diff is not empty cat "$notify_state.diff" | mail -s "$subject" "$mailto" echo "$subject additional failure occurred" | logger cp "$notify_state.now" "$notify_state" fi rm "$notify_state.now" "$notify_state.diff" fi else if [ -f "$notify_state" ]; then rm "$notify_state" subject="$subject_pref now OK - $(date '+%Y-%m-%d %H:%M:%S')" echo "$cmd_out" | mail -s "$subject" "$mailto" echo "$subject" | logger fi fi We have similar script for checking ZFS too. Miroslav Lachman
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f271c8ef-36a7-0a93-9e0b-4bf01ac5552a>