aboutsummaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2019-04-11 18:33:14 +0200
committerGitHub <noreply@github.com>2019-04-11 18:33:14 +0200
commitf84a04e1752f80c9ae97727b55b5fa9219f8491b (patch)
tree94bde526a68b75d6d4a41a116ca8d475c1d95fe1 /logd
parent99c88e4846b752d80ac3590c0ab11adc3d84dc9c (diff)
parent464518bdd46dc109af35f8a4d2f4ee432cb4cf56 (diff)
Merge pull request #9055 from vespa-engine/arnej/less-debug-logs
produce less debug logs from retention enforcer
Diffstat (limited to 'logd')
-rwxr-xr-xlogd/src/apps/retention/retention-enforcer.sh19
1 files changed, 12 insertions, 7 deletions
diff --git a/logd/src/apps/retention/retention-enforcer.sh b/logd/src/apps/retention/retention-enforcer.sh
index d1defacd4e3..a8f3730f4ce 100755
--- a/logd/src/apps/retention/retention-enforcer.sh
+++ b/logd/src/apps/retention/retention-enforcer.sh
@@ -15,11 +15,15 @@ RETAIN_DAYS=30
# The "database" holds lines with format "timestamp /path/to/logfile"
# where "timestamp" is just seconds since epoch.
+log_msg() {
+ echo "$0 [$$]" "$@"
+}
+
prereq_dir() {
if [ -d $1 ] && [ -w $1 ]; then
:
else
- echo "$0: missing directory '$1' in '`pwd`'" >&2
+ log_msg ERROR "missing directory '$1' in '`pwd`'" >&2
exit 1
fi
}
@@ -33,13 +37,14 @@ ensure_dir () {
if [ -d $1 ] && [ -w $1 ]; then
return 0
fi
- echo "Creating directory '$1' in '`pwd`'"
+ log_msg INFO "Creating directory '$1' in '`pwd`'"
mkdir -p $1 || exit 1
}
prepare_stuff() {
check_prereqs
- exec > $DBGF.$$.log 2>&1
+ ensure_dir ${DBGF%/*}
+ exec >> $DBGF.log 2>&1
ensure_dir $DBDIR
}
@@ -68,7 +73,7 @@ check_pidfile() {
ps -p $pid >/dev/null 2>&1 || return 1
proc=$(ps -p $pid 2>&1)
case $proc in *retention*) ;; *) return 1;; esac
- echo "$0 [$$]: Yielding my place to pid '$pid'"
+ log_msg INFO "Yielding my place to pid '$pid'"
exit 1
fi
}
@@ -82,7 +87,7 @@ maybe_collect() {
logfilename=$2
if bad_timestamp "$1"; then
- echo "WARNING: bad timestamp '$timestamp' for logfilename '$logfilename'"
+ log_msg WARNING "bad timestamp '$timestamp' for logfilename '$logfilename'"
return
fi
@@ -92,7 +97,7 @@ maybe_collect() {
lim2=$(($mod_time + $add))
if [ $lim1 -lt $now ] && [ $lim2 -lt $now ]; then
- echo "Collect logfile '$logfilename' timestamped $timestamp modified $mod_time"
+ log_msg INFO "Collect logfile '$logfilename' timestamped $timestamp modified $mod_time"
rm -f "$logfilename"
fi
}
@@ -124,10 +129,10 @@ process_all() {
mainloop() {
while true; do
+ check_pidfile
mark_pid
process_all
sleep 3600
- check_pidfile
done
}