為了要使 IBM DS Storage 郵件警示可以與 SMS 作整合,在 Storage 管理軟體送出警示郵件後,郵件必須透過 Procmail 作過濾以及指定的二次處理程序。
需要的軟體:
郵件轉 SMS 流程:
[IBM DS Storage Manager] ------> [ ds_alerts@localhost ] --------> [ .forward ] -------> [ .procmailrc ] ------> [ SMS provider ]
NOTE:上述流程是基於 Storage 管理軟體與 Procmail 必須安裝在同一部主機,如果其他主機的警示郵件,也要透過這部主機轉發 SMS,需要的步驟在下方文章內。
alang@company.com, "|exec /usr/bin/procmail -f- || exit 75 #ds_alerts"
NOTE:
- #ds_alerts ,ds_alerts 是帳號名稱。
- 如果是在 AIX 系統,必須改成
"|IFS=' ' && exec /usr/bin/procmail || exit 75 #ds_alerts"
MAILDIR=/var/spool/mail SHELL=/bin/sh LOGFILE=$HOME/temp/procmail.log LINEBUF=8192 VERBOSE=yes SMS_SUBJECT="WIN Alert: Something went wrong with the DS storage, pls check your mail box ASAP!!" SMS_TO="sms@provider.com" SMS_ID="[SMS_AIX]" :0 # Fetch all email #* ^From.* # Fetch the email that included the word 'tpemismo02'. * ^From.*(tpemismo02) | echo "$SMS_ID" | mail -s "$SMS_SUBJECT" "$SMS_TO" ;
NOTE:
- 檔案權限 0600
- 利用 procmail.log 除錯
- 要取得信件的主旨內容,可以使用
SUBJECT=`formail -xSubject:`
NOTE:
procmail.host 是本機的 domain name,不可以使用 localhost 替代。
開啟 sendmail 可接收外部主機的信件
# cd /etc/mail # cp -a sendmail.mc sendmail.mc.bak # cp -a sendmail.cf sendmail.cf.bak # vi sendmail.mc DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl 改成 DAEMON_OPTIONS(`Port=smtp,Addr=0.0.0.0, Name=MTA')dnl # m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf # service sendmail restart
Jun 23 17:49:25 tpemismo02 sendmail[20001]: s5N9nPGa020001: from=<noreply@tpemismo02.winfounrdry.com>, size=446, class=0, nrcpts=1, msgid=<201406230949.s5N9nPGa020001@tpemismo02.winfoundry.com>, proto=SMTP, daemon=MTA, relay=localhost.localdomain [127.0.0.1]
Jun 23 17:49:25 tpemismo02 smrsh: uid 500: attempt to use "procmail -f- || exit 75 #ds_alerts" (stat failed)
Jun 23 17:49:25 tpemismo02 sendmail[20002]: s5N9nPGa020001: to="|exec /usr/bin/procmail -f- || exit 75 #ds_alerts", ctladdr=<ds_alerts@tpemismo02.winfoundry.com> (500/500), delay=00:00:00, xdelay=00:00:00, mailer=prog, pri=30735, dsn=5.0.0, stat=Service unavailable
Jun 23 17:49:25 tpemismo02 sendmail[20002]: s5N9nPGa020001: s5N9nPGa020002: DSN: Service unavailable
Ans: 原因是 smrsh 無法執行指令 procmail,解決方式:
# ln -s /usr/bin/procmail /etc/smrsh # ls -l /etc/smrsh lrwxrwxrwx 1 root root 17 Jun 24 10:19 procmail -> /usr/bin/procmail
Images 0 | ||
---|---|---|
No images to display in the gallery. |