www.nagios.org
下载nagios nagios-plugs nrpe
www.apache.org
下载apache
1) 安装apache
进入tar包解压路径(tar.gz zxvf 选项解压 tar.bz jxvf选项解压)
cd /usr/httpd-2.2.11
安装
./configure --prefix=/usr/local/apache && make && make install
在安装完nagios后在/usr/local/apache/conf/httpd.conf添加
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
或者用Include /usr/nagios-3.06/sample-config/httpd.conf 方式添加
2)安装nagios
cd /usr/nagios-3.0.6 (nagios 3.1版本tar包有些问题,安装后不能访问目前建议使用低版本)
安装
a)添加nagios用户
adduser nagios
b)执行安装命令
./configure --prefix=/usr/local/nagios
make all
make install
make install-init ##This installs the init
make install-commandmode
make install-config ##将初始的配置文件安装到/usr/local/nagios/etc
make install
make install-init ##This installs the init
make install-commandmode
make install-config ##将初始的配置文件安装到/usr/local/nagios/etc
3)安装nagios-plugs
./configure --prefix=/usr/local/nagios/ --enable-redhat-pthread-workaround(此选项针对redhat)
make all
make install
make install
4)安装nrpe测试本地
./configure
make all
Install the NRPE plugin (for testing), daemon, and sample daemon config file.
make install-plugin
make install-daemon
make install-daemon-config
Install the NRPE daemon as a service under xinetd.
make install-xinetd
Edit the /etc/xinetd.d/nrpe file and add the IP address of the monitoring server to the only_from directive.
only_from = 127.0.0.1 210.51.4.114
Add the following entry for the NRPE daemon to the /etc/services file.
nrpe 5666/tcp # NRPE
Restart the xinetd service.
service xinetd restart
5)测试nrpe情况
# netstat -at|grep nrpe
tcp 0 0 *:nrpe *:* LISTEN
# netstat -an|grep 5666
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN
可以看到5666端口已经在监听了
6)执行
/usr/local/nagios/libexec/check_nrpe -H localhost
测试nrpe是否正常工作
7)执行下面命令检查nagios配置
/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
7)执行下面命令启动nagios
/usr/local/nagios/bin/nagios –d /usr/local/nagios/etc/nagios.cfg
8)为nagios登录界面添加用户及密码
/usr/local/apache/bin/htpasswd –c /usr/local/nagios/etc/htpasswd nagios
9)修改/usr/local/nagios/etc/cgi.cfg
default_user_name=nagios
更改文件内的nagiosadmin为nagiosadmin,nagios
10)chmod 777 /usr/local/nagios/var/rw/nagios.cmd
chmod 777 /usr/local/nagios/var/rw
11)启动apache
/usr/local/apache/bin/apachectl start
通过http://192.168.1.12/nagios访问nagios
12)添加开机自启动
echo “/usr/local/apache/bin/apachectl start” >> /etc/rc.local
echo “/usr/local/nagios/bin/nagios –d /usr/local/nagios/etc/nagios.cfg” >> /etc/rc.local
http://www.monitoringexchange.org/cgi-bin/page.cgi?d=1
如缺少监控脚本可在此站下载
更为详细请看文档