1
我實施了nsca
在Nagios
爲分佈式監控的目的,似乎一切工作,除了一個奇怪的,我似乎無法找到任何答案。
發送和接收被動檢查,但輸出顯示第4個變量始終未初始化,因此顯示爲$OUTPUT$
。看起來好像檢查顯示了非中央服務器上的正確信息,但是當它被髮送時,它似乎沒有正確插入。
commands.cfg
define command{
command_name submit_check_result
command_line /usr/share/nagios3/plugins/eventhandlers/submit_check_result $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$OUTPUT$'
}
submit_check_result
#!/bin/sh
return_code=-1
case "$3" in
OK)
return_code=0
;;
WARNING)
return_code=1
;;
CRITICAL)
return_code=2
;;
UNKNOWN)
return_code=-1
;;
esac
/usr/bin/printf "%s\t%s\t%s\t%s\n" "$1" "$2" "$return_code" "$4" | /usr/sbin/send_nsca 192.168.40.168 -c /etc/send_nsca.cfg
實施例服務
define service {
host_name example_host
service_description PING
check_command check_icmp
active_checks_enabled 1
passive_checks_enabled 0
obsess_over_service 1
max_check_attempts 5
normal_check_interval 5
retry_check_interval 3
check_period 24x7
notification_interval 30
notification_period 24x7
notification_options w,c,r
contact_groups admins
}
從日誌非中央服務器上的輸出顯示:
Nov 29 22:52:52 nagios-server nagios3: SERVICE ALERT: example_host;PING;OK;HARD;5;OK - 192.168.1.1: rta nan, lost 0%
從日誌在中央服務器上的輸出顯示:
EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;example_host;PING;0;$OUTPUT$
中央服務器(網絡接口)的狀態信息顯示:
PING OK 2016-11-29 22:54:50 0d 0h 54m 6s 1/5 $OUTPUT$
它不只是這兩種服務。所有服務,包括基本上爲Nagios服務器本身預配置的服務「check_load,check_proc等」。
任何援助將不勝感激。