forked from lynckia/ackuaria
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinfo_ackuaria.sh
executable file
·104 lines (83 loc) · 3.2 KB
/
info_ackuaria.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
ACKUARIA_URL="" #HOST URL http://hostname:port/ackuaria
# DATE FORMAT: YYYY/DD/MM-hh/mm
DATE=`date +%Y%m%d%H%M%S`
SCRIPT=`pwd`/$0
PATHNAME=`dirname $SCRIPT`
ROOT=$PATHNAME/..
REPORT_DIR=$ROOT/reports/
FILE_NAME=$REPORT_DIR$DATE"_report.json"
usage()
{
cat << EOF
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Welcome to the help page of the Ackuaria Stats Script. +
+ +
+ Commands: +
+ +
+ . First Parameter: Level of detail +
+ -g --> General information +
+ -d --> Add Detailed information by Room +
+ +
+ . Second Parameter: Query by dates +
+ -t --> Total information +
+ -q INITDATE FINALDATE --> Between two dates +
+ -i INITDATE --> Since date +
+ -f FINALDATE --> Until date +
+ +
+ Response format: JSON +
+ Dates format: DD/MM/YYYY-hh:mm +
+ If you dont specificate any time, 00:00 will be used +
+ Please, always use double digits for days, month and time +
+ +
+ Example: ./info_ackuaria.sh -d -i 01/07/2014-07:53 +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EOF
}
case "$1" in
-g)
TYPE="general"
;;
-d) TYPE="detailed"
;;
*) usage
;;
esac
case "$2" in
-t)
echo "Showing total info"
URL=""$ACKUARIA_URL"/info/"$TYPE""
json_resp=$(curl -H "Accept: application/json" -H "Content-Type: application/json" -X GET "$URL")
echo "$json_resp" >> "$FILE_NAME"
;;
-q)
echo "Showing info query between specified dates..."
init="$3"
final="$4"
INITTIME=$(echo "$init" | sed 's%/%%g;s%-%%g;s%:%%g')
FINALTIME=$(echo "$final" | sed 's%/%%g;s%-%%g;s%:%%g')
URL=""$ACKUARIA_URL"/info/"$TYPE"?init="$INITTIME"&final="$FINALTIME""
json_resp=$(curl -H "Accept: application/json" -H "Content-Type: application/json" -X GET "$URL")
echo "$json_resp" >> "$FILE_NAME"
;;
-i)
echo "Showing info query since date..."
init="$3"
INITTIME=$(echo "$init" | sed 's%/%%g;s%-%%g;s%:%%g')
URL=""$ACKUARIA_URL"/info/"$TYPE"?init="$INITTIME""
json_resp=$(curl -H "Accept: application/json" -H "Content-Type: application/json" -X GET "$URL")
echo "$json_resp" >> "$FILE_NAME"
;;
-f)
echo "Showing info query until date..."
final="$3"
FINALTIME=$(echo "$final" | sed 's%/%%g;s%-%%g;s%:%%g')
URL=""$ACKUARIA_URL"/info/"$TYPE"?final="$FINALTIME""
json_resp=$(curl -H "Accept: application/json" -H "Content-Type: application/json" -X GET "$URL")
echo "$json_resp" >> "$FILE_NAME"
;;
*) echo " Error: Please, specify the second parameter"
usage
;;
esac
exit 0