blob: d11846f15f853d8ff7d90f8909bc3cfd51a109f7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#!/bin/bash
source "${BASH_ARGV0%/*}"/common
RAW_DATA_PATH="/var/log/system-stats"
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
|