紧接前面两篇,前面已经搭建了.111上icinga的服务器,并且监控了远程.131Linux服务器的HTTP服务。
因为HTTP服务属于public service, 不需要在远程机器上安装agent,但是如果需要监控.131的本地资源,比如磁盘,CPU等,就需要安装一个软件。
icinga提供了两种模式,一种叫做active check,就是server .111轮询.131,这种效率不搞,不推荐。还有另一种模式,passive check, 是等待远程agent发送消息。
NSCA插件和icinga配合使用就能达到这种效果。这是推荐的,很可惜,该项目已经从去年终止了,如果想继续,就得自己来了。
我只说要点:
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
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 页面上也能看到一行记录。