本次用到的软件为:
sendEmail-v1.56.tar.gz
一、安装很简单,解压即可
tar –zxvf sendEmail-v1.56.tar.gz
cd sendEmail-v1.56
cp sendEmail /usr/local/bin
chmod 0755 /usr/local/bin/sendEmail
二、修改nagios的commands.cfg文件
vi /usr/local/nagios/etc/objects/commands.cfg
分别把notify-host-by-email和notify-service-by-email项下的command_line 后面的改成如下:
/usr/local/bin/sendEmail -f qky520@163.com -t $CONTACTEMAIL$ -s smtp.163.com -l /var/log/sendEmail -xu qky520 -xp xxxxx -u "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -m "`/usr/bin/printf "%b" "\n***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$ \nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nDate/Time: $LONGDATETIME$\n"`"
/usr/local/bin/sendEmail -f qky520@163.com -t $CONTACTEMAIL$ -s smtp.163.com -l /var/log/sendEmail -xu qky520 -xp xxxxx -u "** $NOTIFICATIONTYPE$ Service Alert: $SERVICEDESC$ is $SERVICESTATE$ **" -m "`/usr/bin/printf "%b" "\n***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$ \nService: $SERVICEDESC$\nHost: $HOSTNAME$\nState: $SERVICESTATE$\nAddress:$HOSTADDRESS$\nInfo:$SERVICEOUTPUT$\nDate/Time: $LONGDATETIME$\n"`"
sendemail的用法:
-f 是你用于发邮件的邮箱
-s 是邮箱域名
-l 是定义日志文件
-xu 邮箱账号
-xp 邮箱密码
阅读(2679) | 评论(1) | 转发(0) |