nagios中告警邮件-sendmail服务的配置

来源:互联网 发布:黑暗法术工厂升级数据 编辑:程序博客网 时间:2024/05/04 17:32
1、检查commands.cfg
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification
Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTA
DDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $
NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
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$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert:
$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
这是正确的命令配置,其中最重要的就是/bin/mail后边的命令配置
2、mqueue
[root@localhost mqueue]# pwd
/var/spool/mqueue
[root@localhost mqueue]# ll
total 8
-rw------- 1 root smmsp 8 Nov 18 20:54 dfmAICsFQj009878
-rw------- 1 root smmsp 901 Nov 18 21:56 qfmAICsFQj009878
[root@localhost mqueue]#
这个目录存储的是邮件发送队列,如果这个里边满了不但会影响程序的运行,而且sendmail容易死掉,所以必要的时候要删除。
3、修改access
[root@localhost mail]# pwd
/etc/mail
[root@localhost mail]# vi access

# Check the /usr/share/doc/sendmail/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
# package.
#
# by default we allow relaying from localhost...
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY
Connect:192.168.0 RELAY
Connect:http://www.163.com RELAY
Connect:1.1.1 RELAY
Connect:nagios@localhost.localdomain RELAY
Connect:root@localhost RELAY

然后执行makemap hash access < access
或者是makemap -v hash /etc/mail/access.db < /etc/mail/access
4、[root@localhost spool]# pwd
/var/spool

chmod 777 mqueue
我的邮箱是163.com。
5、. 检查所传送的电子邮件是否送出,或滞留在邮件服务器中
语法:/usr/lib/sendmail -bp
若屏幕显示为“Mail queue is empty” 的信息,表示mail 已送出。
6检查邮件发送过程
在Sendmail邮件服务器上执行下面的命令.
# echo testing | /usr/sbin/sendmail -v someone@somedomain.com
7、sendmail日志
[root@localhost log]# pwd
/var/log
vi maillog就可以看了,出现任何错误都可以看到。
0 0
原创粉丝点击