submit_check_result.txt in Monitoring 7
#!/bin/bash
## Configuration section ##
# Address of the central Icinga server.
central_server="@central_server"
# Host name as defined by the host object definition at the Icinga server.
host_name="@host_name"
# The local send_nsca command.
SEND_NSCA="/usr/sbin/send_nsca"
# The send_nsca config file.
send_nsca_cfg="/etc/send_nsca.cfg"
# Will invoke drush command to get sensors results. Make sure the drush path
# and argument values are correct.
dump=`/path/to/drush --root=@root --uri=@uri monitoring-icinga`
# Alternatively with sudo:
#
# dump=`sudo -u www_user /path/to/drush --root=@root --uri=@uri monitoring-icinga`
## Configuration end ##
IFS='~' read -a array <<< "$dump"
for line in "${array[@]}"
do
IFS='|' read -a result <<< "$line"
return_code=-1
case "${result[1]}" in
OK)
return_code=0
;;
WARNING)
return_code=1
;;
CRITICAL)
return_code=2
;;
UNKNOWN)
return_code=-1
;;
esac
echo "${result[0]}"
printf "%s\t%s\t%s\t%s\n" "$host_name" "${result[0]}" "$return_code" "${result[2]}" | $SEND_NSCA -H "$central_server" -c "$send_nsca_cfg"
done
File
modules/monitoring_icinga/config_tpl/submit_check_result.txt
View source
- #!/bin/bash
-
- ## Configuration section ##
-
- # Address of the central Icinga server.
- central_server="@central_server"
-
- # Host name as defined by the host object definition at the Icinga server.
- host_name="@host_name"
-
- # The local send_nsca command.
- SEND_NSCA="/usr/sbin/send_nsca"
-
- # The send_nsca config file.
- send_nsca_cfg="/etc/send_nsca.cfg"
-
- # Will invoke drush command to get sensors results. Make sure the drush path
- # and argument values are correct.
- dump=`/path/to/drush --root=@root --uri=@uri monitoring-icinga`
-
- # Alternatively with sudo:
- #
- # dump=`sudo -u www_user /path/to/drush --root=@root --uri=@uri monitoring-icinga`
-
- ## Configuration end ##
-
- IFS='~' read -a array <<< "$dump"
-
- for line in "${array[@]}"
- do
- IFS='|' read -a result <<< "$line"
-
- return_code=-1
-
- case "${result[1]}" in
- OK)
- return_code=0
- ;;
- WARNING)
- return_code=1
- ;;
- CRITICAL)
- return_code=2
- ;;
- UNKNOWN)
- return_code=-1
- ;;
- esac
-
- echo "${result[0]}"
-
- printf "%s\t%s\t%s\t%s\n" "$host_name" "${result[0]}" "$return_code" "${result[2]}" | $SEND_NSCA -H "$central_server" -c "$send_nsca_cfg"
-
- done