Chinaunix首页 | 论坛 | 认证专区 | 博客 登录 | 注册

alang85alang85.blog.chinaunix.net

爱老婆,爱工作!

  • 博客访问: 468941
  • 博文数量: 102
  • 博客积分: 1754
  • 博客等级: 上尉
  • 技术积分: 1607
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-12 10:06
文章分类

全部博文(102)

文章存档

2015年(3)

2013年(16)

2012年(83)

微信关注

IT168企业级官微



微信号:IT168qiye



系统架构师大会



微信号:SACC2013

订阅
热词专题
nagios安装笔记 2012-03-18 22:04:57

分类: 系统运维

nagios安装笔记
[root@mysql nagios-3.2.3]#./configure --prefix=/usr/local/nagios/
[root@mysql nagios-3.2.3]#make
[root@mysql nagios-3.2.3]#make all
[root@mysql nagios-3.2.3]#make install
[root@mysql nagios-3.2.3]#make install-init
     - This installs the init script in /etc/rc.d/init.d
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
[root@mysql nagios-3.2.3]#make install-commandmode
     - This installs and configures permissions on the
       directory for holding the external command file
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios//var/rw
chmod g+s /usr/local/nagios//var/rw       

[root@mysql nagios-3.2.3]#make install-config
     - This installs sample config files in /usr/local/nagios//etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios//etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios//etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios//etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios//etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios//etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios//etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios//etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios//etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios//etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios//etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios//etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios//etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios//etc/objects/switch.cfg

*** Config files installed ***

Remember, these are *SAMPLE* config files.  You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.    
[root@mysql nagios]# tar xvf nagios-plugins-1.4.15.tar.gz
[root@mysql nagios]# cd nagios-plugins-1.4.15
[root@mysql nagios-plugins-1.4.15]#./configure --prefix=/usr/local/nagios/
[root@mysql nagios-plugins-1.4.15]#make
[root@mysql nagios-plugins-1.4.15]#make install


/*安装apache*/
[root@mysql conf]# yum install -y httpd.x86_64 httpd-devel.x86_64 httpd-manual.x86_64
[root@mysql conf]# yum install php.x86_64 php-devel.x86_64
[root@mysql conf]# cd /etc/httpd/conf
[root@mysql conf]# ls
httpd.conf  magic
[root@mysql conf]# cp httpd.conf httpd.conf.std
[root@mysql conf]# ls
httpd.conf  httpd.conf.std  magic
[root@mysql conf]# vim httpd.conf
/*调整为*/
User nagios
Group nagios
DirectoryIndex index.php index.html index.html.var
AddType application/x-httpd-php .php
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
    Require  valid-user

Alias /nagios "/usr/local/nagios/share"

    AuthType basic
    Options None
    AllowOverride None
    Order allow,deny
    Allow from all
    AuthName "Nagios Access"
    AuthUserFile /usr/local/nagios/etc/htpasswd
    Require valid-user



安装rrdtool工具

wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz
[root@mysql nagios]# tar xvf rrdtool-1.4.7.tar.gz
[root@mysql nagios]# cd rrdtool-1.4.7
[root@mysql rrdtool-1.4.7]# ./configure --prefix=/usr/local/rrdtool



一、使用yum安装:
在 /etc/yum.repos.d/下面新建dag.repo文件在文件中输入源地址:
[root@hmg2 yum.repos.d]# cat dag.repo
[dag]
name=Dag RPM Repository for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
gpgkey=http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
enabled=1
[root@hmg2 yum.repos.d]#yum -y install rrdtool
这样就可以完成RRDTool安装……
二、软件包安装:
先yum安装所要的库文件:
[root@hmg2 yum.repos.d]#yum install cairo-devel libxml2-devel pango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel
然后下载rrdtool包,安装:
[root@hmg2 src]#wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.1.tar.gz
[root@hmg2 src]#tar -zxvf rrdtool-1.3.1.tar.gz
[root@hmg2 src]#cd rrdtool-1.3.1
[root@hmg2 src]#./configure --prefix=/usr/local/rrdtool && make && make install
[root@hmg2 src]#ln -s /usr/local/rrdtool/bin/* /usr/bin/
运行rrdtool –v测试安装成功没有:
[root@hmg2 src]#rrdtool -v //可以看到RRDTool的用法以及版本信息

下载pnp
[root@mysql pnp-0.4.14]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata/

[root@mysql pnp-0.4.14]# make all
[root@mysql pnp-0.4.14]# make install
[root@mysql pnp-0.4.14]# make install-config
[root@mysql pnp-0.4.14]# make install-init
配置PNP
[root@mysql pnp]# pwd
/share/softwares/nagios/pnp-0.4.14/sample-config/pnp
[root@mysql pnp]# ls
background.pdf  config.php     npcd.cfg-sample     pages               pnp4nagios_release.in        process_perfdata.cfg-sample.in
check_commands  config.php.in  npcd.cfg-sample.in  pnp4nagios_release  process_perfdata.cfg-sample  rra.cfg-sample
[root@mysql pnp]# cp process_perfdata.cfg-sample
process_perfdata.cfg-sample     process_perfdata.cfg-sample.in  
[root@mysql pnp]# cp process_perfdata.cfg-sample /usr/local/nagios/etc/pnp/process_perfdata.cfg
[root@mysql pnp]# cp npcd.cfg-sample /usr/local/nagios/etc/pnp/npcd.cfg
[root@mysql pnp]# cp rra.cfg-sample /usr/local/nagios/etc/pnp/rra.cfg
[root@mysql pnp]# chown -R nagios.nagios /usr/local/nagios/etc/pnp/   


vim /usr/local/nagios/etc/pnp/process_perfdata.cfg
LOG_LEVEL = 2 (修改)

下载 NRPE
http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz
[root@mysql nrpe-2.13]# make all
[root@mysql nrpe-2.13]# make install-plugin
cd ./src/ && make install-plugin
make[1]: Entering directory `/share/softwares/nagios/nrpe-2.13/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios check_nrpe /usr/local/nagios/libexec
make[1]: Leaving directory `/share/softwares/nagios/nrpe-2.13/src'
[root@mysql nrpe-2.13]# make install-daemon
cd ./src/ && make install-daemon
make[1]: Entering directory `/share/softwares/nagios/nrpe-2.13/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
/usr/bin/install -c -m 775 -o nagios -g nagios nrpe /usr/local/nagios/bin
make[1]: Leaving directory `/share/softwares/nagios/nrpe-2.13/src'
[root@mysql nrpe-2.13]#
[root@mysql nrpe-2.13]# make install-daemon-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc

[root@mysql etc]# /usr/local/nagios/bin/nrpe -d /usr/local/nagios/etc/nrpe.cfg -d
allowed_hosts=127.0.0.1,192.168.3.34(192.168.3.34为监控服务器的IP地址)
[root@mysql etc]# /usr/local/nagios/bin/nrpe -d /usr/local/nagios/etc/nrpe.cfg -d
[root@mysql etc]# netstat -ntlp|grep 5666
tcp        0      0 0.0.0.0:5666                0.0.0.0:*                   LISTEN      8578/nrpe   

关于新增对主机的监控:

[root@mysql etc]# ls -ld servers/
drwxr-xr-x 2 nagios nagios 4096 03-20 08:37 servers/
[root@mysql etc]# cd servers/
[root@mysql servers]# pwd
/usr/local/nagios/etc/servers

在 /usr/local/nagios/etc/nagios.cfg配置文件新增:
cfg_file=/usr/local/nagios/etc/servers/3_148.cnf

3_148.cnf配置文件如下:
[root@mysql etc]# cat servers/3_148.cnf
#监控主机服务
define host{
          use                linux-server
          host_name          148db
          alias                148db
          address              192.168.3.148
         icon_image              linux40.jpg
        }
#监控SWAP
define service{
        use                   generic-service
        host_name             148db
        service_description      check-swap
        check_command        check_nrpe!check_swap_1
        notifications_enabled           1
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            2
        check_period                    24x7
        notification_interval           5
        notification_period             workhours
        notification_options            w,u,c,r
        contact_groups                  admins
               }

define service{
        use                   generic-service
        host_name             148db
        service_description      check-load
        check_command         check_nrpe!check_load
        notifications_enabled           1
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            2
        check_period                    24x7
        notification_interval           5
        notification_period             workhours
        notification_options            w,u,c,r
        contact_groups                  admins
               }

#监控/data目录     
define service{
        use                   generic-service
        host_name            148db
        service_description      check-disk-/data
       check_command        check_nrpe!check_/data
        notifications_enabled           1
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            2
        check_period                    24x7
        notification_interval           5
        notification_period             workhours
        notification_options            w,u,c,r
        contact_groups                  admins
}
#监控根目录
define service{
        use                   generic-service
        host_name            148db
        service_description      check-disk-/
       check_command        check_nrpe!check_/
        notifications_enabled           1
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            2
        check_period                    24x7
        notification_interval           5
        notification_period             workhours
        notification_options            w,u,c,r
        contact_groups                  admins
}
#监控用户
define service{
        use                   generic-service
        host_name             148db
        service_description       check-users
        check_command         check_nrpe!check_users
        notifications_enabled           1
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            2
        check_period                    24x7
        notification_interval           5
        notification_period             workhours
        notification_options            w,u,c,r
        contact_groups                  admins
               }
#监控进程
define service{
        use                    generic-service
        host_name              148db 
        service_description       total_procs
        check_command         check_nrpe!check_total_procs
        notifications_enabled           0
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            2
        check_period                    24x7
        notification_interval           5
        notification_period             workhours
        notification_options            w,u,c,r
        contact_groups                  admins
}

 

define service{
        use                    generic-service
        host_name              148db
        service_description      check_zombie_procs
        check_command         check_nrpe!check_zombie_procs
        notifications_enabled           1
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            2
        check_period                    24x7
        notification_interval           5
        notification_period             workhours
        notification_options            w,u,c,r
        contact_groups                  admins
}
#监控SSH
define service{
        use                             generic-service        
        host_name                       148db
        service_description             SSH
        check_command                   check_ssh
        notifications_enabled           1
        max_check_attempts              3
        normal_check_interval           3
        retry_check_interval            2
        check_period                    24x7
        notification_interval           5
        notification_period             workhours
        notification_options            w,u,c,r
        contact_groups                  admins
        }
  

[root@mysql etc]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
最后显示,表明没有问题:
Total Warnings: 0
Total Errors:   0
 

 


错误处理:
1,nagios web界面提示
It appears as though you do not have permission to view information for any of the services you requested...
打开cgi.cfg配置文件,里面有个参数:
use_authentication=1
为了保障系统的安全性,nagios设置了这个参数,默认为1,改为0即可。

2,[root@mysql etc]# /etc/init.d/nagios restart                                      
Running configuration check...done.
Stopping nagios: done.
Starting nagios:This account is currently not available.
 done.
这个引起:
[root@mysql etc]# cat /etc/passwd|grep nagios
nagios:x:503:503::/home/nagios:/sbin/nologin

阅读(3187) | 评论(4) | 转发(0) |
0

上一篇:没有了

下一篇:sysbench-0.4.12安装和调试

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

weilua2012-04-11 10:02:24

写的比较清楚,要是把注释说明的地方整理一下会更好。

☆彼岸★花开2012-03-20 00:01:42

恩,一下子还真不知道怎么安装……

alang852012-03-19 16:49:55

夏冰软件2012-03-19 15:48:23

楼主写的不错,支持一下

评论热议
请登录后评论。

登录 注册