From 860e402d6372a0ede1cf97ff5af358fc339b2b3a Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 30 Aug 2020 14:50:11 +0200 Subject: Add monitoring script for server --- monitoring/monitoring.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 monitoring/monitoring.sh (limited to 'monitoring') 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 -- cgit v1.2.3-70-g09d2