Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8751
  • 博文数量: 2
  • 博客积分: 85
  • 博客等级: 民兵
  • 技术积分: 30
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-01 11:47
文章分类

全部博文(2)

文章存档

2013年(1)

2009年(1)

我的朋友
最近访客

分类: LINUX

2013-01-06 10:02:24

在 CentOS 6.3x86_64下面编译安装了Nagios

点击(此处)折叠或打开

  1. nagios-3.4.3.tar.gz

  2. nagios-plugins-1.4.15.tar.gz

  3. yum install -y mutt.x86_64

nagios 默认发邮件配置更改为

点击(此处)折叠或打开

  1. define command{
  2.     command_name    notify-host-by-email
  3.     command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mutt -F "/usr/local/nagios/etc/objects/muttrc" -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
  4.     }
  5. define command{
  6.     command_name    notify-service-by-email
  7.     command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mutt -F "/usr/local/nagios/etc/objects/muttrc" -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
  8.     }

查看ngaios.log

点击(此处)折叠或打开

  1. [1357436774] SERVICE NOTIFICATION: nagiosadmin;SH-Web-Tomcat05;HTTP;CRITICAL;notify-service-by-email;HTTP CRITICAL - No data received from host
  2. [1357437364] SERVICE NOTIFICATION: nagiosadmin;SH-Web-Tomcat01;HTTP;CRITICAL;notify-service-by-email;HTTP CRITICAL - No data received from host
  3. [1357437474] SERVICE NOTIFICATION: nagiosadmin;SH-Web-Tomcat01;SSH;CRITICAL;notify-service-by-email;拒绝连接

切换到nagios用户

点击(此处)折叠或打开

  1. echo "message" | mutt -F /usr/local/nagios/etc/objects/muttrc -s "Test abc $(data +%s)" admin@i-david.org

邮件发送正常

阅读(1285) | 评论(2) | 转发(0) |
0

上一篇:重启 tomcat

下一篇:没有了

给主人留下些什么吧!~~

xtso520ok2013-01-06 15:35:30

问题已经解决,感谢IT圈圈@杜亮的支持

最后是nagios调用mutt发送邮件时引用到了文件/root/sent 文件


/root
/root/sent

这两个目录都给nagios用户能读写权限即可

xtso520ok2013-01-06 10:54:39

进一步确认

是nagios这个用户,后台执行mutt,发送邮件有问题

验证理由

在nagios用户下crontab -e

echo OK | mutt -s "Test" admin@i-david.org

未收到东西

定时任务已经执行,有log验证