环境准备
yum install -y httpd php gcc glibc glibc-common gd gd-devel make net-snmp libxml2 libxml2-devel sqlite-devel
创建Nagios用户和Nagcmd组
useradd nagios && groupadd nagcmd
加入nagios和apache到nagcmd组
usermod -G nagcmd nagios && usermod -G nagcmd apache
下载Nagios Core 4.01 和Nagios Plugin 1.5
为Nagios创建文件夹:
mkdir /root/nagios && cd /root/nagios
下载安装包
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.1.tar.gz
解压编译安装
tar zxvf nagios-4.0.1.tar.gz && cd nagios ./configure --prefix=/usr/local/nagios

make all

make install

make install-init
make install-commandmode
make install-config


检查安装
chkconfig --add nagios && chkconfig --level 35 nagios on && chkconfig --list nagios

安装插件
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
tar -xvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure --prefix=/usr/local/nagios
make && make install

安装与配置Apache和Php
Apache 和Php 不是安装nagios 所必须的,但是nagios提供了web监控界面,通过web监控界面可以清晰的看到被监控主机、资源的运行状态,因此,安装一个web服务是很必要的。
需要注意的是,nagios在nagios3.1.x版本以后,配置web监控界面时需要php的支持。这里我们下载的nagios版本为nagios-3.4.3,因此在编译安装完成apache后,还需要编译php模块,这里选取的php版本为php5.4.10
wget http://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz tar zxvf httpd-2.2.23.tar.gz cd httpd-2.2.23 ./configure --prefix=/usr/local/apache2 make && make install

安装PHP
wget https://www.php.net/distributions/php-8.2.0.tar.gz
tar -xvf php-8.2.0.tar.gz
cd php-8.2.0
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs

make && make install

浙公网安备 33010602011771号