一、编译安装Nagios
下载:http://www.nagios.org/download
1.安装所需要的软件包
yum -y install gd gd-devel libpng libpng-devel libjpeg libjpeg-devel zlib zlib-devel httpd php php-devel
2.解压编译核心
[[email protected] ~]# useradd nagios
[[email protected] ~]# usermod -G nagios apache
[[email protected] ~]# tar zxvf nagios-3.2.3.tar.gz
[[email protected] ~]# cd nagios-3.2.3
[[email protected] nagios-3.2.3]# ./configure --prefix=/usr/local/nagios \
--with-nagios-user=nagios --with-nagios-group=nagios
[[email protected] nagios-3.2.3]# make all
[[email protected] nagios-3.2.3]# make install
[[email protected] nagios-3.2.3]# make install-init   #建立启动nagios脚本
[[email protected] nagios-3.2.3]# make install-commandmode  #修改配置文件权限
[[email protected] nagios-3.2.3]# make install-config   #安装实例配置文件
[[email protected] nagios-3.2.3]# make install-webconf  #安装web接口
[[email protected] ~]# chkconfig nagios on
 
2.编译安装nagios插件
[[email protected] ~]# tar zxvf nagios-plugins-1.4.15.tar.gz
[[email protected] ~]# cd nagios-plugins-1.4.15
[[email protected] nagios-plugins-1.4.15]# ./configure --prefix=/usr/local/nagios
[[email protected] nagios-plugins-1.4.15]# make && make install
安装完成后,在/usr/local/nagios/libexec建立许多插件
 
3. 编译安装nagios中文插件(非必须)
[[email protected] ~]# tar jxvf nagios-cn-3.2.3.tar.bz2
[[email protected] ~]# cd nagios-cn-3.2.3
[[email protected] nagios-cn-3.2.3]# ./configure --prefix=/usr/local/nagios/
[[email protected] nagios-cn-3.2.3]# make all
[[email protected] nagios-cn-3.2.3]# make install
 
4.使用htpasswd创建密码验证文件
[[email protected] ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
输入两次密码后,就建立完成
 
5.测试
[[email protected] ~]# /etc/init.d/nagios start
[[email protected] ~]# /etc/init.d/httpd restart
使用浏览器打开:http://ip/nagios/
Nagios安装与配置
 
二、安装nrpe
[[email protected] ~]# yum -y install xinetd
[[email protected] ~]# tar zxvf nrpe-2.13.tar.gz
[[email protected] ~]# cd nrpe-2.13
[[email protected] nrpe-2.13]# ./configure --prefix= /usr/local/nagios
[[email protected] nrpe-2.13]# make all
[[email protected] nrpe-2.13]# make install-plugin
[[email protected] nrpe-2.13]# make install-daemon
[[email protected] nrpe-2.13]# make install-daemon-config
[[email protected] nrpe-2.13]# make install-xinetd
 
配置nrpe,增加以下行:
[[email protected] ~]# vim /etc/services
nrpe                    5666/tcp                 #nrpe
 
在/usr/local/nagios/etc/objects/command.cfg中加入:

  1. #'check_nrpe'command definition 
  2. define command{ 
  3. command_name check_nrpe 
  4. command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ 
[[email protected] ~]# /etc/init.d/xinetd start
[[email protected] ~]# chkconfig xinetd on
 
安装完成。。。
 
错误: 无法打开要更新的命令文件。
外部命令文件或目录权限不对,参考FAQ设置正确的权限
提交命令时出错
解决: chmod a+w /usr/local/nagios/var/rw/nagios.cmd