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

11
runtrap
View file

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