Chinaunix首页 | 论坛 | 博客
  • 博客访问: 116919
  • 博文数量: 17
  • 博客积分: 431
  • 博客等级: 下士
  • 技术积分: 172
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-13 14:45
文章分类

全部博文(17)

文章存档

2012年(1)

2011年(16)

分类: LINUX

2011-10-10 10:41:51

root@alex:/opt/src# tar zxvf nagios-3.1.2.tar.gz

root@alex:/opt/src# apt-get install libcurl4-openssl-dev 

root@alex:/opt/src# tar zxvf nagios-plugins-1.4.12.tar.gz

root@alex:/opt/src# tar zxvf nrpe-2.8.1.tar.gz

root@alex:/opt/src# cd ../nagios-3.1.2

root@alex:/opt/src/nagios-3.1.2#  ./configure --prefix=/usr/local/nagios/

root@alex:/opt/src/nagios-3.1.2#  make all

root@alex:/opt/src/nagios-3.1.2#  make

root@alex:/opt/src/nagios-3.1.2#  make install

root@alex:/opt/src/nagios-3.1.2# make install-commandmode  \\安装配置文件

root@alex:/opt/src/nagios-3.1.2# make install-config    \\安装范例

root@alex:/opt/src/nagios-3.1.2# make install-init          \\安装启动脚本

root@alex:/opt/src/nagios-3.1.2# useradd -m nagios

root@alex:/opt/src/nagios-3.1.2# chown -R nagios.nagios /usr/local/nagios/

root@alex:/opt/src/nagios-3.1.2# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagios    \\访问nagios主页需要用户认证

root@alex:/opt/src/nagios-3.1.2# chmod 755 /usr/local/nagios/etc/htpasswd.users

root@alex:/opt/src/nagios-3.1.2# cd ../nagios-plugins-1.4.12

root@alex:/opt/src/nagios-plugins-1.4.12# ./configure –prefix=/usr/local/nagios

root@alex:/opt/src/nagios-plugins-1.4.12# make

root@alex:/opt/src/nagios-plugins-1.4.12# make install

root@alex:/opt/src/nagios-plugins-1.4.12# cd /etc/apache2/sites. available

root@alex:/etc/apache2/sites-available# vim nagios

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

AuthType Basic

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName "Nagios Access"

AuthUserFile /usr/local/nagios/etc/htpasswd.users

Require valid-user

 

Alias /nagios /usr/local/nagios/share

AuthType Basic

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName "Nagios Access"

AuthUserFile /usr/local/nagios/etc/htpasswd.users

Require valid-user

root@alex:~# /etc/init.d/nagios restart

  web见面输入  输入用户名、密码  可进入主页,但无法显示内容 需要更改/usr/local/nagios/etc/cgi.cfg里面的use_authentication=0(默认为1

在重启nagios即可

 

root@alex:~# cd /opt/src/nrpe - -2.8.1

root@alex:/opt/src/nrpe -2.8.1# ./configure --prefix=/usr/local/nagios/

root@alex:/opt/src/nrpe -2.8.1# make

root@alex:/opt/src/nrpe -2.8.1# make install

root@alex:/opt/src/nrpe -2.8.1# make install-plugin            \\安装插件

root@alex:/opt/src/nrpe -2.8.1# make install-daemon            \\安装daemon

root@alex:/opt/src/nrpe -2.8.1# make install-config              \\ 安装配置文件

root@alex:/opt/src/nrpe -2.8.1# make install-daemon-config       \\nrpe.cfg

root@alex:/opt/src/nrpe -2.8.1# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d

root@alex:/opt/src/nrpe -2.8.1# cd /usr/local/nagios/etc/objects/

root@alex:/usr/local/nagios/etc/objects# vim commands.cfg

    # 'check_nrpe' command definition

define command{

        command_name    check_nrpe

        command_line    /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -t 30

        }


root@alex:/usr/local/nagios/etc/objects# vim host.cfg       \\统一建立主机

define host {

       use                        linux-server

       host_name                  192.168.108.102

       alias                      192.168.108.102

       address                    192.168.108.102

       }

 

define host {

       use                        linux-server

       host_name                  192.168.100.109

       alias                      192.168.100.109

       address                    192.168.100.109

       }

root@alex:/usr/local/nagios/etc/objects# vim hostgroup.cfg      \\统一建立工作组

      define hostgroup {

        hostgroup_name  worker

        alias           worker Servers

        members         192.168.108.102,192.168.100.109

        }

root@alex:/usr/local/nagios/etc/objects# vim 192.168.108.102.cfg    \\添加监控服务

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             users

        check_command                   check_nrpe!check_users

        }

 

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             root partition

        check_command                   check_nrpe!check_load

        }

 

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             unkown

        check_command                   check_nrpe!check_zombie_procs

        }

 

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             total processes

        check_command                   check_nrpe!check_total_procs

        }

 

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             sda1

        check_command                   check_nrpe!check_sda1

        }

 

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             sda2

        check_command                   check_nrpe!check_sda2

        }

 

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             ping

        check_command                   check_nrpe!check_ping

        }

 

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             ssh

        check_command                   check_nrpe!check_ssh

        }

 

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             swap usage

        check_command                   check_nrpe!check_swap

        }

 

define service{

        use                             generic-service

        host_name                       192.168.108.102

        service_description             http

        check_command                   check_nrpe!check_http

        }

 

root@alex:/usr/local/nagios/etc/objects# vim ../nagios.cfg     \\添加加载的配置文件

cfg_file=/usr/local/nagios/etc/objects/192.168.108.102.cfg

cfg_file=/usr/local/nagios/etc/objects/192.168.100.109.cfg

cfg_file=/usr/local/nagios/etc/objects/host.cfg

cfg_file=/usr/local/nagios/etc/objects/hostgroup.cfg

root@alex:/usr/local/nagios/etc/objects# vim ../nrpe.cfg        \\添加监控服务

command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/sda1

command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/sda2

command[check_ping]=/usr/local/nagios/libexec/check_ping -H 192.168.108.102 -w 100,20% -c 500,60% -p 4

command[check_ssh]=/usr/local/nagios/libexec/check_ssh -p 22 -t 10 192.168.108.102

command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%

command[check_http]=/usr/local/nagios/libexec/check_http -H 192.168.108.102

 

192.168.100.109机:

 root@alex1~# cd /opt/src/nrpe - -2.8.1

root@alex1/opt/src/nrpe -2.8.1# ./configure --prefix=/usr/local/nagios/

root@alex1/opt/src/nrpe -2.8.1# make

root@alex1/opt/src/nrpe -2.8.1# make install

root@alex1/opt/src/nrpe -2.8.1# make install-plugin            \\安装插件

root@alex1/opt/src/nrpe -2.8.1# make install-daemon            \\安装daemon

root@alex1/opt/src/nrpe -2.8.1# make install-config              \\ 安装配置文件

root@alex1/opt/src/nrpe -2.8.1# make install-daemon-config       \\nrpe.cfg

root@alex1/usr/local/nagios/etc/# vim nrpe.cfg        \\添加监控服务

command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/sda1

command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p /dev/sda2

command[check_ping]=/usr/local/nagios/libexec/check_ping -H 192.168.100.109 -w 100,20% -c 500,60% -p 4

command[check_ssh]=/usr/local/nagios/libexec/check_ssh -p 22 -t 10 192.168.100.109

command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%

command[check_http]=/usr/local/nagios/libexec/check_http -H 192.168.100.109

root@alex1:/usr/local/nagios/etc# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d


192.168.108.102:

root@alex:~# cd /usr/local/nagios/etc/objects

root@alex:/usr/local/nagios/etc/objects# vim 192.168.100.109.cfg

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             Users

        check_command                   check_nrpe!check_users

        }

 

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             Root Partition

        check_command                   check_nrpe!check_load

        }

 

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             Unkown

        check_command                   check_nrpe!check_zombie_procs

        }

 

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             Total Processes

        check_command                   check_nrpe!check_total_procs

        }

 

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             sda1

        check_command                   check_nrpe!check_sda1

        }

 

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             sda2

        check_command                   check_nrpe!check_sda2

        }

 

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             PING

        check_command                   check_nrpe!check_ping

        }

 

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             SSH

        check_command                   check_nrpe!check_ssh

        }

 

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             Swap Usage

        check_command                   check_nrpe!check_swap

        }

 

define service{

        use                             generic-service

        host_name                       192.168.100.109

        service_description             HTTP

        check_command                   check_nrpe!check_http

        }

root@alex:/usr/local/nagios/etc/objects# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

                   检查nagios配置文件是否有错误

注意: 在nrpe.cfg中 的allowd_hosts=ip      后面跟上可以监控的主机ip 多个ip用“,”隔开 否则会出现CHECK_NRPE: Error - Could not complete SSL handshake. 

root@alex:/usr/local/nagios/etc/objects# /sr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d

                   启动nrpe

阅读(2819) | 评论(0) | 转发(0) |
0

上一篇:debian 安装lamp

下一篇:自编译mysql

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