From 47ef218263b48615d9c01161ade029f2742046df Mon Sep 17 00:00:00 2001 From: Olivier Mehani Date: Tue, 20 Jun 2017 21:14:24 +1000 Subject: [PATCH] [multi-ssl] Backward compatibility with ssl_ Signed-off-by: Olivier Mehani --- plugins/ssl/multi_ssl | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/plugins/ssl/multi_ssl b/plugins/ssl/multi_ssl index 7c348670..dac068a4 100755 --- a/plugins/ssl/multi_ssl +++ b/plugins/ssl/multi_ssl @@ -10,7 +10,7 @@ multi_ssl - Plugin to monitor CERTificate expiration on multiple services and po =head1 CONFIGURATION [multi_ssl] - env.services www.service.tld blah.example.net_PORT + env.services www.service.tld blah.example.net:PORT To set warning and critical levels do like this: @@ -18,6 +18,17 @@ To set warning and critical levels do like this: env.services ... env.warning 30: +Alternatively, if you want to monitor hosts separately, you can create multiple symlinks named as follows. + + multi_ssl_HOST:PORT + +For example: + + multi_ssl_www.example.net + multi_ssl_www.example.org_443 + multi_ssl_192.0.2.42_636 + multi_ssl_2001:0DB8::badc:0fee_485 + =head1 AUTHOR Pactrick Domack (ssl_) @@ -36,6 +47,13 @@ if [ "${MUNIN_DEBUG}" = 1 ]; then set -x fi +HOSTPORT=${0##*multi_ssl_} + +if [ "${HOSTPORT}" != "${0}" ] \ + && [ ! -z "${HOSTPORT}" ]; then + services="${HOSTPORT}" +fi + case $1 in config) @@ -46,7 +64,7 @@ case $1 in echo "graph_info This graph shows the days left for the certificate" for service in $services; do fieldname=$(clean_fieldname "$service") - echo "${fieldname}.label $(echo ${service} | sed 's/_/:/')" + echo "${fieldname}.label $(echo "${service}" | sed 's/_/:/')" print_thresholds "${fieldname}" done @@ -56,12 +74,16 @@ esac get_expire() { - SITE="$(echo ${1} | sed 's/_.*//')" - PORT="$(echo ${1} | sed 's/.*_//')" + SITE="$(echo "${1}" | sed 's/_.*//')" + PORT="$(echo "${1}" | sed 's/.*_//')" + VAR="$(clean_fieldname "$1")" if [ "$PORT" = "$SITE" ]; then PORT=443 fi + if echo "$SITE" | grep -q ':'; then + SITE="[${SITE}]" + fi CERT=$(echo "" | openssl s_client -CApath /etc/ssl/certs -servername "${SITE}" -connect "${SITE}:${PORT}" 2>/dev/null);