From 40e0608af662086c641fc2f6f13da96bbbc5fa76 Mon Sep 17 00:00:00 2001 From: Eric Renfro Date: Tue, 2 Jul 2013 10:35:16 -0400 Subject: [PATCH] Added zabbix agent config parameter to runtrap --- runtrap | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/runtrap b/runtrap index ac26a84..68167b7 100755 --- a/runtrap +++ b/runtrap @@ -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}