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即可
三、下载nagios:
现在nagios版本和客户端插件地址如下:
wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.1/nagios-3.2.1.tar.gz/download
wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download
wget http://jaist.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.13/nrpe-2.13.tar.gz
创建用户维护Nagios的用户和组
useradd nagios
passwd nagios
四、在服务器端,安装Nagios和nrpe、nagios插件:
安装Nagios
tar zxvf nagios-3.2.1.tar.gz
cd nagios-3.2.1
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
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-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
安装nrpe
tar -xzf nrpe-2.13.tar.gz && cd nrpe-2.13 &&./configure --enable-ssl --with-ssl-lib &&make all && make install-plugin && make install-daemon && make install-daemon-config
chown -R nagios:nagios /usr/local/nagios/
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d 启动nrpe服务
五、创建web 访问用户:
增加访问控制验证用户:(第一次创建时要加参数c)
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
nagios安装完毕,然后重启apache,重启nagios,/etc/init.d/nagios restart
访问:http://localhost/nagios/ 即可! 即可访问到nagios最初安装界面
六、在客户端安装nrpe、nagios-plugin:
首先下载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 install
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-plugin && 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
保存即可!
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com