Added zabbix agent config parameter to runtrap

This commit is contained in:
Eric Renfro 2013-07-02 10:35:16 -04:00
parent 70bafc99f2
commit 40e0608af6
1 changed files with 6 additions and 5 deletions

11
runtrap
View File

@ -1,6 +1,7 @@
#!/bin/bash
state=${1:-live}
agentconf=${2:-/etc/zabbix/zabbix_agentd.conf}
lockfile="/tmp/zabbix.trap.${state}.lock"
tempfile=$(mktemp /tmp/zabbix.trap.${state}.tmp.XXXXXXXXXX)
trapdir="$(dirname $(readlink -f $0))/trap.d/${state}"
@ -15,13 +16,13 @@ if [[ -r "${lockfile}" ]]; then
if [[ $(pgrep -f $(readlink -f $0) | wc -l) -gt 0 ]]; then
runs=$(head -n1 ${lockfile})
if [[ $runs -ge 3 ]]; then
for s in ${trapdir}/${state}/*
for s in ${trapdir}/*
do
echo "Kill: $s "
pkill -9 -f $s
done
rm -f /tmp/zabbix.trap.${state}.lock
rm -f /tmp/zabbix.trap.${state}.tmp.*
rm -f ${lockfile}
rm -f /tmp/zabbix.trap.${state}.*
pkill -9 -f $(readlink -f $0)
else
echo "$[ ++runs ]" > ${lockfile}
@ -31,7 +32,7 @@ if [[ -r "${lockfile}" ]]; then
fi
echo 1 > ${lockfile}
for s in ${trapdir}/${state}/*
for s in ${trapdir}/*
do
$s > ${tempfile} 2> /dev/null
if [ $? -ne 0 ]; then
@ -57,5 +58,5 @@ else
fi
rm -f ${tempfile}
rm -f /tmp/zabbix.trap.${state}.lock
rm -f ${lockfile}