Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设备,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的邮件或短信通知。
本文在Red Hat Enterprise Linux Server release 6.7上部署安装nagios-4.2.0,系统采用最小安装,安装前关闭防火墙,关闭selinux。为便于区分,以下每条命令后边都加了分号。
1.Prerequisites,准备环境;yum安装安装需要的相关包,加上依赖大概有45个包,耐心安装
yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp unzip;
2.Download Nagios Core and Nagios Plugins Tarballs,下载软件包到/tmp目录下
cd /tmp ;
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.0.tar.gz ;
wget http://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz;
3.添加Nagios用户和组
useradd nagios;
groupadd nagcmd;
usermod -a -G nagios,nagcmd apache;
4.Nagios Core 安装
解包-编译-安装-启动
cd /tmp ;
tar zxf nagios-4.2.0.tar.gz ;
tar zxf nagios-plugins-2.1.2.tar.gz;
./configure --with-command-group=nagcmd;
make all;
make install;
make install-init;
make install-config;
make install-commandmode;
make install-webconf;
/etc/init.d/nagios start;
/etc/init.d/httpd start;
5.创建web访问的默认用户,不然没法访问,默认用户为nagiosadmin,设置一个密码即可
htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin;
6.Nagios Plugin安装
cd /tmp/nagios-plugins-2.1.2;
./configure --with-nagios-user=nagios --with-nagios-group=nagios;
make;
make install;
7.服务设置开机自启动
chkconfig --add nagios;
chkconfig --level 35 nagios on;
chkconfig --add httpd;
chkconfig --level 35 httpd on;
8.网页访问,查看效果,默认检测本机。访问地址:http://<your's ip>/nagios,用户名为nagiosadmin,密码为第五步设置的密码。效果如下:
原文链接:Nagios监控系统,转载请注明来源!