大橙子网站建设,新征程启航

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

Nagios(三)——监控外部信息(主机、服务)-创新互联

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

创新互联长期为上千余家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为襄汾企业提供专业的网站制作、成都网站制作,襄汾网站改版等技术服务。拥有10年丰富建站经验和众多成功案例,为您定制开发。

       一、监控外部信息

       监控外部信息,只需要参照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

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享名称:Nagios(三)——监控外部信息(主机、服务)-创新互联
标题链接:http://dzwzjz.com/article/cecchs.html
在线咨询
服务热线
服务热线:028-86922220
TOP