Fix for 1046440: pt-stalk purge_samples slows down checks

Like the bug submitter noted, the fix was simply to make purge_samples
only come into effect if the collection has been triggered.

I added a second purge_samples after the collect loop, which should
maintain the previous behavior for the non-collect case, and purge
any leftover files that passed the threshold during a stalk that
never triggered collection.
This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-12-05 13:20:06 -03:00
parent d2f1742606
commit c9146b3c04

View File

@@ -1189,6 +1189,11 @@ stalk() {
# There will not be enough disk space, so do not collect.
warn "Collect canceled because there will not be enough disk space after collecting another $margin MB"
fi
# Purge old collect files.
if [ -d "$OPT_DEST" ]; then
purge_samples "$OPT_DEST" "$OPT_RETENTION_TIME"
fi
fi
# ##################################################################
@@ -1204,13 +1209,13 @@ stalk() {
# Trigger/check/value is ok, sleep until next check.
sleep_ok "$OPT_INTERVAL"
fi
# Purge old collect file between checks.
if [ -d "$OPT_DEST" ]; then
purge_samples "$OPT_DEST" "$OPT_RETENTION_TIME"
fi
done
# One final purge of old collect files, but only if in collect mode.
if [ "$OPT_COLLECT" -a -d "$OPT_DEST" ]; then
purge_samples "$OPT_DEST" "$OPT_RETENTION_TIME"
fi
# Before exiting, the last collector may still be running.
# Wait for it to finish in case the tool is part of a script,
# or part of a test, so the caller has access to the collected