I just upgraded from a 2.4 version to 3.2 (built from source) and notice that some or all of my external scripts are not working anymore.
It's not a normal upgrade, but a complete new install. Even the Linux server is a fresh installed Ubuntu 16.04 server.
I used export/import to get my config over.
In the past I would use the database, but I didn't want to do that now (afraid of migrating anomalies).
I'm still in the process of finding out what happens.
They stopped working on my previous install, but I never noticed. It was just giving me false values.
Now I noticed because I have suddenly 800 triggers going off.
I have an external script called "certexpire" which I call using
certexpire[{HOST.CONN1}, 25]
The script has always been working fine in an older version.
I now notice that the script is not receiving a hostname and 25, but the literal text "{HOST.CONN1} 25"
Of course that's not going to work.
I have more scripts not working
I am probably missing something. Something changed in some version?
It's not a normal upgrade, but a complete new install. Even the Linux server is a fresh installed Ubuntu 16.04 server.
I used export/import to get my config over.
In the past I would use the database, but I didn't want to do that now (afraid of migrating anomalies).
I'm still in the process of finding out what happens.
They stopped working on my previous install, but I never noticed. It was just giving me false values.
Now I noticed because I have suddenly 800 triggers going off.
I have an external script called "certexpire" which I call using
certexpire[{HOST.CONN1}, 25]
The script has always been working fine in an older version.
I now notice that the script is not receiving a hostname and 25, but the literal text "{HOST.CONN1} 25"
Of course that's not going to work.
I have more scripts not working
I am probably missing something. Something changed in some version?
Code:
#!/bin/bash
export PATH=${PATH}:/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin
TIMEOUT=10
RETVAL=-0.5
# If called by zabbix, handle some things different
if echo "${BASH_SOURCE}" | grep -q "zabbix" ; then
# get rid of 1st parameter (on Zabbix 1.8x)
# shift 1
# Change TimeOut value to the one in /etc/zabbix/zabbix_server.conf
ZABBIX_TIMEOUT=`grep -i '^Timeout' /etc/zabbix/zabbix_server.conf 2>/dev/null | awk -F= '{print $2}' | tr -cd '0-9'`
if [ -z "${ZABBIX_TIMEOUT}" ] ; then
TIMEOUT=3
else
# Let's take 1 second less than the one in /etc/zabbix/zabbix_server.conf and just hope to be in time
TIMEOUT=$(( ${ZABBIX_TIMEOUT} - 1 ))
fi
fi
# Zabbix 2.0 sends parameters quoted, where < 1.9 sends them unquoted
# This way it works on both
HOST=`echo "$*" | awk '{print $1}'`
PORT=`echo "$*" | awk '{print $2}'`
SCRATCH=`mktemp`
[ -z "${HOST}" ] && exit 1
[ -z "${PORT}" ] && PORT=443
# openssl is able to check plain smtp/pop3/ftp/imap connections
# that use TLS to setup a secure connection
TLS=
echo "${PORT}" | egrep -q '^(25|587)$' && TLS="-crlf -starttls smtp"
echo "${PORT}" | egrep -q '^110$' && TLS="-starttls pop3"
echo "${PORT}" | egrep -q '^21$' && TLS="-starttls ftp"
echo "${PORT}" | egrep -q '^143$' && TLS="-starttls imap"
# Retrieve Certificate in background because it doesn't support TimeOuts
# exec 2>/dev/null doesn't seem to be necessary if called this way....
echo "" | openssl s_client -servername ${HOST} -connect ${HOST}:${PORT} ${TLS} 2>/dev/null >${SCRATCH} &
sleep .1
# double the TIMEOUT and wait for half a second each time
let TIMEOUT*=2
# Wait for certificate
n=1
while [ ! -s ${SCRATCH} ] ; do
sleep .48
[ $n -ge ${TIMEOUT} ] && break
let n++
done
# If we have retrieved the certificate, we'll process it and retrieve the expiration date
if [ -s ${SCRATCH} ] ; then
EXPIRE_DATE=`sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' ${SCRATCH} | openssl x509 -enddate -noout 2>/dev/null | sed 's/notAfter\=//'`
if [ ! -z "${EXPIRE_DATE}" ]; then
EXPIRE_SECS=`date -d "${EXPIRE_DATE}" +%s`
EXPIRE_TIME=$(( ${EXPIRE_SECS} - `date +%s` ))
# We finally have it...
RETVAL=$(( ${EXPIRE_TIME} / 24 / 3600 ))
fi
else
# Too late you lazy bastard, I might as well kill you...
kill -9 %1 2>/dev/null
fi
rm -f ${SCRATCH} 2>/dev/null
echo ${RETVAL}
Comment