2015
December
Standard

NetApp SnapMirror Mail Alert

First of all we need to make friend Linux alert# server & Netapp filer…
NetApp 7-mode SSH key passwordless auth

Generate key@Linux host

[root@alert ~]# ssh-keygen -t rsa -b 2048 -f gus-key

[root@alert ~]# cat ./gus-key.pub

sssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1QobRNaPRCx2u5Cpd8ZEn

Put gus-key.pub to the NetApp ssh conf:

[root@alert ~]# ssh systemB

#####

> priv set advanced

*> useradmin diaguser unlock

*> useradmin diaguser password

##### GO to NetApp system shell

*> systemshell

##use diag to login

login: diag

passwd:

% mkdir -p /mroot/etc/sshd/root/.ssh

% vi /mroot/etc/sshd/root/.ssh/authorized_keys
sssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1QobRNaPRCx2u5Cpd8ZEn

% chown -R root:wheel /mroot/etc/sshd/root

% chmod -R 0600 /mroot/etc/sshd/root

% exit

####Lock acc

*> useradmin diaguser lock

####Leave priv mode

*> priv set admin

> exit

############Now we are able to run remote ssh command….

Here is the script to check LAG time summary in minutes and if lag time is more that 20 min it will send ALERT message to the recipients…
it runs every 1 min thru the crontab…
My NetApp has 4 volumes in replication which runs every 3 min…0-59/3 :)Each replication takes less that 1 min, then summary shouldn’t be more that 4… :)
[root@alert ~]# cat /root/systemB.sh
#!/bin/bash

#Target NAS

nas=”systemB”

#Target Volume

volume=”systemB”

#Define acceptable threshold summary in MIN

threshold=”20″

#Email to list.

mail_user_list=”gus@belomor.nl”

#Email CC list

mail_cc_list=”gbackoffice@belomor.nl”

#Command to get snapmirror lag time summary

mirror_min_sum=`ssh $nas snapmirror status | grep $volume | awk ‘{print $4}’ | awk -F ‘:’ ‘{ sum+=$2} END {print sum}’`

#Simple mail content.

message=’Perform snapmirror status check’

if [ $mirror_min_sum -gt $threshold ]

then

echo $message | mail -s “[Alert]snapmirror lag time at $nas greater than $threshold minutes! ” -c $mail_cc_list $mail_user_list — -r “root@systemB.belomor.nl”

fi
[root@alert ~]# contab -e

*/1 * * * * /root/systemB.sh #EVERY MIN

*/1 * * * * /root/systemA.sh #EVERY MIN
###JUST A LITTLE COMMAND :)
cat ./ss | grep system | awk ‘{print $4}’ | awk -F ‘:’ ‘{ sum+=$2} END {print sum}’
###

systemB> snapmirror status

Snapmirror is on.
Source Destination State Lag Status
systemC:vol0 systemB:vol3 Snapmirrored 00:01:53 Idle with restart checkpoint (23 MB done)
systemC:vol4 systemB:vol5 Snapmirrored 00:02:58 Transferring (36 MB done)
systemA:/vol/vol1/qt5 systemB:/vol/vol4/qt5 Quiesced 00:01:12 Idle
systemC:/vol/vol2/qt1 systemB:/vol/vol1/qt2 Snapmirrored 00:02:33 Quiescing

 

 

# date
Mon Dec 21 19:25:47 AZT 2015

 

more