你好,游客 登录 注册 搜索
背景:
阅读新闻

icinga用NSCA监控远程Linux服务器

[日期:2013-05-16] 来源:Linux社区  作者:sheismylife [字体:大 中 小]

紧接前面两篇,前面已经搭建了.111上icinga的服务器,并且监控了远程.131Linux服务器的HTTP服务。

http://www.linuxidc.com/Linux/2013-05/84362.htm
http://www.linuxidc.com/Linux/2013-05/84363.htm

因为HTTP服务属于public service, 不需要在远程机器上安装agent,但是如果需要监控.131的本地资源,比如磁盘,CPU等,就需要安装一个软件。

icinga提供了两种模式,一种叫做active check,就是server .111轮询.131,这种效率不搞,不推荐。还有另一种模式,passive check, 是等待远程agent发送消息。

NSCA插件和icinga配合使用就能达到这种效果。这是推荐的,很可惜,该项目已经从去年终止了,如果想继续,就得自己来了。

先看看怎么用吧。这篇文档可以帮助我们安装和使用。http://docs.icinga.org/latest/en/nsca.html

我只说要点:

1. 当运行

./nsca -c ../sample-config/nsca.cfg

出现权限不足时,简单点,直接用chmod -R 777 修改该目录权限

2. 10.3.6中选择xinetd方式,Ubuntu下先要安装:

apt-et install xinetd

然后编辑/etc/hosts.allow 文件,加一行:

ALL: 10.112.18.131

3. 把一些文件拷贝的131机器上后,没有必要创建什么incinga用户,直接用root就可以测试

4. .111 icinga server上linux.cfg文件配置如下:

define host{
        use            linux-server            ; Inherit default values from a template
        host_name      StaticFileServer              ; The name we're giving to this host                                                                                     
        alias          static filer server for 3D and jenksins server for CloudEngine        ; A longer name associated with the host                                         
        address        10.112.18.131            ; IP address of the host                                                                                                       
        contact_groups  admins                ; Host groups this host is associated with                                                                                       
        }                                                                                                                                                                       
                                                                                                                                                                               
# check that web services are running                                                                                                                                           
define service{                                                                                                                                                                 
        host_name                  StaticFileServer                                                                                                                             
        service_description            HTTP                                                                                                                                   
        check_command                  check_http                                                                                                                             
        use                            generic-service                                                                                                                         
        action_url                      http://10.112.18.131/ArcGIS/rest/services/SanFrancisco/3DFeatureServer                                                                 
        notification_interval          0 ; set > 0 if you want to be renotified                                                                                               
}                                                                                                                                                                               
                                                                                                                                                                               
define service{                                                                                                                                                                 
    use                    generic-service  ; template to inherit from                                                                                                       
    name                    passive-service  ; name of this template                                                                                                           
    active_checks_enabled  0                ; no active checks                                                                                                               
    passive_checks_enabled  1                ; allow passive checks                                                                                                           
    check_command          check_dummy!0    ; use "check_dummy", RC=0 (OK)                                                                                                   
    check_period            24x7              ; check active all the time                                                                                                       
    check_freshness        0                ; do not check if check result is stale                                                                                           
    register                0                ; this is a template, not a real service                                                                                         
    }                                                                                                                                                                           
                                                                                                                                                                               
define service{                                                                                                                                                                 
    use                    passive-service  ; template to inherit from                                                                                                       
    host_name              StaticFileServer        ; host where send_nsca is located                                                                                           
    service_description    Diskspace        ; service to be checked                                                                                                           
    }   

5. 日志文件位置: /usr/local/icinga/var/icinga.log

6. commands.cfg中已经定义了check_dummy命令,不需要修改

7. .131上运行命令测试发送数据:

echo -e "StaticFileServer\tDiskspace\t0\t/var=78%\n" | /usr/local/icinga/bin/send_nsca -H 10.112.18.111 -c /usr/local/icinga/etc/send_nsca.cfg

注意StaticFileServer大小写不能错, /var=78% 是发送的信息。

-H后面是icinga server的IP地址

8. 最后看日志中有了:

[1368620324] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;StaticFileServer;Diskspace;0;/var=78%
[1368620332] PASSIVE SERVICE CHECK: StaticFileServer;Diskspace;0;/var=78%

9. web 页面上也能看到一行记录。

总结:NSCA就是解决了监控终端发送消息给服务器的通信问题,监控脚本要自己编写,用来采集数据。因此这个架构很灵活,可以随便发挥。不过就是做的事情不少,后面会尝试整体解决方案:Check_MK, 如果能够在这上面二次开发,功能就非常强大了。

linux
相关资讯       icinga 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款