sendEmail实现邮件报警

 下载sendEmail

  1. wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.55.tar.gz
  2. tar –zxvf sendEmail-v1.55.tar.gz
  3. cd sendEmail-v1.55
  4. cp sendEmail /usr/local/bin
  5. chmod 0755 /usr/local/bin/sendEmail
  6. /usr/local/bin/sendEmail –f [email protected]–t [email protected] –s mail.test.com –u “from nagios” –xu nagios –xp 123456–m nagios test

解释:
-f 表示发送者的邮箱
-t 表示接收者的邮箱
-s 表示SMTP服务器的域名或者ip
-u 表示邮件的主题
-xu 表示SMTP验证的用户名
-xp 表示SMTP验证的密码(注意,这个密码貌似有限制,例如我用d!5neyland就不能被正确识别)
-m 表示邮件的内容

修改commands.cfg

 

    # 'notify-by-email' command definition

define command{

        command_name    notify-by-email

        command_line    /usr/bin/printf "%b" "***** Nagios 2.9 *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -f [email protected] -t $CONTACTEMAIL$ -s mail.test.com -u "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" -xu nagios -xp 123456

                            }

你可能感兴趣的:(职场,email,sendEmail,休闲,邮件报警)