手动添加apache支持 )
lamp环境搭建直接用xampp
1.添加用户与组:
useradd nagios
groupadd nagios
useradd –G nagios nagios
2.安装nagios:
tar zxvf nagios-3.5.0.tar.gz
cd nagios
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
Make all
make install
Make install-init
Make install-commmode
Make-install-config
Make install-webconf(失败,没有找到httpd.conf
vi httpd.conf,添加以下内容
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory "/usr/local/nagios/sbin">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share">
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
添加用户密码
/usr/local/apache2/bin/htpasswd ‐ c /usr/local/nagios/etc/htpasswd nagios
New password: (输入12345)
Re‐ type new password: (再输入12345)
3. 启动nagios 启动项
把Nagios 加入到服务列表中以使之在系统启动时自动启动
chkconfig ‐‐ add nagios
chkconfig nagios on
验证Nagios 的样例配置文件
/usr/local/nagios/bin/nagios ‐ v /usr/local/nagios/etc/nagios.cfg
如果没有报错,可以启动Nagios 服务
service nagios start
4.服务端安装插件nagios-plugins
tar zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure
make
make install
chown nagios.nagios /usr/local/nagios
chown ‐ R nagios.nagios /usr/local/nagios/libexec
5.服务端安装nrpe插件
tar ‐ zxvf nrpe ‐***.tar.gz
cd nrpe
./configure
make all
make install -plugin
测试连接 /usr/local/nagios/libexec/check_nrpe -H localhost
6.客户端安装plugin和nrpe
useradd nagios
groupadd nagios
tar zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure
make
make install
chown nagios.nagios /usr/local/nagios
chown ‐ R nagios.nagios /usr/local/nagios/libexec
tar ‐ zxvf nrpe ‐***.tar.gz
cd nrpe
./configure
make all
make install -plugin
make install -daemon
make install -daemon- config
7.客户端配置check_nrpe(被动方式)
vi /usr/local/nagios/etc/objects/command.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
vi /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg(添加被监控机器的配置文件)
vi /usr/local/nagios/etc/objects/mylinux.cfg
define host{
use linux-server
host_name oracle
alias oracle 10g
address 192.168.1.132 被监控机器ip
}
define service{
use generic-service
host_name oracle
service_description proc
check_command check_nrpe!check_total_procs!20!10
}
8.客户端修改配置文件,启动nrpe
vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,192.168.1.165
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 27753/nrpe
9.访问 http:/165主机ip/nagios,查看132(oracle)服务