nagios需要依赖lamp环境,全部我们先在nagios服务器上安装配置lamp环境。
[root@pc1 ~]# yum -y install httpd php* mariadb*
解压干系软件
[root@pc1 ~]# cd /root/桌面
[root@pc1 ~]# tar -zxvf nagios-4.0.1.tar.gz -C /usr/src
[root@pc1 ~]# tar -zxvf nagios-plugins-1.5.tar.gz -C /usr/src
[root@pc1 ~]# tar -zxvf nrpe-2.15.tar.gz -C /usr/src
2、安装依赖环境
yum -y install openssl-devel
3、编译安装nagois
[root@localhost ~]# useradd -M -s /sbin/nologin nagios
[root@localhost ~]# mkdir /usr/local/nagios
[root@localhost ~]# chown -R nagios:nagios /usr/local/nagios/
[root@localhost ~]# cd /usr/src/nagios-4.0.1/ 配置编译环境
[root@pc1 nagios-4.0.1]# yum -y install gcc*
[root@localhost nagios-4.0.1]# ./configure --prefix=/usr/local/nagios
编译安装
[root@localhost nagios-4.0.1]# make all
[root@localhost nagios-4.0.1]# make install
[root@localhost nagios-4.0.1]# make install-init
[root@localhost nagios-4.0.1]# make install-commandmode
[root@localhost nagios-4.0.1]# make install-config
make install #安装主程序,CGI和HTML文件
make install-init #在/etc/rc.d/init.d安装启动脚本
make install-commandmode #安装command模板
make install-config #安装示例配置文件
6、编译安装nagios-plugins:
[root@localhost nagios-4.0.1]# cd /usr/src/nagios-plugins-1.5
[root@pc1 nagios-plugins-1.5]# ./configure --prefix=/usr/local/nagios
[root@pc1 nagios-plugins-1.5]# make && make install
7、编译安装nrpe:
[root@pc1 nagios-plugins-1.5]# cd /usr/src/nrpe-2.15/
[root@pc1 nrpe-2.15]# ./configure && make all
[root@pc1 nrpe-2.15]# make install-plugin
8、配置httpd.conf
添加nagios的访问界面
[root@pc1 nrpe-2.15]# vim /etc/httpd/conf/httpd.conf
在末了面添加:
ScriptAlias /nagios/cgi-bin/ "/usr/local/nagios/sbin/"
<Directory "/usr/local/nagios/sbin">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
9、设置页面访问认证:
[root@localhost ~]# vim /usr/local/nagios/etc/cgi.cfg
修改:
[root@localhost ~]# yum -y install openssl openssl-devel gcc*
[root@localhost ~]# useradd -M -s /sbin/nologin nagios
安装nagios-plugins
[root@localhost ~]# cd /root/桌面
[root@localhost ~]# tar -zxvf nagios-plugins-1.5.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/nagios-plugins-1.5/
[root@localhost nagios-plugins-1.5]# ./configure --prefix=/usr/local/nagios
[root@localhost nagios-plugins-1.5]# make && make install
[root@localhost nagios-plugins-1.5]# chown -R nagios:nagios /usr/local/nagios/
3、安装nrpe
[root@localhost ~]# tar -zxvf /root/桌面/nrpe-2.15.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/nrpe-2.15/
[root@localhost nrpe-2.15]# ./configure --prefix=/usr/local/nagios/
[root@localhost nrpe-2.15]# make all
[root@localhost nrpe-2.15]# make install-plugin
[root@localhost nrpe-2.15]# make install-daemon
[root@localhost nrpe-2.15]# make install-daemon-config
4、配置
[root@localhost nrpe-2.15]# vim /usr/local/nagios/etc/nrpe.cfg
修改: