diff options
author | 2023-09-17 21:00:10 +0600 | |
---|---|---|
committer | 2023-09-18 18:08:42 +0600 | |
commit | baf9a8b057eab1bb4595cb5e2ed4cdc05e56b263 (patch) | |
tree | d4c6cf8d557b79ce70299981b6cc4c6cb5339e70 /data | |
parent | 2585fe11a4af7b7e85b4c8a2ae31097a68a8c9ad (diff) | |
download | shopno-os-log-sync-baf9a8b057eab1bb4595cb5e2ed4cdc05e56b263.tar.gz shopno-os-log-sync-baf9a8b057eab1bb4595cb5e2ed4cdc05e56b263.zip |
system-stats: Add script to sync system stats
Signed-off-by: Mubashshir <ahm@jadupc.com>
Diffstat (limited to 'data')
-rwxr-xr-x | data/scripts/sync-stats | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/data/scripts/sync-stats b/data/scripts/sync-stats new file mode 100755 index 0000000..2c4218b --- /dev/null +++ b/data/scripts/sync-stats @@ -0,0 +1,25 @@ +#!/bin/bash +source "${BASH_ARGV0%/*}"/common +RAW_DATA_PATH="/var/log/stat-monitor" + +enmac="$(getaddr "$(getiface "net/e")")" +wlmac="$(getaddr "$(getiface "net/w")")" + +get_logs() +{ + find "$RAW_DATA_PATH/$1" -type f -exec basename -a '{}' + \ + | grep -oE "$2" +} + +find "$RAW_DATA_PATH" -type f \ + | grep -oE '[0-9]+-[0-9]+-[0-9]+_[0-9]+' \ + | while IFS=-_ read -r year month day hour; do + ! [[ $(date +%-H --utc) == "$hour" && $(date --utc --rfc-3339=date) == "$year-$month-$day" ]] || continue + ! communicate /whack/a/mole system/hourly "$wlmac" "$enmac" "$year" "$month" "$day" "$hour" --silent --fail \ + || continue + + echo "Uploading hourly system stats: $year-$month-$day at ${hour}'th hour of UTC" >&2 + communicate /puss/in/boots system/hourly "$wlmac" "$enmac" "$year" "$month" "$day" "$hour" \ + -# --data-urlencode "data@$RAW_DATA_PATH/$year-$month-${day}_$hour.log" \ + || rm "$RAW_DATA_PATH/$year-$month-${day}_$hour.log" + done |