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

[[email protected] ~]# ssh-keygen -t rsa -b 2048 -f gus-key

[[email protected] ~]# cat ./gus-key.pub

sssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1QobRNaPRCx2u5Cpd8ZEn

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

[[email protected] ~]# 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… :)
[[email protected] ~]# 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
[[email protected] ~]# 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:

[[email protected] ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[[email protected] ~]# 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:

[[email protected] ~]#¬†yum install cyrus-sasl-plain -y
[[email protected] ~]# yum install mail -y

 

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

 

 

[[email protected] ~]# vi /etc/postfix/canonical

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

smtp.yandex.ru [email protected]:MYPASSWD

[[email protected] ~]# vi /etc/postfix/sender_relay

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

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

 

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

 

 

 

 

 

 

 

 

:)

[[email protected] ~]# date
Sun Dec 20 03:01:30 AZT 2015

 

more