-
Notifications
You must be signed in to change notification settings - Fork 6
/
grab-iis-count
executable file
·41 lines (36 loc) · 1.17 KB
/
grab-iis-count
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
#!/bin/sh
# Fetch the table
wget -q --no-check-certificate -O - 'https://www.iis.se/domaner/statistik/tillvaxt?chart=per-type' |
# There are several 'var jsonData' lines; print the one that occurs just
# before the DNSSEC caption
awk '
/var jsonData/ { myline = $0 }
/text: .*DNSSEC.* 90 dagar/ {
print myline $0
exit
}
' |
# result (one line with many items):
# ...},{"value":"355501","key":"2014-12-01"},{"value":"355541","key":"2014-12-02"},{...
# split the json dicts
sed 's/},{/\n/g' |
# result (many lines with one item):
# "value":"355501","key":"2014-12-01"
# this script is expected to return only the latest count
# remove this filter to return all Swedish data in the graph
tail -n 1 |
# result (one line):
# "value":"355501","key":"2014-12-01"
# extract the count and the date
sed 's/.*"value":"\([0-9]\+\)","key":"\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\)".*/\1 \2/' |
# result (one line):
# 355501 2014-12-01
# convert to unix time
while read count date; do
timestamp=`date +%s -d "$date 00:00:00 UTC" 2> /dev/null`
if [ $? = 0 ]; then
echo "$timestamp $count"
fi
done
# result (one line):
# 1417392000 355501