Linux下Nagios安装配置详解(3)

在Nagios的默认配置文件下是没有Linux的配置文件所以如果是用于监控Linux主机,需要自行定义写配置文件,在此就用简单的写了一个Linux下使用的模板:
[root@linuxidc nagios]# vim objects/linux.cfg
define host{
        use            linux-server
        host_name      linuxhost
        alias          My linux Server
        address        192.168.218.129    ;这里填被监控主机的IP
        }
 
define service{
        use                    generic-service
        host_name              linuxhost
        service_description    CHECK_USERS
        check_command          check_nrpe!check_users
        }
 
define service{
        use                    generic-service
        host_name              linuxhost
        service_description    CHECK_LOAD
        check_command          check_nrpe!check_load
        }
 
define service{
        use                    generic-service
        host_name              linuxhost
        service_description    CHECK_SDA1
        check_command          check_nrpe!check_sda1
        }
 
define service{
        use                    generic-service
        host_name              linuxhost
        service_description    CHECK_ZOMBIE_PROCS
        check_command          check_nrpe!check_zombie_procs
        }
 
define service{
        use                    generic-service
        host_name              linuxhost
        service_description    CHECK_TOTAL_PROCS
        check_command          check_nrpe!check_total_procs
        }
[root@linuxidc nagios]# chown nagios:nagios linux.cfg#修改下配置文件的属组

在linux.cfg配置文件修改好后还需要 在nagios.cfg添加环境变量:
[root@linuxidc nagios]# vim nagios.cfg
…略…
cfg_file=/etc/nagios/objects/linux.cfg
…略…

正在修改后可以用Nagios的配置文件验证检查
[root@linuxidc nagios]# /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg
Nagios Core 4.3.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 02-23-2017
License: GPL
 
Website: https://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 13 services.
        Checked 2 hosts.
        Checked 1 host groups.
        Checked 0 service groups.
        Checked 1 contacts.
        Checked 1 contact groups.
        Checked 25 commands.
        Checked 5 time periods.
        Checked 0 host escalations.
        Checked 0 service escalations.
Checking for circular paths...
        Checked 2 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
[root@linuxidc nagios]# /etc/init.d/nagios restart

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/cefb0d80e53d2eff864ef9af069af7a5.html