本文原创,转载请注明出处:
http://teartao.iteye.com/blog/2173109
相关附件下载链接:
链接: http://pan.baidu.com/s/1pJODHvd 密码: ygs9(选中文本可见)
一、说明
nagios相关的说明,网上很多,这里不作赘述,网上很多教程中也有介绍,也可以下载官网的pdf,本文主要介绍nagios的简单工作原理、安装步骤以及安装过程中遇到的一些问题。
本文为个人学习记录,仅供参考,如有错误,还望批评指正
二、Nagios简单工作原理
nagios的监控分为监控端(Monitor Server)和被监控端(Remote Server)。监控端安装nagios core,它本身没有监控功能,在监控过程中nagios core仅为一个平台,或者说是一个环境,在nagios core环境下,通过安装各种各样的插件(nagios plugins)来实现对机器的监控。
nagios plugins 有的自带远程监控功能,有的只有本地监控的功能,这时,我们可以通过nrpe来实现对远程机进行监控,nrpe又分为check_nrpe插件 和nrpe daemon两部分,监控机安装check_nrpe,被监控机安装nrpe daemon。监控机执行check_nrpe向被监控机请求相应的监控信息,被监控机上的nrpe daemon来调用本地的nagios plugins对本机进行监控,并将监控结果返回给监控机。
详细工作原理及说明请自行百度、google、访问官网,资料很多
三、监控环境安装
1、监控机安装
1)nagios core安装
#用yum命令安装系统组建以满足插件的安装环境 yum install -y wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp #创建nagios用户、用户组,并将nagios加入到相应组 useradd nagios groupadd nagcmd usermod -a -G nagcmd nagios #进入下载的nagios core文件目录,解压文件,进入解压目录 #cd /home/taolei/copy/pkg/ #【nagios core install】 rm -rf nagios-4.0.8 tar zxvf nagios-4.0.8.tar.gz cd nagios-4.0.8 #编译安装 ./configure --with-command-group=nagcmd make all make install make install-init make install-config make install-commandmode make install-webconf #拷贝文件至nagios安装目录 rm -rf /usr/local/nagios/libexec/eventhandlers/ cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/ #改变文件夹属主,使nagios插件可以获得权限 chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers #nagios安装已完成,检查nagios配置文件正确性 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg #启动相关服务:nagios服务和apache的服务 /etc/init.d/nagios restart /etc/init.d/httpd restart #用apache的命令,创建web访问的用户及密码 htpasswd -bc /usr/local/nagios/etc/htpasswd.users nagiosadmin admin #此时可以在浏览器输入http://ip/nagios 登录nagios页面,通过登录认证后便可以查看nagios的监控情况了 #如:http://localhost/nagios
2)nagios plugins安装
监控机其实无需安装nagios plugins ,这里安装只是为了检测nagios core是否安装正确
进入安装包所在目录,解压并进入解压文件夹 cd /home/taolei/copy/pkg/ rm -rf nagios-plugins-2.0.3 tar zxvf nagios-plugins-2.0.3.tar.gz cd nagios-plugins-2.0.3 #编译安装nagios plugins ./configure --with-nagios-user=nagios --with-nagios-group=nagcmd make make install #为服务设置开机启动 chkconfig --add nagios chkconfig --level 35 nagios on chkconfig --add httpd chkconfig --level 35 httpd on
3)check_nrpe安装
用yum命令安装系统组建以满足插件的安装环境 yum -y install openssl-devel #cd /home/taolei/copy/pkg/ #进入安装包所在目录,解压并进入解压文件夹 rm -rf nrpe-2.15 tar zxvf nrpe-2.15.tar.gz cd nrpe-2.15 #编译安装 ./configure make all make install-plugin #开启防火墙端口,以便远程的被监控机访问(这里是为了本机测试使用) /sbin/iptables -I INPUT -p tcp -m tcp --dport 5666 -j ACCEPT #保存防火墙配置: /etc/rc.d/init.d/iptables save #重启防火墙 /etc/rc.d/init.d/iptables restart #通过监测命令测试check_nrpe插件检查插件版本来反映插件是否安装完成 #假设本监控机IP 192.168.52.132,被监控机(远程机)ip为192.168.52.131 #本机开启了防火墙的端口号可以通过如下命令检查本地插件版本 /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 #若已有远程机安装了nrpe daemon 则可以使用如下命令检查远程机nrpe版本 /usr/local/nagios/libexec/check_nrpe -H 192.168.52.131 #当返回了nrpe 版本信息时说明check_nrpe安装正确,若提示connect refused之类信息,则说明远程机#的nrpe防火墙或端口没开启,或有其它原因我没遇到过
2、被监控机安装
1)nagios plugins安装:同上
2)nrpe daemon安装
yum -y install openssl-devel xinetd chown nagios:nagios /usr/local/nagios chown -R nagios:nagios /usr/local/nagios/libexec tar zxvf nrpe-2.15.tar.gz cd nrpe-2.15 ./configure make all make install-plugin make install-daemon make install-daemon-config make install-xinetd #编辑/etc/xinetd.d/nrpe文件 nano /etc/xinetd.d/nrpe #在only_from 后面加上nagios core所在的监控机ip,与前一ip之间用空白隔开 #only_from = 127.0.0.1 <nagios_ip_address> ,如: #only_from = 127.0.0.1 129.168.52.132 #编辑/etc/services 文件 nano /etc/services #在其中加入NRPE端口的配置 nrpe 5666/tcp # NRPE #开启防火墙5666端口 /sbin/iptables -I INPUT -p tcp -m tcp --dport 5666 -j ACCEPT #保存防火墙配置: /etc/rc.d/init.d/iptables save #编辑nrpe.cfg文件 nano /usr/local/nagios/etc/nrpe.cfg #找到allowed_hosts = 127.0.0.1,在后面加入监控机的ip,如: allowed_hosts = 127.0.0.1,192.168.52.132
3、常见问题解决
【问题描述】按照NRPE官方安装文档的步骤安装nrpe daemon输入make all命令时,提示
make: *** No rule to make target `all'. Stop.
【解决方法】安装openssl-devel:yum -y install openssl-devel
重新执行./configure命令后,再执行make all命令,即可解决
【问题描述】按照官方文档步骤,输入/usr/local/nagios/libexec/check_nrpe -H localhost命令时,报错提示:CHECK_NRPE: Error - Could not complete SSL handshake.
【解决方法】将localhost也添加至/etc/xinetd.d/nrpe文件中的only_from=后面,即
only_from = 127.0.0.1 localhost
【问题描述】按照NRPE安装文档的步骤输入iptables -I RH-Firewall-1-INPUT -p tcp -m tcp –dport 5666 -j ACCEPT命令时报错
【解决方法】官方文档中上述命令书写有误,改为/sbin/iptables –I INPUT -p tcp -m tcp --dport 5666 -j ACCEPT 即可
check_linux_status.pl安装
【问题描述】make test报错Can't locate Time/HiRes.pm in @INC.....
【解决方法】yum -y install perl-Time-HiRes 安装perl相关插件
修改配置文件nrpe.cfg后需要重启nrpe,否则配置不会生效,重启方法如下
pkill nrpe; /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
相关推荐
Nagios监控平台之三:MRTG监控交换机流量
Centos环境安装LAMP环境和nagios程式部署
centos6.4系统环境下的nagios监控配置
nagios监控主机内存,监控主机开销,主机类型为linux
使用nagios监控mongoddb分片集群,开业python插件
主机监控:Nagios 可以监控服务器、路由器、交换机等网络设备。它检查主机的可用性、响应时间、资源利用率等,并生成报告以供管理员查看。 插件支持:Nagios 支持各种插件,这些插件可以根据需要添加到系统中。通过...
CentOS配置Nagios监控平台,监控Linux客户端,Windows客户端详细配置,以及如何设置微信报警
Nagios监控redis、MySQL插件,亲测可用。 不能用的可以加Q私聊
Nagios的配置过程:主机,主机组,服务,服务组,联系人,联系人组,监控时间,监控命令等,配置文件及配置项之间相互关联,彼此引用。
nagios监控交换机端口,MRTG监控交换机流量
nagios 监控服务器内存脚本,实时短信报警
nagios监控网卡流量插件 Total RX Bytes: 9671.37 MB, Total TX Bytes: 4099.41 MB Average Traffic: 0.00 kB/s (0.0%) in, 2.10 kB/s (0.0%) out| inUsage=0.0;80;100;; outUsage=0.0;80;100;;
本教程采用Open SuSE Linux为基础平台,用Nagios监控SQL数据库
nagios监控windows及linux机器,配置及安装
上一篇:Nagios服务端和客户端安装与配置 自定义监控脚本 要求: 创建cfg文件部署客户端下的监控,参考localhost.cfg,创建一个跟本地监控项一模一样的远程监控文件; 添加监控脚本,设计一个能监控nginx端口的脚本...
nagios监控主机安装手册
Nagios在Windows下的应用 图文并茂~非常好理解~
nagios监控windows64位插件
包含安装mysql监控的所有源码安装包,包含check_mysql_health-2.2.tar.gz、httpd-2.2.23.tar.gz、nagios-3.4.3.tar.gz、nagios-plugins-1.4.16.tar.gz、nrpe-2.15.tar.gz、php-5.4.10.tar.gz
redis自身的info可以读出自身的内存使用情况,通过config get可读出你所设置的内存最大值。故可通过这两点,对redis内存使用情况进行监控。以下脚本考虑了四种输出可能:正常,警告,严重警告