icinga用NSCA监控远程Linux服务器


icinga用NSCA监控远程Linux服务器
 
因为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下先要安装:
[plain] 
apt-et install xinetd  
 
然后编辑/etc/hosts.allow 文件,加一行: 
[plain] 
ALL: 10.112.18.131  
 
3. 把一些文件拷贝的131机器上后,没有必要创建什么incinga用户,直接用root就可以测试
 
4. .111 icinga server上linux.cfg文件配置如下:
[plain] 
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上运行命令测试发送数据:
[plain] 
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. 最后看日志中有了:
[plain] 
[1368620324] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;StaticFileServer;Diskspace;0;/var=78%  
[1368620332] PASSIVE SERVICE CHECK: StaticFileServer;Diskspace;0;/var=78%  
 
9. web 页面上也能看到一行记录。
不过写完文章就看不到了,还是对icinga不熟悉啊。回头找到了再截图。
 
总结:NSCA就是解决了监控终端发送消息给服务器的通信问题,监控脚本要自己编写,用来采集数据。因此这个架构很灵活,可以随便发挥。不过就是做的事情不少,后面会尝试整体解决方案:Check_MK, 如果能够在这上面二次开发,功能就非常强大了。
 

相关内容

    暂无相关文章