Fixed runtrap and added runtrap.debug
This commit is contained in:
parent
23a6bd21d5
commit
db47e1d472
2 changed files with 17 additions and 7 deletions
23
runtrap
23
runtrap
|
@ -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,14 +51,18 @@ done
|
||||||
#echo "Errors: $errors"
|
#echo "Errors: $errors"
|
||||||
#exit 0
|
#exit 0
|
||||||
|
|
||||||
zsend=$(zabbix_sender -c ${agentconf} -i ${tempfile})
|
if $debug; then
|
||||||
if [ $? -ne 0 ]; then
|
cat ${tempfile}
|
||||||
echo "ERROR"
|
|
||||||
else
|
else
|
||||||
if [[ $errors -gt 0 ]]; then
|
zsend=$(zabbix_sender -c ${agentconf} -i ${tempfile})
|
||||||
echo "WARN"
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "ERROR"
|
||||||
else
|
else
|
||||||
echo "OK"
|
if [[ $errors -gt 0 ]]; then
|
||||||
|
echo "WARN"
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
1
runtrap.debug
Symbolic link
1
runtrap.debug
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
runtrap
|
Loading…
Reference in a new issue