Nagios利用NRPE监控Linux主机(1)(2)
4、定义服务
- [root@Nagios objects]# cp windows.cfg linhost.cfg
- [root@Nagios objects]# grep -v '^#' linhost.cfg |sed '/^$/d'
- define host{
- use linux-server
- host_name linhost
- alias My Linux Server
- address 192.168.0.81
- }
- define service{
- use generic-service
- host_name linhost
- service_description CHECK USER
- check_command check_nrpe!check_users
- }
- define service{
- use generic-service
- host_name linhost
- service_description Load
- check_command check_nrpe!check_load
- }
- define service{
- use generic-service
- host_name linhost
- service_description SDA1
- check_command check_nrpe!check_hda1
- }
- define service{
- use generic-service
- host_name linhost
- service_description Zombie
- check_command check_nrpe!check_zombie_procs
- }
- define service{
- use generic-service
- host_name linhost
- service_description Total procs
- check_command check_nrpe!check_total_procs
- }
这里重点说下,Nagios服务端定义服务的命令完全是根据被监控端NRPE中内置的监控命令,如下图所示
5、启动所定义的命令和服务
- [root@Nagios ~]# vim /usr/local/nagios/etc/nagios.cfg
- #增加一行
- cfg_file=/usr/local/nagios/etc/objects/linhost.cfg
6、配置文件语法检查
- [root@Nagios ~]# service nagios configtest
- Nagios Core 4.0.7
- Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
- Copyright (c) 1999-2009 Ethan Galstad
- Last Modified: 06-03-2014
- License: GPL
- Website: http://www.nagios.org
- Reading configuration data...
- Read main config file okay...
- Read object config files okay...
- Running pre-flight check on configuration data...
- Checking objects...
- Checked 20 services.
- Checked 3 hosts.
- Checked 2 host groups.
- Checked 0 service groups.
- Checked 1 contacts.
- Checked 1 contact groups.
- Checked 26 commands.
- Checked 5 time periods.
- Checked 0 host escalations.
- Checked 0 service escalations.
- Checking for circular paths...
- Checked 3 hosts
- Checked 0 service dependencies
- Checked 0 host dependencies
- Checked 5 timeperiods
- Checking global event handlers...
- Checking obsessive compulsive processor commands...
- Checking misc settings...
- Total Warnings: 0
- Total Errors: 0
- Things look okay - No serious problems were detected during the pre-flight check
- Object precache file created:
- /usr/local/nagios/var/objects.precache
7、重新启动nagios服务
- [root@Nagios ~]# service nagios restart
- Running configuration check...
- Stopping nagios: done.
- Starting nagios: done.
8、打开Nagios web监控页面
1)首先点击Hosts】查看监控主机状态是否为UP
2)其次点击Services】查看各监控服务的状态是否为OK
注意:在监控新添加的主机linhost;出现状态为CRITICAL,提示没有那个文件或目录。下面是解决办法
在监控Linhost主机时出现一个CRITICAL的警告,查找解决办法
- ###被监控端修改NRPE配置文件并重启NRPE服务
- [root@ClientNrpe etc]# vim nrpe.cfg
- command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1
- [root@ClientNrpe etc]# service nrped restart
- ###监控端修改linhost.cfg配置文件并重启nagios和httpd服务
- [root@Nagios objects]# vim linhost.cfg
- #注释:原来这里是hda1,现在修改成sda1
- define service{
- use generic-service
- host_name linhost
- service_description SDA1
- check_command check_nrpe!check_sda1
- }
- [root@Nagios ~]# service nagios restart
- Running configuration check...
- Stopping nagios: done.
- Starting nagios: done.
- [root@Nagios ~]# service httpd restart
- 停止 httpd: [确定]
- 正在启动 httpd: [确定]
再次点击services】即为刷新页面,查看如下图所示:
博文出自:http://467754239.blog.51cto.com/4878013/1558897
评论暂时关闭