nagios分布式配置(1)(3)
nagios分布式服务端:
1.修改nagios.cfg文件
查看源代码
打印帮助0vi /usr/local/nagios/etc/nagios.cfg
1#修改以下参数值
2enable_notifications=0
3obsess_over_services=1
4ocsp_command=submit_service_check_result
5obsess_over_hosts=1
6ochp_command=submit_host_check_result
2.创建submit_service_check_result脚本
查看源代码
打印帮助00vi /usr/local/nagios/libexec/submit_service_check_result
01#!/bin/sh
02# Arguments:
03# = host_name (Short name of host that the service is
04# associated with)
05# = svc_description (Description of the service)
06# = state_string (A string representing the status of
07# the given service - "OK", "WARNING", "CRITICAL"
08# or "UNKNOWN")
09# = plugin_output (A text string that should be used
10# as the plugin output for the service checks)
11#
12# Convert the state string to the corresponding return code
13return_code=-1
14case "$3" in
15OK)
16return_code=0
17;;
18WARNING)
19return_code=1
20;;
21CRITICAL)
22return_code=2
23;;
24UNKNOWN)
25return_code=-1
26;;
27esac
28# pipe the service check info into the send_nsca program, which
29# in turn transmits the data to the nsca daemon on the central
30# monitoring server
31/usr/bin/printf "%s\t%s\t%s\t%s\n" "$1" "$2" "$return_code" "$4" | /usr/local/nagios/bin/send_nsca -H 1.1.1.1(修改为主服务端的ip) -c /usr/local/nagios/etc/send_nsca.cfg
查看源代码
打印帮助0chmod +x /usr/local/nagios/libexec/submit_service_check_result
1chown nagios.nagios submit_service_check_result
3.创建submit_host_check_result脚本
查看源代码
打印帮助00vi /usr/local/nagios/libexec/submit_host_check_result
01#!/bin/sh
02# Arguments:
03# = host_name (Short name of host that the service is
04# associated with)
05# = svc_description (Description of the service)
06# = state_string (A string representing the status of
07# the given service - "OK", "WARNING", "CRITICAL"
08# or "UNKNOWN")
09# = plugin_output (A text string that should be used
10# as the plugin output for the service checks)
11#
12# Convert the state string to the corresponding return code
13return_code=-1
14case "$2" in
15UP)
16return_code=0
17;;
18DOWN)
19return_code=1
20;;
21UNREACHABLE)
22return_code=2
23;;
24esac
25# pipe the service check info into the send_nsca program, which
26# in turn transmits the data to the nsca daemon on the central
27# monitoring server
28/usr/bin/printf "%s\t%s\t%s\n" "$1" "$return_code" "$3" | /usr/local/nagios/bin/send_nsca -H 1.1.1.1(修改为主服务端的ip) -c /usr/local/nagios/etc/send_nsca.cfg
评论暂时关闭