diff --git a/xymon/xymon.procs.alert.sh b/xymon/xymon.procs.alert.sh index 67502e1..9a7c9a2 100755 --- a/xymon/xymon.procs.alert.sh +++ b/xymon/xymon.procs.alert.sh @@ -1,19 +1,31 @@ #!/bin/sh # Purpose {{{ -## If Xymon server says that a service is in error on a remote host, try to restart this service. +## If Xymon server says that a service is in error on a remote host, try to +## restart this service. ## 1. Create a ssh keyring for xymon user {{{ # sudo mkdir -p -- /var/lib/xymon/.ssh/ # sudo ssh-keygen -f /var/lib/xymon/.ssh/id_rsa -N '' -q # sudo chown -R xymon:xymon /var/lib/xymon/.ssh/ ## }}} ## 2. Remote user {{{ -# Ensure to have the ${REMOTE_SSH_USER} available on remote hosts and allowed to connect with SSH. -# Restrict the SSH access to a single SSH key from the Xymon server IP (~${REMOTE_SSH_USER}/.ssh/authorized_keys) : +# Ensure to have the ${REMOTE_SSH_USER} available on remote hosts and allowed +# to connect with SSH. +# Restrict the SSH access to a single SSH key from the Xymon server IP +# (~${REMOTE_SSH_USER}/.ssh/authorized_keys) : ## from="IP.SRV.XYM.ON" ssh-rsa AAAAA… # Allow sudo commands to restart services (/etc/sudoers.d/xymon-ssh) : ## xymon-ssh ALL=(root:root) NOPASSWD: /bin/systemctl restart * ## }}} +## 3. Xymon Configuration {{{ +# PROC monitoring need to display the real service name in it's description : +## PROC %^/sbin/rpcbind MIN=1 MAX=1 COLOR=red "TEXT=rpcbind" +# You can add more information about this proc if you an underscore "_" : +## PROC %^/usr/sbin/rpc.idmapd MIN=1 MAX=1 COLOR=red "TEXT=NFS-server_rpc.idmapd" +## This way, the script will only take the text before the underscore "_" as the +## service name to be restarted. +# Don't add whitespaces in the description of a process. +## }}} # }}} # Vars {{{ @@ -48,7 +60,7 @@ if [ -s "${service_list}" ]; then ## Pattern "req. between" {{{ if echo "${line}" | grep -q -E -- ".* \\(found .*, req. between .* and .*\\)" ; then [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : while process loop — Pattern \"req. between\"." >> "${debug_stdout}" - service_name="$(echo "${line}" | cut -d" " -f1)" + service_name="$(echo "${line}" | cut -d" " -f1 | sed 's/_.*//')" process_found="$(echo "${line}" | cut -d" " -f3 | tr -d ',')" process_min="$(echo "${line}" | cut -d" " -f6)" process_max="$(echo "${line}" | cut -d" " -f8 | tr -d ')')" @@ -57,7 +69,7 @@ if [ -s "${service_list}" ]; then ## Pattern "req. .* or more" {{{ if echo "${line}" | grep -q -E -- ".* \\(found .*, req. .* or more\\)" ; then [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : while process loop — Pattern \"req. .* or more\"." >> "${debug_stdout}" - service_name="$(echo "${line}" | cut -d" " -f1)" + service_name="$(echo "${line}" | cut -d" " -f1 | sed 's/_.*//')" process_found="$(echo "${line}" | cut -d" " -f3 | tr -d ',')" process_min="$(echo "${line}" | cut -d" " -f5)" process_max="nolimit"