forked from wklaebe/ffmap-d3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodeplot.cgi
executable file
·47 lines (36 loc) · 1.1 KB
/
nodeplot.cgi
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
#!/bin/sh
NODE=$(echo "${QUERY_STRING}" | tr -dc '0-9A-Fa-f' | tr A-F a-f)
if ! test "${#NODE}" -eq 12 || ! echo "${NODE}" | egrep -q '^[0-9a-f]{12}$' ; then
echo Status: 400 Bad Request
echo
exit 0
fi
NODERRD=/opt/ffmap/nodedb/${NODE}.rrd
NODEPNG=/opt/ffmap/nodeplots/${NODE}.png
if test -r $NODERRD ; then
echo Status: 200 OK
else
echo Status: 404 File not found
NODERRD=/opt/ffmap/nosuchnode.rrd
fi
echo Refresh: 60
echo Content-Type: image/png
echo
# 'AREA:u#0C0:up\\l'
echo "
<RRD::GOODFOR -60><RRD::GRAPH ${NODEPNG}
--lazy
-w 900 -h 400 --full-size-mode
--title 'Freifunk Kiel, Node ${NODE}: Status und Clients über Zeit'
--start -7d --end now
-l 0 -y 1:1
'DEF:clients=${NODERRD}:clients:AVERAGE'
'VDEF:maxc=clients,MAXIMUM'
'CDEF:c=0,clients,ADDNAN'
'CDEF:u=clients,UN,0,maxc,IF'
'CDEF:d=clients,UN,maxc,UN,1,maxc,IF,0,IF'
'AREA:d#F00:down\\l'
'LINE1:c#00F:clients connected\\l'
>" | /usr/bin/rrdcgi --filter - > /dev/null
cat ${NODEPNG}
# EOF