一、编译安装Nagios
下载:http://www.nagios.org/download
中文插件: http://sourceforge.net/projects/nagios-cn/files/
1.安装所需要的软件包
yum -y install gd gd-devel libpng libpng-devel libjpeg libjpeg-devel zlib zlib-devel httpd php php-devel
2.解压编译核心
[root@nagios ~]# useradd nagios
[root@nagios ~]# usermod -G nagios apache
[root@nagios ~]# tar zxvf nagios-3.2.3.tar.gz
[root@nagios ~]# cd nagios-3.2.3
[root@nagios nagios-3.2.3]# ./configure --prefix=/usr/local/nagios \
--with-nagios-user=nagios --with-nagios-group=nagios
[root@nagios nagios-3.2.3]# make all
[root@nagios nagios-3.2.3]# make install
[root@nagios nagios-3.2.3]# make install-init #建立启动nagios脚本
[root@nagios nagios-3.2.3]# make install-commandmode #修改配置文件权限
[root@nagios nagios-3.2.3]# make install-config #安装实例配置文件
[root@nagios nagios-3.2.3]# make install-webconf #安装web接口
[root@nagios ~]# chkconfig nagios on
2.编译安装nagios插件
[root@nagios ~]# tar zxvf nagios-plugins-1.4.15.tar.gz
[root@nagios ~]# cd nagios-plugins-1.4.15
[root@nagios nagios-plugins-1.4.15]# ./configure --prefix=/usr/local/nagios
[root@nagios nagios-plugins-1.4.15]# make && make install
安装完成后,在/usr/local/nagios/libexec建立许多插件
3. 编译安装nagios中文插件(非必须)
[root@nagios ~]# tar jxvf nagios-cn-3.2.3.tar.bz2
[root@nagios ~]# cd nagios-cn-3.2.3
[root@nagios nagios-cn-3.2.3]# ./configure --prefix=/usr/local/nagios/
[root@nagios nagios-cn-3.2.3]# make all
[root@nagios nagios-cn-3.2.3]# make install
4.使用htpasswd创建密码验证文件
[root@nagios ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
输入两次密码后,就建立完成
5.测试
[root@nagios ~]# /etc/init.d/nagios start
[root@nagios ~]# /etc/init.d/httpd restart
使用浏览器打开: http://ip/nagios/
二、安装nrpe
[root@nagios ~]# yum -y install xinetd
[root@nagios ~]# tar zxvf nrpe-2.13.tar.gz
[root@nagios ~]# cd nrpe-2.13
[root@nagios nrpe-2.13]# ./configure --prefix= /usr/local/nagios
[root@nagios nrpe-2.13]# make all
[root@nagios nrpe-2.13]# make install-plugin
[root@nagios nrpe-2.13]# make install-daemon
[root@nagios nrpe-2.13]# make install-daemon-config
[root@nagios nrpe-2.13]# make install-xinetd
配置nrpe,增加以下行:
[root@nagios ~]# vim /etc/services
nrpe 5666/tcp #nrpe
在/usr/local/nagios/etc/objects/command.cfg中加入:
#'check_nrpe'command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
[root@nagios ~]# /etc/init.d/xinetd start
[root@nagios ~]# chkconfig xinetd on
安装完成。。。
错误:无法打开要更新的命令文件。
外部命令文件或目录权限不对,参考
FAQ
设置正确的权限
提交命令时出错
解决: chmod a+w /usr/local/nagios/var/rw/nagios.cmd