Also, James discovers
http://gist.github.com
via
http://kasun86.blogspot.ie/2011/07/posting-code-snippets-to-blogger.html
Wurgh, spot the difference, has my scripting evolved to avoid use of < and & ? :)
# usage: ./monitor_remote_access.sh > monitor_remote_access.log 2>&1 &
[[ "$1" == "" ]] && REMOTEDIR=/projects
while true; do
DTS_BEFORE=$(date +%Y_%m_%d_%H_%M_%S)
S_BEFORE=$(date +%s)
OUT=$(time ls $REMOTEDIR 2>mon_${2}.log)
#real
0m0.015s
#user
0m0.001s
#sys
0m0.004s
SUCCESSCHECK=$(echo "$OUT" |grep
"$3")
ERRORCHECK=$(cat mon_belprojects.log)
TIMECHECK==$(echo "$OUT" |grep
"real")
DTS=$(date +%Y_%m_%d_%H_%M_%S)
S=$(date +%s)
S_DELTA=$((S-S_BEFORE))
echo
"DTS_BEFORE=$DTS_BEFORE DTS=$DTS TIME=$TIME ERRORCHECK=$ERRORCHECK
SECONDS=$S_DELTA TIMECHECK=$TIMECHECK SUCCESSCHECK=$SUCCESSCHECK"
# 3
checks 1. success, 2. error returned, 3. time command took
[[
"$SUCCESSCHECK" == "" ]] && echo "ERROR:
SUCCESSCHECK=$SUCCESSCHECK";
[[
"$ERRORCHECK" != "" ]] && echo "ERROR:
ERRORCHECK=$ERRORCHECK";
((
S_DELTA > 20 )) && echo "ERROR: TIMECHECK FAIL
SECONDS=$S_DELTA";
sleep 10
done