-
Notifications
You must be signed in to change notification settings - Fork 8
/
create-png
63 lines (49 loc) · 1.7 KB
/
create-png
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
#!/bin/bash
cd /home/juerd
ARGS2=(
-l 0
-v "Watt"
--units-exponent 0
DEF:Watt=kWh.rrd:kWh:AVERAGE
"CDEF:weekend=LTIME,604800,%,172800,345600,LIMIT,UN,UNKN,Watt,*,INF,IF"
"CDEF:night=LTIME,86400,%,25200,82800,LIMIT,UN,INF,UNKN,Watt,*,IF"
"CDEF:offpeak=weekend,ISINF,night,ISINF,+,INF,*"
AREA:offpeak#000040:""
"CDEF:Low=Watt,0,750,LIMIT"
"CDEF:Mid=Watt,750,1500,LIMIT"
"CDEF:High=Watt,1500,3000,LIMIT"
"CDEF:VHigh=Watt,3000,15000,LIMIT"
-c BACK#000000 -c CANVAS#202020 -c MGRID#00ff00 -c GRID#008000 -c FONT#00ff00
-c AXIS#00ff00 -c ARROW#00ff00 -c SHADEA#000000 -c SHADEB#000000
AREA:Low#00ff00:"0 - 750"
AREA:Mid#ffbf00:"750 - 1500"
AREA:High#FF0000:"1500 - 3000"
AREA:VHigh#ffffff:"> 3kW"
"GPRINT:Watt:AVERAGE:Average usage\: %.0lf W"
)
#rrdtool graph power.png "${ARGS[@]}" -s 18:00 -e 20:10
#exit
if [ "X$1" == "Xdetail" ]; then
nice -n 10 \
rrdtool graph temp$$.png -w 900 -h 300 "${ARGS2[@]}" -s end-6h -e now "GPRINT:Watt:LAST:Current usage\: %.0lf W" \
&& mv temp$$.png power-6h.png
fi
if [ "X$1" == "Xhourly" ]; then
ARGS3=(
-w 400 -h 200
"CDEF:euro=Watt,offpeak,0.1915,0.2267,IF,*,1000,/,24,*"
"GPRINT:euro:AVERAGE:Average cost per day\: %.2lf EUR"
)
nice -n 10 \
rrdtool graph temp$$.png "${ARGS2[@]}" "${ARGS3[@]}" -s end-2d -e now \
&& mv temp$$.png power-2d.png
nice -n 10 \
rrdtool graph temp$$.png "${ARGS2[@]}" "${ARGS3[@]}" -s end-14d -e now \
&& mv temp$$.png power-14d.png
nice -n 10 \
rrdtool graph temp$$.png "${ARGS2[@]}" "${ARGS3[@]}" -s end-60d -e now \
&& mv temp$$.png power-60d.png
nice -n 10 \
rrdtool graph temp$$.png "${ARGS2[@]}" "${ARGS3[@]}" -s end-1y -e now \
&& mv temp$$.png power-1y.png
fi