Fixed runtrap and added runtrap.debug
This commit is contained in:
parent
23a6bd21d5
commit
db47e1d472
2 changed files with 17 additions and 7 deletions
17
runtrap
17
runtrap
|
@ -6,6 +6,11 @@ lockfile="/tmp/zabbix.trap.${state}.lock"
|
|||
tempfile=$(mktemp /tmp/zabbix.trap.${state}.tmp.XXXXXXXXXX)
|
||||
trapdir="$(dirname $(readlink -f $0))/trap.d/${state}"
|
||||
errors=0
|
||||
debug=false
|
||||
|
||||
if [[ "$0" == *".debug" ]]; then
|
||||
debug=true
|
||||
fi
|
||||
|
||||
if [[ ! -d "$trapdir" ]]; then
|
||||
echo "ERROR: Trap directory doesn't exist: $trapdir "
|
||||
|
@ -34,7 +39,7 @@ fi
|
|||
echo 1 > ${lockfile}
|
||||
for s in ${trapdir}/*
|
||||
do
|
||||
$s > ${tempfile} 2> /dev/null
|
||||
$s >> ${tempfile} 2> /dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
errors=1
|
||||
fi
|
||||
|
@ -46,15 +51,19 @@ done
|
|||
#echo "Errors: $errors"
|
||||
#exit 0
|
||||
|
||||
zsend=$(zabbix_sender -c ${agentconf} -i ${tempfile})
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR"
|
||||
if $debug; then
|
||||
cat ${tempfile}
|
||||
else
|
||||
zsend=$(zabbix_sender -c ${agentconf} -i ${tempfile})
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "ERROR"
|
||||
else
|
||||
if [[ $errors -gt 0 ]]; then
|
||||
echo "WARN"
|
||||
else
|
||||
echo "OK"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f ${tempfile}
|
||||
|
|
1
runtrap.debug
Symbolic link
1
runtrap.debug
Symbolic link
|
@ -0,0 +1 @@
|
|||
runtrap
|
Loading…
Reference in a new issue