Updated runtrap to log, diskstats to handle default action

This commit is contained in:
Eric Renfro 2013-08-12 15:34:49 -04:00
parent 3e40157c11
commit 698f8fd539
2 changed files with 11 additions and 6 deletions

14
runtrap
View file

@ -8,12 +8,16 @@ trapdir="$(dirname $(readlink -f $0))/trap.d/${state}"
errors=0 errors=0
debug=false debug=false
log() {
echo "$(date +"%x %T") $*"
}
if [[ "$0" == *".debug" ]]; then if [[ "$0" == *".debug" ]]; then
debug=true debug=true
fi fi
if [[ ! -d "$trapdir" ]]; then if [[ ! -d "$trapdir" ]]; then
echo "ERROR: Trap directory doesn't exist: $trapdir " log "ERROR: Trap directory doesn't exist: $trapdir "
exit 5 exit 5
fi fi
@ -23,7 +27,7 @@ if [[ -r "${lockfile}" ]]; then
if [[ $runs -ge 3 ]]; then if [[ $runs -ge 3 ]]; then
for s in ${trapdir}/* for s in ${trapdir}/*
do do
echo "Kill: $s " log "Kill: $s "
pkill -9 -f $s pkill -9 -f $s
done done
rm -f ${lockfile} rm -f ${lockfile}
@ -56,12 +60,12 @@ if $debug; then
else else
zsend=$(zabbix_sender -c ${agentconf} -i ${tempfile}) zsend=$(zabbix_sender -c ${agentconf} -i ${tempfile})
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "ERROR" log "ERROR"
else else
if [[ $errors -gt 0 ]]; then if [[ $errors -gt 0 ]]; then
echo "WARN" log "WARN"
else else
echo "OK" log "OK"
fi fi
fi fi
fi fi

View file

@ -1,9 +1,10 @@
#!/bin/bash #!/bin/bash
mode=${1,,} mode=${1-trap}
mountpath=${2-all} mountpath=${2-all}
stat=${3,,} stat=${3,,}
mode=${mode,,}
#echo "mode: $mode" #echo "mode: $mode"
#echo "path: $mountpath" #echo "path: $mountpath"