nagios利用sendEmail发警告邮件
sendmail太麻烦,所以决定用sendEmail,一个不错的邮件软件
下载并解压sendEmail
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585775lTlf.jpg
复制文件
cp –a sendEmail-v1.56/sendEmail /usr/local/bin
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585775sR7a.png
给它执行权限
chmod +x /usr/local/bin/sendEmail
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585776ImNz.png
运行它的方法
sendEmail 或者/usr/local/bin/sendEmail
会出现它的详细解释
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585776DLPB.png
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585776OnFZ.png
先发一封邮件测试
-f是发送者from
-t是接收者to
-u是主题,也就是邮件名
-m是内容
提示发送成功,看能不能收到
我用163的发,qq的收
sendEmail –f ******@163.com –t ######@qq.com –u “test”-m “LOOK”
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585777xEM7.jpg
OK,果然收到了,但这里发送者不能用qq邮箱,我试了用QQ邮箱发却收不到,也有人说用gmail,139邮箱发也是可以的
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585777ZoGo.png
配置nagios的commands.cfg
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585777sMtC.png
把email的主机和服务命令最后的/usr这里路径改成sendEmail复制到的路径,填写发送方,接收方这里用的是引用,引用的是contacts.cfg里的email地址,不知道这里直接写邮箱地址,contacts.cfg里不写email行不行,懒得试了,有兴趣的可以自己试下!
这里就三个参数-f -t –u
/usr/local/bin/sendEmail -f 发送邮箱 -t $CONTACTEMAIL$ -u "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **"
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585778HinP.jpg
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585779ed2L.jpg
编辑contacts.cfg
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585779obKE.png
添加接收邮箱
email ######@qq.com
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585779bdT2.jpg
重启服务
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585780mNgn.jpg
成功,如果你关天没收到,就改一下template.cfg里的120那个重发时间,改小一点就很快收到了,默认是2个小时重发!
http://mcmvp.blog.运维网.com/attachment/201306/7/5497438_1370585781DTYL.jpg
页:
[1]