forked from JackKelly/CurrentCostLogger
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathupdate-power
executable file
·75 lines (70 loc) · 2.11 KB
/
update-power
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
#!/bin/sh
#
# Generate graphs in SVG format for power and temperature, depending how
# script is called
#
# Give arguments for period lengths to use for update, otherwise
# use default (5, 15, 60 minutes, 1 day, 1 week, 1 month, 1 year).
#
db=powertemp.rrd
outdir=.
if [ -z $1 ]; then
periods='5 15 60 1440 10080 43829 525949'
else
periods=$@
fi
if [ `basename $0` = "update-power" ]; then
for i in $periods; do
echo Power $i
rrdtool graph $outdir/power-${i}min.svg \
--start end-${i}min --end now-15s \
-a SVG --width 700 --slope-mode --no-legend \
--color BACK#00000000 \
--color CANVAS#00000000 \
--color SHADEA#00000000 \
--color SHADEB#00000000 \
--color GRID#600000ff \
--color MGRID#800000ff \
--color FONT#a04040ff \
--color AXIS#a04040ff \
--color FRAME#ffffffff \
--color ARROW#a04040ff \
--vertical-label Watts --lower-limit 0 --alt-autoscale-max \
--units-length 4 --units-exponent 0 \
DEF:Power=$db:Power:AVERAGE \
DEF:PowerMin=$db:Power:MIN \
DEF:PowerMax=$db:Power:MAX \
LINE1:PowerMin#00a0e040 \
LINE1:PowerMax#00a0e040 \
LINE1:Power#00ffff \
AREA:Power#00a0e060 \
> /dev/null
done
fi
if [ `basename $0` = "update-temperature" ]; then
for i in $periods; do
echo Temperature $i
rrdtool graph $outdir/temperature-${i}min.svg \
--start end-${i}min --end now-15s \
-a SVG --width 700 --slope-mode --no-legend \
--color BACK#00000000 \
--color CANVAS#00000000 \
--color SHADEA#00000000 \
--color SHADEB#00000000 \
--color GRID#600000ff \
--color MGRID#800000ff \
--color FONT#a04040ff \
--color AXIS#a04040ff \
--color FRAME#ffffffff \
--color ARROW#a04040ff \
--vertical-label °C --lower-limit 0 --alt-autoscale-max \
--units-length 2 --units-exponent 0 \
DEF:Temperature=$db:Temperature:AVERAGE \
DEF:TemperatureMin=$db:Temperature:MIN \
DEF:TemperatureMax=$db:Temperature:MAX \
LINE0.5:TemperatureMin#a0e00040 \
LINE0.5:TemperatureMax#a0e00040 \
LINE1:Temperature#ffff00 \
> /dev/null
done
fi