icinga 被动模式 nsca 安装

本文假设读者已安装好icinga,此外nsca本身nagios插件,icinga/nagios都适用

一。编译安装nsca
1.编译,拷贝文件
tar -vxzf nsca-2.7.2.tar.gz
./configure
make
cp src/nsca /usr/local/icinga/bin
cp sample-config/nsca.cfg /usr/local/icinga/etc
cp src/send_nsca /usr/local/icinga/bin
cp sample-config/send_nsca.cfg /usr/local/icinga/etc


2.修改nsca.cfg,本案例是icinga,需把文件中的所有nagios替换成icinga
server_address=192.168.100.100
debug=1
#与icinga的命令文件相同(默认就不用改)
command_file=/usr/local/icinga/var/rw/icinga.cmd


二。icinga配置文件
1.配置文件 template.cfg 添加模板
#ADD FOR PASSIVE CHECK
define service{
        name                            passive-service
        use                             generic-service
        max_check_attempts              1
        active_checks_enabled           0
        passive_checks_enabled          1
        normal_check_interval           5
        retry_check_interval            1
        notification_interval           10
        notification_options            w,u,c,r,f,s
        contact_groups                  admins
        register                        0
        }
2.配置文件 linux.cfg/hpux.cfg 添加主机, 主机组,服务,服务组(分组管理)
#ADD FOR PASSIVE CHECK
define hostgroup{
        hostgroup_name  nsca_cluster ; The name of the hostgroup
        alias           nsca_Servers ; Long name of the group
        members         192.168.100.100
        }
define servicegroup {
        servicegroup_name  NSCA-MON
        alias   NSCA-MON
}
define host{
        use                  linux-server        ;using linux-server template!!!
        host_name               192.168.100.100
        alias                   local-host
        icon_image              redhat.gif
        statusmap_image         redhat.gd2
        address                 192.168.100.100
        }

define service{
        hostgroup_name                  nsca_cluster
        use                             passive-service
        servicegroups                   NSCA-MON
        service_description             CheckDummy
        check_command                   check_dummy!0
        notifications_enabled           1
        }

3.配置文件 commands.cfg 添加服务
# ADD FOR PASSIVE CHECK
define command{
       command_name    check_dummy
       command_line    /usr/local/icinga/libexec/check_dummy $ARG1$
       }

三。查看icinga的nsca插件是否成功运行

1.启动服务端nsca
nsca -c ../etc/nsca.cfg --daemon
nestat -an|grep 5667 此时端口是LISTEN

2.send_nsca发送数据
# vi xxx.txt写入一行并保存,注意其中的tab分隔符
192.168.100.100    CheckDummy    0    this is a test of nsca

# 发送数据到服务端
echo xxx.txt| send_nsca -H 192.168.100.100 -p 5667 -c ../etc/send_nsca.cfg

3.查看系统日志,确认服务端是否收到信息
grep nsca /var/log/messages

结果如下,说明已经成功,如果没有输出[被动服务检查],则说明icinga的命令/服务配置等不正确,没有找到描述为[CheckDummy]的命令
nsca[21562]: SERVICE CHECK -> Host Name: '192.168.100.100', Service Description: 'CheckDummy', Return Code: '0', Output: 'this is a test of nsca'
nsca[21562]: End of connection...
icinga: 额外命令: PROCESS_SERVICE_CHECK_RESULT;192.168.100.100;CheckDummy;0;this is a test of nsca
icinga: 被动服务检查: 192.168.100.100;CheckDummy;0;this is a test of nsca

4.完成。
可根据需要,写程序调用send_nsca发送给icinga监控结果数据了。
查看icinga控制台,主机192.168.100.100 服务CheckDummy 状态 正常

转载于:https://www.cnblogs.com/airsong23/p/3608293.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值