- 论坛徽章:
- 0
|
今天我在CentOS release 5.6 (Final)(32bit)里搭建了naigos Version 3.3.1,配置完成之后重启没有报错,但当主机宕掉了还是没有收到报警的邮件,不知道是什么原因,现在我把我的配置与日志贴出来,希望大家能帮我分析一下是什么问题导致不能发送邮件报警,以及解决方法,谢谢!
commands.cfg的关于邮件报警的配置:
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\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$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
contacts.cfg的配置:
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
email 244979152@qq.com ;我的qq邮箱
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
localhost.cfg的部分配置:
define host{
use linux-server .
host_name nginx
alias nginx
address 192.168.10.220
}
define hostgroup{
hostgroup_name linux-servers
alias Linux Servers
members nginx
}
define service{
use local-service ; Name of service template to use
host_name nginx
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service ; Name of service template to use
host_name nginx
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}
但我的另外一个监控主机或者本机的一个服务(如httpd)宕掉的时候,我的邮箱里收不到邮件报警,下面是我的mail日志
Jan 4 06:01:01 nginx sendmail[4362]: q04B11FU004362: from=root, size=328, class=0, nrcpts=1, msgid=<[email=201201041101.q04B11FU004362@nginx]201201041101.q04B11FU004362@nginx[/email]>, [email=relay=root@localhost]relay=root@localhost[/email]
Jan 4 06:01:01 nginx sendmail[4415]: q04B11ib004415: from=<[email=root@nginx]root@nginx[/email]>, size=541, class=0, nrcpts=1, msgid=<[email=201201041101.q04B11FU004362@nginx]201201041101.q04B11FU004362@nginx[/email]>, proto=ESMTP, daemon=MTA, relay=[127.0.0.1]
Jan 4 06:01:01 nginx sendmail[4362]: q04B11FU004362: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30328, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q04B11ib004415 Message accepted for delivery)
Jan 4 06:01:02 nginx sendmail[4426]: q04B11ib004415: to=<[email=root@nginx]root@nginx[/email]>, ctladdr=<[email=root@nginx]root@nginx[/email]> (0/0), delay=00:00:01, xdelay=00:00:00, mailer=local, pri=30700, dsn=2.0.0, stat=Sent
Jan 4 06:05:01 nginx sendmail[4511]: My unqualified host name (nginx) unknown; sleeping for retry
Jan 4 06:06:01 nginx sendmail[4511]: unable to qualify my own domain name (nginx) -- using short name
Jan 4 06:06:01 nginx sendmail[4511]: q04B61no004511: from=root, size=328, class=0, nrcpts=1, msgid=<[email=201201041106.q04B61no004511@nginx]201201041106.q04B61no004511@nginx[/email]>, [email=relay=root@localhost]relay=root@localhost[/email]
Jan 4 06:06:01 nginx sendmail[4530]: q04B61Em004530: from=<[email=root@nginx]root@nginx[/email]>, size=541, class=0, nrcpts=1, msgid=<[email=201201041106.q04B61no004511@nginx]201201041106.q04B61no004511@nginx[/email]>, proto=ESMTP, daemon=MTA, relay=[127.0.0.1]
Jan 4 06:06:01 nginx sendmail[4511]: q04B61no004511: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30328, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (q04B61Em004530 Message accepted for delivery)
Jan 4 06:06:01 nginx sendmail[4531]: q04B61Em004530: to=<[email=root@nginx]root@nginx[/email]>, ctladdr=<[email=root@nginx]root@nginx[/email]> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30700, dsn=2.0.0, stat=Sent
我根据日志分析好像是邮件都发生到root@nginx里了,但不知道如何的修改能是mail发生邮件到我设定的邮箱里,希望大家能帮我分析一下原因与解决方法
下面还有我的hosts文件里的信息
[root@nginx objects]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#127.0.0.1 test2 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.10.224 web2
192.168.10.223 web1
192.168.10.221 nginx-backup
192.168.1.225 center center
192.168.10.220 nginx localhost
[root@nginx objects]# hostname
nginx
我的邮件是用本机自带的sendmail发送的,没有更改任何配置,直接启动就用。
附件是我的nagios配置文件。
|
|