配置nagios客户端
创始人
2024-07-24 02:51:04
0

  配置nagios客户端

  一、客户端安装配置

  1、客户端安装:

  1.   wget http://blog.vlvtu.com/nrpe_install.zip  
  2.  
  3.   tar zxvf nrpe_install  
  4.  
  5.   cd nrpe_install  
  6.  
  7.   ./setup.sh  
  8.  

  2、添加启动项:

  1.   echo "/usr/local/nrpe/bin/nrpe -c /usr/local/nrpe/etc/nrpe.cfg -d" >> /etc/rc.d/rc.local  
  2.  

  3、启动:

  1.   /usr/local/nrpe/bin/nrpe -c /usr/local/nrpe/etc/nrpe.cfg -d  
  2.  

  4、检查:

  1.   tail -f /var/log/message  
  2.  
  3.   Oct 20 16:19:38 webhost2 nrpe[3782]: Starting up daemon  
  4.  
  5.   Oct 20 16:19:38 webhost2 nrpe[3782]: Listening for connections on port 5666  
  6.  
  7.   Oct 20 16:19:38 webhost2 nrpe[3782]: Allowing connections from: 127.0.0.1,192.168.1.11  
  8.  

  5、测试NEPE本地是否正常启动

  1.   /usr/local/nrpe/libexec/check_nrpe -H 192.168.1.11  
  2.  
  3.   NRPE v2.12  
  4.  

  6、防火墙配置方法:

 

  1.   iptables -A FORWARD -i eth0 -p tcp –dport 5666 -j ACCEPT  
  2.  

#p#

  二、在监控主机上配置NRPE的服务

  1.查看新扩展插件check_nrpe的使用方法

  1.   /usr/local/nagios/libexec/check_nrpe -h|less  
  2.  
  3.   Usage: check_nrpe -H [-n] [-u] [-p ] [-t ] [-c ]  
  4.  

  使用方式:check_nrpe -H 主机名 -p NRPE端口 -c NRPE命令名

  选项:

  1.    = The address of the host running the NRPE daemon  
  2.  

  主机,运行着NRPE守护进程的远程被监测主机名,并且该主机名必须在host里定义过。

  1.   [port] = The port on which the daemon is running (default=5666)  
  2.  

  端口,被监测的远程主机上运行NRPE的端口,默认是5666,如果是默认就不用指定。

  1.   [command] = The name of the command that the remote daemon should run  
  2.  

  命令,这些命令名必须是被监测主机上NRPE守护进程运行着的。

  查看监控服务器是否能和远程Linux 192.168.1.11正常通信。能正常通信返回 NRPE的版本号

  1.   /usr/local/nagios/libexec/check_nrpe -H 192.168.1.11  
  2.  

  2.在command.cfg命令定义文件中添加NRPE命令。

  1.   vi /usr/local/nagios/etc/commands.cfg  
  2.  
  3.   # NRPE Command  
  4.  

  最下方添加NRPE功能命令。

  1.   #check nrpe  
  2.  
  3.   define command{  
  4.  
  5.   command_name check_nrpe  
  6.  
  7.   command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$  
  8.  
  9.   }  
  10.  

  这里要说明几点:

  (1)这里定义的命令名就叫作nrpe。

  (2)$USER1$/check_nrpe会通过引用resource.cfg获得/usr/local/nagios/libexec/check_nrpe这个绝对路径。

  (3)-H $HOSTADDRESS$ 用来获得指定被监测主机的IP地址,$HOSTADDRESS$变量会通过定义主机名查找到host段中的IP地址。

  (4)-c $ARG1$ 用来指定被监测主机上NRPE守护进程运行着的NRPE命令名。

  3.在Nagios监控服务器上然后按照NRPE命令定义来添加NRPE远程监控主机和服务:

  hosts.cfg 添加定义主机

  1.   vi /usr/local/nagios/etc/object/hosts.cfg  
  2.  
  3.   define host {  
  4.  
  5.   host_name nagios-server  
  6.  
  7.   alias nagios server  
  8.  
  9.   address 202.96.155.155  
  10.  
  11.   contact_groups sagroup  
  12.  
  13.   check_command check-host-alive  
  14.  
  15.   max_check_attempts 3  
  16.  
  17.   notification_interval 10  
  18.  
  19.   notification_period 24×7  
  20.  
  21.   notification_options d,u,r  
  22.  
  23.   }  
  24.  
  25.   define host{  
  26.  
  27.   use linux-server  
  28.  
  29.   host_name test-cnname server  
  30.  
  31.   alias test-cnname server  
  32.  
  33.   address 202.96.155.155  
  34.  
  35.   contact_groups sagroup  
  36.  
  37.   check_command check-host-alive  
  38.  
  39.   max_check_attempts 3  
  40.  
  41.   notification_interval 10  
  42.  
  43.   notification_period 24×7  
  44.  
  45.   notification_options d,u,r  
  46.  
  47.   }  
  48.  

#p#

  测试配置文件

  1.   [root@app ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg  
  2.  

  ………………………………..

  1.   Checking services…  
  2.  
  3.   Checked 5 services.  
  4.  
  5.   Checking hosts…  
  6.  
  7.   Warning: Host '202.96.155.155' has no services associated with it!  
  8.  
  9.   Checked 2 hosts.  
  10.  
  11.   Checking host groups…  
  12.  
  13.   Total Warnings: 1  
  14.  
  15.   Total Errors: 0  
  16.  

  有一警告,没配置services.cfg

  1.   vi /usr/local/nagios/etc/objects/services.cfg  
  2.  
  3.   #address 192.168.1.11为远程Linux服务器的地址  
  4.  

  实现监控192.168.1.11服务器硬盘使用情况

  1.   vi /usr/local/nagios/etc/objects/services.cfg  
  2.  
  3.   define service{  
  4.  
  5.   host_name test-cnname server  
  6.  
  7.   service_description check-disk  
  8.  
  9.   check_command check_nrpe!check_df  
  10.  
  11.   max_check_attempts 4  
  12.  
  13.   normal_check_interval 3  
  14.  
  15.   retry_check_interval 2  
  16.  
  17.   check_period 24×7  
  18.  
  19.   notification_interval 10  
  20.  
  21.   notification_period 24×7  
  22.  
  23.   notification_options w,u,c,r  
  24.  
  25.   contact_groups sagroup  
  26.  
  27.   }  
  28.  

  通过这样的方法可以在hosts文件里添加更多的服务器

  运行如下命令。如果没有错误就可以重启Nagios 服务

  1.   /usr/local/nagios/bin/nagios –v /usr/local/ngaios/etc/nagios.cfg  
  2.  

  重启 Nagios Service 使配置生效

  1.   service nagios reload  

【编辑推荐】

配置Nagios监控Oracle服务器

Nagios监控系统搭建问题

Nagios监控全解-手机短信

相关内容

热门资讯

如何允许远程连接到MySQL数... [[277004]]【51CTO.com快译】默认情况下,MySQL服务器仅侦听来自localhos...
如何利用交换机和端口设置来管理... 在网络管理中,总是有些人让管理员头疼。下面我们就将介绍一下一个网管员利用交换机以及端口设置等来进行D...
施耐德电气数据中心整体解决方案... 近日,全球能效管理专家施耐德电气正式启动大型体验活动“能效中国行——2012卡车巡展”,作为该活动的...
Windows恶意软件20年“... 在Windows的早期年代,病毒游走于系统之间,偶尔删除文件(但被删除的文件几乎都是可恢复的),并弹...
20个非常棒的扁平设计免费资源 Apple设备的平面图标PSD免费平板UI 平板UI套件24平图标Freen平板UI套件PSD径向平...
德国电信门户网站可实时显示全球... 德国电信周三推出一个门户网站,直观地实时提供其安装在全球各地的传感器网络检测到的网络攻击状况。该网站...
为啥国人偏爱 Mybatis,... 关于 SQL 和 ORM 的争论,永远都不会终止,我也一直在思考这个问题。昨天又跟群里的小伙伴进行...
《非诚勿扰》红人闫凤娇被曝厕所... 【51CTO.com 综合消息360安全专家提醒说,“闫凤娇”、“非诚勿扰”已经被黑客盯上成为了“木...