2018-08-17 15:31:17 +02:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
# Purpose {{{
|
|
|
|
|
## If Xymon server says that a probe is in error on a remote host, try to call the appropriate script.
|
|
|
|
|
## For debugging messages, you can check xymon's logs (/var/log/xymon/alert.log
|
|
|
|
|
|
|
|
|
|
## How-to use : {{{
|
|
|
|
|
### Define an alert in Xymon configuration file (/etc/xymon/alerts.cfg)
|
|
|
|
|
#HOST=HOST.DOMAIN.ORG
|
|
|
|
|
# SCRIPT /PATH/TO/SCRIPT/xymon.alert.sh 1234567890 FORMAT=SCRIPT DURATION<20
|
|
|
|
|
|
|
|
|
|
## }}}
|
|
|
|
|
# }}}
|
|
|
|
|
# Vars {{{
|
2018-08-17 15:33:46 +02:00
|
|
|
|
DEBUG=1
|
2018-08-17 15:31:17 +02:00
|
|
|
|
|
|
|
|
|
script_path="$(dirname -- ${0})"
|
|
|
|
|
script_libs="${script_path}/xymon.libs.alert.sh"
|
2018-08-21 16:37:37 +02:00
|
|
|
|
script_procs="${script_path}/xymon.procs.alert.sh"
|
2018-08-17 15:31:17 +02:00
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
|
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${BBHOSTNAME} — ${BBSVCNAME} is in error."
|
|
|
|
|
|
|
|
|
|
# Match probe name with the script {{{
|
|
|
|
|
case "${BBSVCNAME}" in
|
|
|
|
|
'libs' )
|
|
|
|
|
script_to_run="${script_libs}"
|
|
|
|
|
;;
|
2018-08-21 16:37:37 +02:00
|
|
|
|
'procs' )
|
|
|
|
|
script_to_run="${script_procs}"
|
|
|
|
|
;;
|
2018-08-17 15:31:17 +02:00
|
|
|
|
# default
|
|
|
|
|
* )
|
|
|
|
|
script_to_run="NOT.MANAGED"
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Call the next script if managed {{{
|
|
|
|
|
if [ "${script_to_run}" != "NOT.MANAGED" ]; then
|
|
|
|
|
# Export vars {{{
|
|
|
|
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${BBHOSTNAME} — Export vars for ${script_to_run}"
|
|
|
|
|
export BBALPHAMSG
|
|
|
|
|
export BBHOSTNAME
|
|
|
|
|
export BBSVCNAME
|
|
|
|
|
# }}}
|
|
|
|
|
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${BBHOSTNAME} — Run ${script_to_run} script."
|
|
|
|
|
"${script_to_run}"
|
|
|
|
|
fi
|
|
|
|
|
# }}}
|
|
|
|
|
|
|
|
|
|
exit 0
|