Nagios 监控 Linux邮件服务器

Will0 2009-07-07

首先在被监控主机上安装:

[root@mail src]# useradd nagios

[root@mail src]# passwd nagios

[root@mail src]# tar zxvf nagios-plugins-1.4.13.tar.gz

[root@mail src]# cd nagios-plugins-1.4.13
[root@mail nagios-plugins-1.4.13]# ./configure --prefix=/usr/local/nagios

[root@mail nagios-plugins-1.4.13]# make

[root@mail nagios-plugins-1.4.13]# make install

[root@mail nagios-plugins-1.4.13]# chown -R nagios.nagios /usr/local/nagios

[root@mail nagios-plugins-1.4.13]# cd ..

[root@mail src]# tar zxvf nrpe-2.8.1.tar.gz

[root@mail src]# cd nrpe-2.8.1

[root@mail nrpe-2.8.1]# ./configure --prefix=/usr/local/nrpe

[root@mail nrpe-2.8.1]# make all

[root@mail nrpe-2.8.1]# make install-plugin

[root@mail nrpe-2.8.1]# make install-daemon

[root@mail nrpe-2.8.1]# make install-daemon-config

[root@mail nrpe-2.8.1]# make install-xinetd

[root@mail nrpe-2.8.1]# vim /etc/xinetd.d/nrpe

      only_from       = 127.0.0.1 218.106.**.**

[root@mail nrpe-2.8.1]# vim /etc/services

# Local services

nrpe            5666/tcp                        # nrpe

[root@mail nrpe-2.8.1]# service xinetd restart

[root@mail nrpe-2.8.1]# netstat -an|grep 5666

 

tcp        0      0 0.0.0.0:5666            0.0.0.0:*               LISTEN 

 

[root@mail nrpe-2.8.1]# /usr/local/nrpe/libexec/check_nrpe -H localhost

NRPE v2.8.1

[root@mail nrpe-2.8.1]# vim /usr/local/nrpe/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hdb1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hdb1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
在nagios服务器上设置:

[root@eric ~]# /usr/local/nagios/libexec/check_nrpe -H 218.106.**.**

 

NRPE v2.8.1

[root@eric ~]# vim /usr/local/nagios/etc/objects/commands.cfg

########################################################################
#
# 2009.06.29 add by Stone
# NRPE COMMAND
#
########################################################################
# 'check_nrpe ' command definition
define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }
[root@eric ~]# vim /usr/local/nrpe/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hdb1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/hdb1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

[root@eric ~]# vim /usr/local/nagios/etc/objects/linux/mail.cfg

   define host{
      use           linux-server
      host_name     mail.com
      alias         mail.com
      address       218.106.**.**
       }

   define service{
        use             generic-service
        host_name               mail.com
        service_description     Ping
        check_command           check_ping!100.0,20%!500.0,60%define service{
       use          generic-service
       host_name    mail.com
       service_description     SMTP
       check_command check_smtp
        }
    define service{
       use          generic-service
       host_name    mail.com
       service_description     POP3
       check_command check_pop
          }

     define service{
       use          generic-service
       host_name    mail.com
       service_description     check-swap
      check_command           check_nrpe!check_swap
            }
define service{
       use          generic-service
       host_name    mail.com
       service_description     check-load
      check_command           check_nrpe!check_load
            }
define service{
       use          generic-service
       host_name    mail.com
       service_description     check-disk
       check_command           check_nrpe!check_hdb1
            }

define service{
       use          generic-service
       host_name    mail.com
       service_description     zombie_procs
      check_command           check_nrpe!check_zombie_procs
            }
define service{
       use          generic-service
       host_name    mail.com
       service_description     check-users
      check_command           check_nrpe!check_users
             }
define service{
       use          generic-service
       host_name    mail.com
       service_description     total_procs
      check_command           check_nrpe!check_total_procs
               }

[root@eric ~]# vim =/usr/local/nagios/etc/nagios.cfg

cfg_file=/usr/local/nagios/etc/objects/linux/mail.cfg
[root@eric ~]# service nagios restart

http://yourserverIP/nagios

Nagios 监控 Linux邮件服务器

相关推荐