1. 监控原理
监控方式有两种,一种是利用ssh方式,执行Nagios的check_by_ssh来执行被监控服务器上的插件程序,从而获取相关的信息。但是这种方式,当运用于监控上百台服务器时,由于ssh连接的建立和中断,会对Nagios服务器产生高负载现象,所以不建议使用。它的优点在安全性高与采用NRPE的插件方式。 另外一种方式,是常用的方式。就是在被监控的Linux/Unix的服务器上安装NRPE监控引擎,然后Nagios服务器通过check_nrpe的程序,利用ssl通讯模式调用nrpe获取相关数据信息。优点包括可以使用Nagios的大多数监控插件。处理可以监控自身的状态变化,还可以拓展应用监控其它服务器的开放服务。 Linux/Unix服务器的内部参数包括以下 外部监控内容,可以使用Nagios的监控插件,监控其他的服务器开放的服务。起到间接监控的作用或者说是代理监控。 配置环境 ubuntu 8.0 b.远程主机配置 useradd nagios password nagios 下载地址 http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.6.tar.gz tar xzvf nagios-plugins-1.4.6.tar.gz cd nagios-plugins-1.4.6 ./configura make make install chown nagios.nagios /usr/local/nagios chown -R nagios.nagios /usr/local/nagios/libexec c.安装NRPE tar -zxvf nrpe-2.8.tar.gz ./configure 注意事项: 在ubuntu下面安装时,需要先确认安装了openssl libssl0.9.8 libssl-dev make install-plugin make install-xinetd only_from= 127.0.0.1 service xinetd restart d. 测试NRPE是否正常 netstat -at |grep nrpe 如果反馈的是以下信息,则表示运行正常。 tcp 0 0 *:nrpe *:* LISTEN 没有出现以上信息,则从下面找问题 /usr/local/nagios/libexec/check_nrpe -H localhost 正常反馈信息为 NRPE v2.8 e.客制化NRPE指令 编辑/usr/local/nagios/etc/nrpe.cfg 在最后的COMMAND部分已经定义了部分监测的指令,你可以根据实际情况进行添加修改参数。 同时,可以用以下指令检测nrpe调用nagios插件是否正常 /usr/local/nagios/libexec/check_nrpe -H localhost -c check_users f.监控服务器设置 安装ssl的包 apt-get install libssl-dev 下载nrpe源码包 解压缩该包 tar -zxvf nrpe-2.*.tar.gz cd nrpe-2.* ./configure make all 安装check_nrpe程序到/usr/local/nagiso/libexec/ make install-plugin 先编辑被监控主机的/etc/xinetd.d/nrpe中的only_from的参数为监控服务器的ip 重新启动xinetd的服务 service xinetd restart 在监控服务器上,运行 /usr/local/nagios/libexec/check_nrpe -H 被监控主机IP 正常反馈信息如下: NRPE v2.8 如果有问题,用telnet IP地址 5666检测一下。如果被直接connection closed,则需要查看一下防火墙的规则和被监测主机的nrpe的进程 编辑/usr/local/nagios/etc/objects/commands.cfg增加以下配置信息 define command{ 先建立一个模板用于之后的主机监控的继承设定(在/usr/local/nagios/etc/objects/templates.cfg已经有添加了这个模板规则,只是notification_period不一样而已,关于这个的解释也非常有意思可以自己看看) define host{ 编辑/usr/local/nagios/etc/objects/localhost.cfg(也可以自己创建文件,只要在nagios.cfg中添加对应配置) 增加被监控的主机对象 define host{ 增加监控远程服务器的服务对象 define service{ define service{ #磁盘监控需要确认自己的硬盘是hda 还是sda,nrpe安装的默认配置是check_hda1,所以需要你手动修改被监控服务器的/usr/local/nagios/etc/nrpe.cfg,将hda修改为sda。并重新启动xinetd服务 define service{ define service{ define service{ 配置完成后,运行/etc/init.d/nagios checkconfig 或 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 检测nagios配置是否正确。 没有问题,重新启动nagios服务,则可以通过网页来查看监控结果了。 由于前面的服务是nrpe主机上的默认建立的样例规则。如果手动建立服务监控需要做以下操作 a.被监控主机的配置内容 在/usr/local/nagios/libexec下,有很多监控插件。在写入nrpe.cfg前,先用指令测试这个插件和参数所产生的结果是否符合要求 例如 /usr/local/nagios/libexec/check_swap -w 20% -c 10% ‘监控swap的使用状况 编辑/usr/local/nagios/etc/nrpe.cfg 添加一行 command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10% 然后重新启动xinetd服务 b.Nagios服务的配置内容 编辑/usr/local/nagios/etc/objects/localhost.cfg 添加以下内容 service{ use generic_service hostname web_server service_description swap status check_command check_nrpe!check_swap } 然后重新启动nagios服务,这个新的监控服务就完成创建了。
a.前提条件
make all
make install-daemon
make install-daemon-config
nrpe 5666/tcp
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_hda1
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_total_procs
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_zombie_procs
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
name linux-server ; Name of this template
use generic-host ; Inherit default values
check_period 24x7
check_interval 5
retry_interval 1
max_check_attempts 10
check_command check-host-alive
notification_period 24x7
notification_interval 30
notification_options d,r
contact_groups admins
register 0 ; DONT REGISTER THIS - ITS A TEMPLATE
}
use linux-server
host_name web-server ;nrpe check host
alias ubuntu server (WWW)
address 192.168.200.244
}
use generic-service
host_name web-server
service_description CPU Load
check_command check_nrpe!check_load
}
use generic-service
host_name web-server
service_description Current Users
check_command check_nrpe!check_users
}
use generic-service
host_name web-server
service_description /dev/sda1 Free Space
check_command check_nrpe!check_sda1
}
use generic-service
host_name web-server
service_description Total Processes
check_command check_nrpe!check_total_procs
}
use generic-service
host_name web-server
service_description Zombie Processes
check_command check_nrpe!check_zombie_procs
}
4.自定义监控服务
ubuntu系统
原创
©著作权归作者所有:来自51CTO博客作者jasonlk的原创作品,请联系作者获取转载授权,否则将追究法律责任
下一篇: RPE的安装配置

提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
66、ubuntu系统下,文字转语音测试代码
基本思想:chatgpt4的实践,真的很厉害,也不用百度、google搜索了~
ubuntu linux 运维 人工智能 #include -
ubuntu系统
ubuntu系统
Nagios ubuntu ssh 休闲 系统监控 -
基于ubuntu开发版 ------渗透测试,审计取证类系统
基于ubuntu 渗透测试,审计取证类系统
测试 ubuntu 取证 -
配置ubuntu系统
在虚拟机中安装 Ubuntu步骤安装前的准备和基本安装设置语言环
ubuntu linux 服务器 python -
ubuntu分区方案(纯ubuntu系统)
ubuntu分区方案(纯ubuntu系统)首先,基本配置是:512G SDD +2T 机械 ,内存 64G大神推
ubuntu linux 数据 ubuntu系统 -
Ubuntu 系统下载
http://cdimage.ubuntu.com/ubuntukylin/releases/
ubuntu kylin 其他