温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Nagios(三)——监控外部信息(主机、服务)

发布时间:2020-07-19 08:22:20 来源:网络 阅读:913 作者:筑梦攻城狮 栏目:移动开发

       Nagios 对主机的监控分为2种,像服务,端口,ping之类的监控属于外部信息监控;像内存,磁盘,swap这些信息的监控属于内部信息监控。外部信息监控可以通过安装Nagios 插件补丁来实现例如check_ping ;内部信息监控则需要通过NRPE 插件来实现,其原理为:客户机NRPE插件收集相关信息,服务端通过check_nrpe 来采集相关信息,并做相关处理。

        一、监控外部信息

        监控外部信息,只需要参照Nagios(二) 将Nagios 服务搭建起来,并且配置好欲监控的主机和服务即可。


1. 配置hosts.cfg
[root@server ~]# vim /usr/local/nagios/etc/hosts.cfg
define host{
        use     linux-server
        host_name       node-1
        alias           lamp
        address         192.168.30.110
}

2. 配置services.cfg
[root@server etc]# vim services.cfg
define service{
        use     generic-service
        host_name       node-1
 service_description     ping
        check_command   check_ping!100.0,20%!500.0,60%
        max_check_attempts 5
        normal_check_interval 1
}
define service{
        use     generic-service
        host_name       node-1
 service_description     tcp
        check_command   check_tcp!22
        max_check_attempts 5
        normal_check_interval 1
}
define service{
        use     generic-service
        host_name       node-1
 service_description     http
        check_command   check_http
        max_check_attempts 5
        normal_check_interval 1
}

3.将services.cfg和hosts.cfg 引用进nagios

[root@server ~]# vim /usr/local/nagios/etc/nagios.cfg

cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/services.cfg

4.用nagios自带的检查命令检查其配置是否正确
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

注意:由于这条命令较长而且使用的频率也较高,所以可以通过以下的方法快捷的运用
[root@server ~]# vim .bashrc
alias check='/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg'

[root@server ~]# source .bashrc
这样使用check命令即可直接调用-v 的命令,但只是当前登录有效。

命令运行结果如下:
[root@server ~]# check

Nagios Core 3.2.0
Copyright (c) 2009 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2009
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/services.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
        Checked 11 services.
Checking hosts...
        Checked 2 hosts.
Checking host groups...
        Checked 1 host groups.
Checking service groups...
        Checked 0 service groups.
Checking contacts...
        Checked 1 contacts.
Checking contact groups...
        Checked 1 contact groups.
Checking service escalations...
        Checked 0 service escalations.
Checking service dependencies...
        Checked 0 service dependencies.
Checking host escalations...
        Checked 0 host escalations.
Checking host dependencies...
        Checked 0 host dependencies.
Checking commands...
        Checked 24 commands.
Checking time periods...
        Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
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

5. 重启nagios
[root@server ~]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.

6. 测试

监控服务:Nagios(三)——监控外部信息(主机、服务)

监控主机:Nagios(三)——监控外部信息(主机、服务)

至此,nagios 监控外部信息完成!

 

 

相关软件包下载:http://down.51cto.com/data/699395

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI