一、Nginx介绍
Nagios是一款开源的网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知运维人员,在状态恢复后发出正常的邮件或短信通知。
Nagios原名为NetSaint,由Ethan Galstad开发并维护至今。NAGIOS是一个缩写形式:“Nagios Ain't Gonna Insist On Sainthood” Sainthood翻译为圣徒,而"Agios"是"saint"的希腊表示方法。Nagios被开发在Linux下使用,但在Unix下也工作得非常好。
二、主要功能介绍
•网络服务监控(SMTP、POP3、HTTP、NNTP、ICMP、SNMP、FTP、SSH)
•主机资源监控(CPU load、disk usage、system logs),也包括Windows主机(使用NSClient++ plugin)
•可以指定自己编写的Plugin通过网络收集数据来监控任何情况(温度、警告……)
•可以通过配置Nagios远程执行插件远程执行脚本
•远程监控支持SSH或SSL加通道方式进行监控
•简单的plugin设计允许用户很容易的开发自己需要的检查服务,支持很多开发语言(shell scripts、C++、Perl、ruby、Python、PHP、C#等)
•包含很多图形化数据Plugins(Nagiosgraph、Nagiosgrapher、PNP4Nagios等)
•可并行服务检查
•能够定义网络主机的层次,允许逐级检查,就是从父主机开始向下检查
•当服务或主机出现问题时发出通告,可通过email, pager, sms 或任意用户自定义的plugin进行通知
•能够自定义事件处理机制重新激活出问题的服务或主机
•自动日志循环
•支持冗余监控
•包括Web界面可以查看当前网络状态,通知,问题历史,日志文件等
三、Naginx工作原理
Nagios的所有的监控、检测功能都是通过各种插件来完成的(比如NRPE)。报警功能是用户自定义阈值
Nagios 通过NRPE 来远端管理服务
1. Nagios 执行安装在它里面的check_nrpe 插件,并告诉check_nrpe 去检测哪些服务。
2. 通过SSL,check_nrpe 连接远端机子上的NRPE daemon
3. NRPE 运行本地的各种插件去检测本地的服务和状态(check_disk,..etc)
4. 最后,NRPE 把检测的结果传给主机端的check_nrpe,check_nrpe 再把结果送到Nagios状态队列中。
5. Nagios 依次读取队列中的信息,再把结果显示出来。
下面就来介绍下Nrpe的安装
四、安装nrpe客户端:
[root@svr1 ~]# useradd nagios
[root@svr1 ~]# tar -xzf nagios-plugins-1.4.15.tar.gz
[root@svr1 ~]# cd nagios-plugins-1.4.15
[root@svr1 nagios-plugins-1.4.15]# ./configure
[root@svr1 nagios-plugins-1.4.15]# make && make install
[root@svr1 ~]# tar -xzf nrpe-2.12.tar.gz
[root@svr1 ~]# cd nrpe-2.12
[root@svr1 nrpe-2.12]# ./configure
*** Configuration summary for nrpe 2.12 03-10-2008 ***:
General Options:
-------------------------
NRPE port: 5666
NRPE user: nagios
NRPE group: nagios
Nagios user: nagios
Nagios group: nagios
[root@svr1 nrpe-2.12]# make all && make install-plugin
cd ./src/ && make install-plugin
make[1]: Entering directory `/root/nrpe-2.12/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios check_nrpe /usr/local/nagios/libexec
make[1]: Leaving directory `/root/nrpe-2.12/src'
[root@svr1 nrpe-2.12]# make install-daemon
cd ./src/ && make install-daemon
make[1]: Entering directory `/root/nrpe-2.12/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/bin
/usr/bin/install -c -m 775 -o nagios -g nagios nrpe /usr/local/nagios/bin
make[1]: Leaving directory `/root/nrpe-2.12/src'
[root@svr1 nrpe-2.12]# make install-daemon-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc
[root@svr1 nrpe-2.12]# make install-xinetd
/usr/bin/install -c -m 644 sample-config/nrpe.xinetd /etc/xinetd.d/nrpe
[root@svr1 nrpe-2.12]# vim /etc/xinetd.d/nrpe
# default: on
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
flags = REUSE
socket_type = stream
port = 5666
wait = no
user = nagios
group = nagios
server = /usr/local/nagios/bin/nrpe
server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd
log_on_failure += USERID
disable = no
only_from = 10.1.1.40
}
[root@svr1 nrpe-2.12]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@svr1 nrpe-2.12]# chkconfig --list | grep nrpe
nrpe: on
[root@svr1 nrpe-2.12]# netstat -tnlp | grep nrpe
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 25360/nrpe
修改Nrpe配置文件
[root@svr1 nrpe-2.12]# vim /usr/local/nagios/etc/nrpe.cfg
修一行:
allowed_hosts=127.0.0.1,10.1.1.40
本机测试!
[root@svr1 nrpe-2.12]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
[root@svr1 nrpe-2.12]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
OK - load average: 0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0; load5=0.000;10.000;25.000;0;
load15=0.000;5.000;20.000;0;
备注:有时候在客户端本机上测试时,发现会报错。CHECK_NRPE: Error - Could not complete SSL handshake.
这个时候,注意下xinetd.d/nrpe 以及nrpe.conf 里关于allowed相关的选项,另外就是防火墙。
使用xinetd后发现重启xinetd并不能重启nrpe,只有将其 T掉然后再开。
从远程主机上测试下:
[root@svr4 ~]# /usr/local/nagios/libexec/check_nrpe -H 10.1.1.10 -c check_total_procs
PROCS CRITICAL: 249 processes
- QQ精品交流群
-
- 微信公众号
-