diff options
author | Tom Smeding <tom.smeding@gmail.com> | 2020-08-30 14:50:11 +0200 |
---|---|---|
committer | Tom Smeding <tom.smeding@gmail.com> | 2020-08-30 14:50:11 +0200 |
commit | 860e402d6372a0ede1cf97ff5af358fc339b2b3a (patch) | |
tree | e092beb1b1674fa8f5d89be75ccbd938b80253cb | |
parent | acd8cf7e1309da8946ca57847e665e3edf970249 (diff) |
Add monitoring script for server
-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 |