新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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

       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


文章标题:Nagios(三)——监控外部信息(主机、服务)
网址分享:http://wjwzjz.com/article/giedpj.html
在线咨询
服务热线
服务热线:028-86922220
TOP