如何用netcattestingnagios send_nsca

我正在尝试使用nc写一个send_nsca的unit testing,但是它失败了。

我想要启动nc来侦听nsca端口,然后使用send_ncsa向该端口发送消息。

在一个terminal,我正在运行:

 nc -l 5667 -v 

在另一个:

 echo -e "foo.example.com\ttest\t0\t0" | ./send_nsca -H localhost -p 5667 -c send_nsca.cfg 

我的send_nsca.cfg文件只包含: encryption_method=0

在收听terminal上,我得到:

 Connection from 10.1.30.23 port 5667 [tcp/*] accepted 

但没有别的。 在send_nsca方面我得到:

 Error: Timeout after 10 seconds 

有任何想法吗?

编辑:

我重新编译了源代码并启用了DEBUG输出:

 Connected okay... Error: Timeout after 10 seconds Cleaned up encryption routines 

从代码中我看到我缺less包含IV和时间戳的初始化数据包:

 #ifdef DEBUG printf("Connected okay...\n"); #endif /* read the initialization packet containing the IV and timestamp */ result=read_init_packet(sd); if(result!=OK){ printf("Error: Could not read init packet from server\n"); close(sd); do_exit(STATE_CRITICAL); } #ifdef DEBUG printf("Got init packet from server\n"); #endif 

有没有其他的方式来testingsend_nsca没有完整的Nagios安装?

你不需要一个“全面的nagios安装”来testingsend_nsca …

NSCA是附加组件,不属于Nagios核心本身。 例如,它被封装在Debian / Ubuntu和CentOS(epel或repoforge)中。

NSCA作为守护进程或通过inetd / xinetd运行。 有关如何运行它的更多信息,请参阅NSCA设置文档 。

此外,有几个可用的NSCA的替代品; NRDP和NSCA-ng可能是你感兴趣的testing。