在我们的Nagios设置中,我们使用服务和主机的模板和对象inheritance。
#Le Hosts define host{ use linux-nrpe,linux-dc3,linux-cassandra host_name tigris alias tigris address 192.168.4.72 } define host{ use linux-nrpe,linux-dc3,linux-cassandra host_name euphrates alias euphrates address 192.168.4.177 } #Le Templates define host{ name linux-nrpe use all-hosts hostgroups linux-nrpe contact_groups rhands,usergroup1,opcomms register 0 } #Le Services define service{ hostgroup_name linux-nrpe use high-priority-service,graphed-service service_description Load check_command check_by_nrpe!check_load!5,5,6!9,9,9 contact_groups rhands,usergroup1,opcomms } [...etc...]
这个设置的问题是, linux-nrpe组中的所有服务器在其负载级别达到服务中定义的任何值时触发警报,但是我们的主力服务器可能在24小时运行,但是我们的数据库服务器非常高兴地坐在〜1,除非出现问题,所以我们发现系统发出太多警报,或者忽略/不警告。 为每个服务器定义单独的服务定义(大部分)需要很长时间,我们真正想做的事情就是这样
define host{ name linux-nrpe use all-hosts hostgroups linux-nrpe contact_groups rhands,usergroup1,opcomms register 0 perf_load 2,2,3 5,5,6 perf_mem 95% 97% [...more...] } define service{ hostgroup_name linux-nrpe use high-priority-service,graphed-service service_description Load check_command check_by_nrpe!check_load!$perf_mem$ contact_groups rhands,usergroup1,opcomms }
我查看了文档,看不到任何东西,除非我失去了一些东西。 有任何想法吗?
在我们的Nagios监控中,我们有一个非常类似的解决scheme。 自定义主机/服务variables必须以定义的下划线开始,并且必须添加_HOST或_SERVICE作为前缀,并且全部使用大写字母作为参考。
因此你的perf_load和perf_mem自定义variables必须被定义为
define host { [..] _perf_load 2,2,3 5,5,6 _perf_mem 95% 97% [..] }
并引用为
define service { [..] check_command check_by_nrpe!check_load!$_HOSTPERF_LOAD$ [..] }
从我们的Nagios的运行configuration中的一个片段:
define host { host_name target alias target address target use tmpl_host _gprs_address 192.168.0.1 } [...] define service { host_name target service_description GPRS ping use tmpl_service_ping check_command check_fping-by-ssh!-H 1.2.3.4 -S $_HOSTGPRS_ADDRESS$ -n 7 -t 1000 -w 1000 -c 2000 event_handler check_restart-GPRS-PPP notes_url https://wiki. contact_groups admin_allday }
您可以在Nagios 文档中find更多详细信息。
作为参考,这个工作在Icinga也很好。
您也可以在主机本身上定义NRPEconfiguration中的阈值。 这是不实际的,如果你有几十个主机,除非你有某种types的confpipe理(像木偶,甚至只是git / hg / svn /其他),并在nrpe.cfg中使用'includes'。
但是,Lairsdragon的build议要好得多。 我会补充一件事是:
使用两个前导下划线($ __ FOO)命名自定义对象variables会很有帮助,因此可以将它们命名为“$ _HOST_FOO”。