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=”[email protected]

#Email CC list

mail_cc_list=”[email protected]

#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 “[email protected]

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
Standard

Postfix + Yandex DNS MAIL RELAY

OS:

[root@nas ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[root@nas ~]# uname -a
Linux nas 2.6.32-573.3.1.el6.x86_64 #1 SMP Thu Aug 13 22:55:16 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Install required compotes:

[root@nas ~]# yum install cyrus-sasl-plain -y
[root@nas ~]# yum install mail -y

 

[root@nas ~]# vi /etc/postfix/main.cf

to the end:

# pdd.yandex.ru: SMTP-Relay config
relayhost =
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_type = cyrus
smtp_sasl_mechanism_filter = login
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
sender_canonical_maps = hash:/etc/postfix/canonical
smtp_generic_maps = hash:/etc/postfix/generic
smtp_use_tls = yes

 

 

[root@nas ~]# vi /etc/postfix/canonical

@belomor.nl [email protected]
[root@nas ~]# vi /etc/postfix/sasl_passwd

smtp.yandex.ru [email protected]:MYPASSWD

[root@nas ~]# vi /etc/postfix/sender_relay

@belomor.nl smtp.yandex.ru
[root@nas ~]# postmap /etc/postfix/canonical
[root@nas ~]# postmap /etc/postfix/sasl_passwd
[root@nas ~]# postmap /etc/postfix/generic
[root@nas ~]# postmap /etc/postfix/sender_relay
[root@nas ~]# service postfix restart

[root@nas ~]# echo “MESSAGE” | mail -r “[email protected] (NAS SERVER)” -s “SUBJECT” [email protected]

 

[root@nas ~]# tail -f /var/log/maillog | grep “status=sent”
Dec 20 02:58:53 nas postfix/smtp[23981]: 6DEA63220718: to=<[email protected]>, relay=smtp.yandex.ru[213.180.193.38]:25, delay=1.3, delays=0.02/0/0.55/0.69, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued on smtp4h.mail.yandex.net as 1450565933-USGDET3ys6-wrFeS5vD)

subj

 

 

 

 

 

 

 

 

:)

[root@nas ~]# date
Sun Dec 20 03:01:30 AZT 2015

 

more