nagios-plugins-2.0.3.tar.gz
nrpe-2.15.tar.gz
httpd-2.2.23.tar.gz
2、Nagios Server端安装
1)、安装相关依赖包
yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel
2)、安装Nagios
# useradd -s /sbin/nologin nagios
# configure --prefix=/usr/local/nagios
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# chkconfig nagios on
# chkconfig --list | grep nagios
3)、安装Nagios插件
# tar zxvf nagios-plugins-2.0.3.tar.gz
# cd nagios-plugins-2.0.3
# ./configure --prefix=/usr/local/nagios/
# make && make install
4)、安装配置apache
# tar zxvf httpd-2.2.23.tar.gz
# cd httpd-2.2.23
# ./configure --prefix=/usr/local/apache2
# make && make install
# vim /usr/local/apache2/conf/http.conf
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
User daemon
Group daemon
修改为
User nagios
Group nagios
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
修改并增加为
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
AddType application/x-httpd-php .php
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
增加验证配置,即在httpd.conf 文件最后添加如下信息:
#setting for nagios
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>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
创建上面的目录验证文件htpasswd
# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd nagios
# vim /usr/local/nagios/etc/cgi.cfg
修改配置文件中所有含有nagiosadmin的内容
nagiosadmin => nagiosadmin,nagios
# scp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
# vim /etc/init.d/httpd
添加以下内容
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web Server
# chkconfig httpd on
# chkconfig --list | grep httpd
5)、安装配置php
# tar zxvf php-5.4.10.tar.gz
# cd php-5.4.10
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
# make && make install
# service httpd start
# service nagios start
6)、安装nrpe
# tar zxvf nrpe-2.15.tar.gz
# cd nrpe-2.15
# ./configure --enable-command-args
# make all
# make install-plugin
# /usr/local/nagios/libexec/check_nrpe -H 10.0.2.203
NRPE v2.15
7)、配置commands.cfg,添加check_nrpe定义
vim /usr/local/nagios/etc/objects/commands.cfg
# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
8、配置hosts.cfg
vim /usr/local/nagios/etc/objects/hosts.cfg
define host{
use linux-server
host_name node.3
alias node.3
address 10.0.2.203
}
9、配置node.3.cfg(也就是node.3的services.cfg文件,为了便于管理,每台机器的services.cfg文件分开配置,并以主机名命名)
vim /usr/local/nagios/etc/objects/node.3.cfg
define service{
use local-service
host_name node.3
service_description Current Load
check_command check_nrpe!check_load
contact_groups admins
}
define service{
use local-service
host_name node.3
service_description Check Disk disk
check_command check_nrpe!check_disk
contact_groups admins
}
define service{
use local-service
host_name node.3
service_description Total Processes
check_command check_nrpe!check_total_procs
contact_groups admins
}
define service{
use local-service
host_name node.3
service_description Current Users
check_command check_nrpe!check_users
contact_groups admins
}
define service{
use local-service
host_name node.3
service_description Check Zombie Procs
check_command check_nrpe!check_zombie_procs
contact_groups admins
}
10)、配置nagios.cfg
# vim /usr/local/nagios/etc/nagios.cfg
添加以下内容
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/node.3.cfg
11)、检查nagios配置文件,并重启nagios服务
# chown -R nagios.nagios /usr/local/nagios
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# service nagios restart