Snapmirror alert script

Snapmirror is very cool and fantastic tool command used for migration and mirroring. You can run the snapmirror using schedule (snapmirror.conf) and let it run.

However, the draw back of snapmirror is

  • keep the information for last transfer only. No more history more than last transfer.
  • NO Alert sent when the job fail due to destination space is full (& others reason) .

 

That is a pain in axx , i have a backup mirror failed for weeks without me realizing it. So i have written a simple script to check on the activity.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
 
 
#Target NAS
nas="nas01"
 
#Target Volume
volume="sync_backup"
 
#Define acceptable threshold , 24 hours is acceptable but 48 hours to play safe in case not able to finish the mirror within 24 hours.
threshold="48"
 
#Email to list.
mail_user_list="group1@testmail.com"
 
#Email CC list
mail_cc_list="group2@testmail.com"
 
#Command to get snapmirror lag time
mirror_hour=`ssh $nas snapmirror status | grep $volume | awk '{print $4}' | cut -f1 -d":"`
 
#Simple mail content.
message='Perform snapmirror status to check from $nas
NAS = $nas
volume = $volume
threshold = $threshold
Lag time of snapmirror = $mirror_hour'
 
if [ $mirror_hour -gt $threshold ]
then
 
echo $message | mail -s "[Alert]snapmirror for syncbackup lag time greater than $threshold hours!" -c $mail_cc_list $mail_user_list -- -r "tiwlim@testmail.com"
fi

 

My script will eventually check on the “Lag” time of snapmirror status. Lag time = last successful snapmirror activity till now. if you set a daily snapmirror happening once every day, you should not be getting lag time more than 24 hours. If it did, something is wrong and you may want to check more detail using “snapmirror status -l

2 Comments

  1. Hey, great script i have the same issue and in need of something similar. Where does this script load from .. is it meant for powershell ?

  2. TingWei

    September 11, 2014 at 11:02 pm

    Hi Sunil,
    This script is meant to run from Linux/Unix only.

    Thanks!

Leave a Reply

Your email address will not be published.

*

© 2019 Thinkway

Theme by Anders NorénUp ↑