最新消息:

Nagios 监控平台安装

Linux知识总结 admin 2805浏览 0评论

Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。

一、 首先安装apache:
安装apache,采用yum方式安装,安装的命令是yum install –y httpd
安装完apache后,启动apache命令/etc/init.d/httpd restart 即可!

二、 安装php
Nagios是基于php语音编写的程序,所以需要安装php,也采用yum方式安装
Yum install php php-devel -y即可

三、 整合apache和php
在apache的配置文件httpd.conf里面添加AddType application/x-httpd-php .php 然后在index.html 前面添加index.php 即可!
四、 安装nagios
现在nagios版本和客户端插件地址如下:
wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz/download

http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download

创建用户维护Nagios的用户和组
/usr/sbin/useradd nagios
passwd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios

五、安装Nagios和插件
安装Nagios
#tar zxvf nagios-3.3.1.tar.gz
#cd nagios
#./configure –prefix=/usr/local/nagios –with-command-group=nagcmd
#make all
#make install //来安装主程序,CGI和HTML文件
#make install-init //在/etc/rc.d/init.d安装启动脚本
#make install-config //来安装示例配置文件,安装的路径是/usr/local/nagios/etc
#make install-commandmode //来配置目录权限
#make install-webconf // 配置nagios跟apache整合
安装Nagios-plugins
#tar zxvf nagios-plugins-1.4.15.tar.gz
#cd nagios-plugins-1.4.15
#./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-group=nagios
#make && make install

六、主要修改apache配置文件httpd.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

增加访问控制验证用户:(第一次创建时要加参数c)
htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin

nagios安装完毕,然后重启apache,访问:
http://localhost/nagios/ 即可!

7、安装nrpe客户端:
首先下载nagios-plugins-1.4.15.tar.gz和nrpe-2.13.tar.gz,执行如下脚本即可
#!/bin/sh
###auto make install nagios_plugin and nrpe
useradd nagios
tar -xzf nagios-plugins-1.4.15.tar.gz &&cd nagios-plugins-1.4.15 &&./configure –prefix=/usr/local/nagios &&make &&make insta
ll

sleep 2

echo “This is make install nrpe ,please waiting ………………”
cd ../ ; tar -xzf nrpe-2.13.tar.gz && cd nrpe-2.13 &&./configure –enable-ssl –with-ssl-lib &&make all && make install-plugi
n && make install-daemon && make install-daemon-config

chown -R nagios:nagios /usr/local/nagios/
cd .. ;cp nrpe.cfg /usr/local/nagios/etc/nrpe.cfg

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

###Add auto start
grep “nrpe” /etc/rc.local

if [ $? -ne 0 ];then
echo “/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d” >>/etc/rc.local
else
echo “nrpe is exist”
fi
保存即可!

转载请注明:爱开源 » Nagios 监控平台安装

您必须 登录 才能发表评论!