diff options
-rwxr-xr-x | monitoring/monitoring.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/monitoring/monitoring.sh b/monitoring/monitoring.sh new file mode 100755 index 0000000..b09489d --- /dev/null +++ b/monitoring/monitoring.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail + +SLEEPTIME=60 + +cd "$(dirname "$0")" + +stat --version 2>/dev/null | grep -q 'GNU coreutils' || { + echo >&2 "Not gnu stat!"; exit 1; +} + +logf_dbsize="log_dbsize.txt" +[[ -f $logf_dbsize ]] && echo "Appending to '$logf_dbsize'" || echo "Logging to '$logf_dbsize'" + +echo "Monitoring: logging every $SLEEPTIME seconds" + +while true; do + now="$EPOCHSECONDS" + dbsize="$(stat -c '%s' ../db.db)" + echo "$now $dbsize" >>"$logf_dbsize" + + sleep "$SLEEPTIME" +done |