2021-05-20 22:11:48 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
for monitor in storage/data/*; do
|
2021-06-10 22:57:41 +02:00
|
|
|
if [[ "$(tail -n1 < $monitor | jq -r '.status')" == 1 ]]; then
|
2021-05-20 22:11:48 +02:00
|
|
|
label="$(tail -n1 < $monitor | jq -r '.label')"
|
|
|
|
label_sha="$(shasum <<< "$label" | cut -c 1-16)"
|
|
|
|
if [[ ! -f "storage/reports/$label_sha" ]]; then
|
|
|
|
for file in storage/appconfig/every_*.json; do
|
|
|
|
data="$(jq -r '.[] | select(.label == "'"$label"'")' $file)"
|
|
|
|
|
|
|
|
if [[ "$data" != '' ]]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
notify="$(jq -r '.notify[]' <<< "$data")"
|
|
|
|
|
|
|
|
if [[ "$notify" != '' ]]; then
|
|
|
|
source "${cfg[namespace]}/code/func.sh"
|
|
|
|
|
|
|
|
notify "$notify" 1
|
|
|
|
touch "storage/reports/$label_sha"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|