Fixed runtrap and added runtrap.debug

This commit is contained in:
Eric Renfro 2013-07-08 08:56:03 -04:00
parent 23a6bd21d5
commit db47e1d472
2 changed files with 17 additions and 7 deletions

11
runtrap
View file

@ -6,6 +6,11 @@ lockfile="/tmp/zabbix.trap.${state}.lock"
tempfile=$(mktemp /tmp/zabbix.trap.${state}.tmp.XXXXXXXXXX) tempfile=$(mktemp /tmp/zabbix.trap.${state}.tmp.XXXXXXXXXX)
trapdir="$(dirname $(readlink -f $0))/trap.d/${state}" trapdir="$(dirname $(readlink -f $0))/trap.d/${state}"
errors=0 errors=0
debug=false
if [[ "$0" == *".debug" ]]; then
debug=true
fi
if [[ ! -d "$trapdir" ]]; then if [[ ! -d "$trapdir" ]]; then
echo "ERROR: Trap directory doesn't exist: $trapdir " echo "ERROR: Trap directory doesn't exist: $trapdir "
@ -34,7 +39,7 @@ fi
echo 1 > ${lockfile} echo 1 > ${lockfile}
for s in ${trapdir}/* for s in ${trapdir}/*
do do
$s > ${tempfile} 2> /dev/null $s >> ${tempfile} 2> /dev/null
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
errors=1 errors=1
fi fi
@ -46,6 +51,9 @@ done
#echo "Errors: $errors" #echo "Errors: $errors"
#exit 0 #exit 0
if $debug; then
cat ${tempfile}
else
zsend=$(zabbix_sender -c ${agentconf} -i ${tempfile}) zsend=$(zabbix_sender -c ${agentconf} -i ${tempfile})
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR" echo "ERROR"
@ -56,6 +64,7 @@ else
echo "OK" echo "OK"
fi fi
fi fi
fi
rm -f ${tempfile} rm -f ${tempfile}
rm -f ${lockfile} rm -f ${lockfile}

1
runtrap.debug Symbolic link
View file

@ -0,0 +1 @@
runtrap