-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsendRingStats.sh
executable file
·51 lines (43 loc) · 1.12 KB
/
sendRingStats.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
cd "$( dirname "${BASH_SOURCE[0]}" )/."
stop=false
config_file=""
_setArgs(){
while [ "$1" != "" ]; do
case $1 in
"-h" | "--help")
echo "options:"
echo "-h, --help show brief help"
echo "-c, --config (optional) define config file to load"
stop=true
;;
"-c" | "--config")
shift
config_file="$1"
;;
esac
shift
done
}
_setArgs $*
if "$stop"; then
return
fi
if [ ! -n "$config_file" ]; then
config_file=$(./getConfig.sh)
fi
if [[ "$config_file" == *"Error"* ]] || [ ! -n "$config_file" ] || [ ! -f "$config_file" ]; then
echo "$config_file does not exists."
return
fi
config=$(jq -c '.' "$config_file")
user=$(echo "$config" | jq -r '.auth.user' | tr -d '"')
password=$(echo "$config" | jq -r '.auth.password' | tr -d '"')
url=$(echo "$config" | jq -r '.url' | tr -d '"')
while true
do
ringStats=$(./getRingStats.sh --config "$config_file" | jq -r -c '.')
echo "$(date)Send ring status: $ringStats"
curl -u "$user":"$password" -X POST -H "Content-Type: application/json" -d "$ringStats" "$url"
sleep 600
done