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"
<Directory "/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
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/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

</Directory>

安装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   


错误处理:
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
 
 





 

posted @ 2012-03-09 19:11  痞子过  阅读(323)  评论(0编辑  收藏  举报