Commit | Line | Data |
---|---|---|
9d6ff8a8 S |
1 | #!/bin/bash |
2 | set -eu | |
3 | # thanks to Thomas Mellenthin @ https://github.com/melle/l33tport/blob/master/rrdtool/graphRRDBs.sh | |
4 | DSLDB=/home/rrd/rrd/dsl.rrd | |
5 | LTEDB=/home/rrd/rrd/lteinfo.rrd | |
6 | OUTPUTDIR=/var/www/stats | |
7 | ||
8 | # Pleasant colors from | |
9 | # https://oss.oetiker.ch/rrdtool-trac/wiki/OutlinedAreaGraph | |
10 | # | |
11 | # LIGHT DARK | |
12 | # RED #EA644A #CC3118 | |
13 | # ORANGE #EC9D48 #CC7016 | |
14 | # YELLOW #ECD748 #C9B215 | |
15 | # GREEN #54EC48 #24BC14 | |
16 | # BLUE #48C4EC #1598C3 | |
17 | # PINK #DE48EC #B415C7 | |
18 | # PURPLE #7648EC #4D18E4 | |
19 | ||
20 | ||
21 | ||
22 | # Graphs DSL values. The scaling is pretty bogus. | |
23 | # | |
24 | # $1 - filenme | |
25 | # $2 - title | |
26 | # $3 - starttime | |
27 | # $4 - endtime | |
28 | function drawDSL | |
29 | { | |
30 | rm -f $OUTPUTDIR/$1 | |
31 | ||
32 | rrdtool graph $OUTPUTDIR/$1 \ | |
33 | -s $3 \ | |
34 | -e $4 \ | |
35 | -t "$2" \ | |
36 | -h 200 \ | |
37 | -w 600 \ | |
38 | -a PNG \ | |
39 | -v "Upstream / Downstream" \ | |
40 | --upper-limit 16000 --rigid \ | |
41 | DEF:dactual=$DSLDB:dactual:AVERAGE \ | |
42 | DEF:dattainable=$DSLDB:dattainable:AVERAGE \ | |
43 | DEF:uactual=$DSLDB:uactual:AVERAGE \ | |
44 | DEF:uattainable=$DSLDB:uattainable:AVERAGE \ | |
45 | DEF:uLine=$DSLDB:uLine:AVERAGE \ | |
46 | DEF:dLine=$DSLDB:dLine:AVERAGE \ | |
47 | DEF:uSNR=$DSLDB:uSNR:AVERAGE \ | |
48 | DEF:dSNR=$DSLDB:dSNR:AVERAGE \ | |
49 | DEF:dHEC=$DSLDB:dHEC:MAX \ | |
50 | DEF:dCRC=$DSLDB:dCRC:MAX \ | |
51 | CDEF:dCRCScaled=dCRC,20000,* \ | |
52 | CDEF:dHECScaled=dHEC,20000,* \ | |
53 | CDEF:uLineScaled=uLine,10,* \ | |
54 | CDEF:dLineScaled=dLine,10,* \ | |
55 | CDEF:uSNRScaled=uSNR,80,* \ | |
56 | CDEF:dSNRScaled=dSNR,80,* \ | |
57 | CDEF:dHECOutline=dHECScaled,dCRCScaled,dHECScaled,+,UNKN,IF \ | |
58 | \ | |
59 | COMMENT:" \t\t\t" \ | |
60 | COMMENT:"Cur\: \t\t" \ | |
61 | COMMENT:"Min\: \t\t" \ | |
62 | COMMENT:"Avg\: \t\t" \ | |
63 | COMMENT:"Max\: \n" \ | |
64 | \ | |
65 | AREA:dattainable#54EC48CC \ | |
66 | LINE1:dattainable#24BC14:"dattainable\t\t" \ | |
67 | GPRINT:dattainable:LAST:"%1.0lf kBps\t" \ | |
68 | GPRINT:dattainable:MIN:"%1.0lf kBps\t" \ | |
69 | GPRINT:dattainable:AVERAGE:"%1.0lf kBps\t" \ | |
70 | GPRINT:dattainable:MAX:"%1.0lf kBps\n" \ | |
71 | \ | |
72 | LINE1:dactual#ff3535:"dactual\t\t" \ | |
73 | GPRINT:dactual:LAST:"%1.0lf kBps\t" \ | |
74 | GPRINT:dactual:MIN:"%1.0lf kBps\t" \ | |
75 | GPRINT:dactual:AVERAGE:"%1.0lf kBps\t" \ | |
76 | GPRINT:dactual:MAX:"%1.0lf kBps\n" \ | |
77 | \ | |
78 | AREA:uattainable#48C4EC \ | |
79 | LINE1:uattainable#1598C3:"uattainable\t\t" \ | |
80 | GPRINT:uattainable:LAST:"%1.0lf kBps\t" \ | |
81 | GPRINT:uattainable:MIN:"%1.0lf kBps\t" \ | |
82 | GPRINT:uattainable:AVERAGE:"%1.0lf kBps\t" \ | |
83 | GPRINT:uattainable:MAX:"%1.0lf kBps\n" \ | |
84 | \ | |
85 | LINE1:uactual#0000FF:"uactual\t\t" \ | |
86 | GPRINT:uactual:LAST:"%1.0lf kBps\t" \ | |
87 | GPRINT:uactual:MIN:"%1.0lf kBps\t" \ | |
88 | GPRINT:uactual:AVERAGE:"%1.0lf kBps\t" \ | |
89 | GPRINT:uactual:MAX:"%1.0lf kBps\n" \ | |
90 | \ | |
91 | AREA:dHECScaled#EC9D48AA:"Header Errors\t" \ | |
92 | GPRINT:dHEC:LAST:"%1.0lf \t\t" \ | |
93 | GPRINT:dHEC:MIN:"%1.0lf \t\t" \ | |
94 | GPRINT:dHEC:AVERAGE:"%1.0lf \t\t" \ | |
95 | GPRINT:dHEC:MAX:"%1.0lf \n" \ | |
96 | \ | |
97 | AREA:dCRCScaled#ECD748AA:"CRC Errors\t\t":STACK \ | |
98 | LINE1:dHECScaled#CC7016AA \ | |
99 | LINE1:dHECOutline#C9B215AA \ | |
100 | GPRINT:dCRC:LAST:"%1.0lf \t\t" \ | |
101 | GPRINT:dCRC:MIN:"%1.0lf \t\t" \ | |
102 | GPRINT:dCRC:AVERAGE:"%1.0lf \t\t" \ | |
103 | GPRINT:dCRC:MAX:"%1.0lf \n" \ | |
104 | \ | |
105 | LINE1:uSNRScaled#DE48EC:"uSNR\t\t\t" \ | |
106 | GPRINT:uSNR:LAST:"%1.0lf \t\t" \ | |
107 | GPRINT:uSNR:MIN:"%1.0lf \t\t" \ | |
108 | GPRINT:uSNR:AVERAGE:"%1.0lf \t\t" \ | |
109 | GPRINT:uSNR:MAX:"%1.0lf \n" \ | |
110 | \ | |
111 | LINE1:dSNRScaled#B415C7:"dSNR\t\t\t" \ | |
112 | GPRINT:dSNR:LAST:"%1.0lf \t\t" \ | |
113 | GPRINT:dSNR:MIN:"%1.0lf \t\t" \ | |
114 | GPRINT:dSNR:AVERAGE:"%1.0lf \t\t" \ | |
115 | GPRINT:dSNR:MAX:"%1.0lf \n" \ | |
116 | \ | |
117 | LINE1:uLineScaled#7648EC:"uLine\t\t\t" \ | |
118 | GPRINT:uLine:LAST:"%1.0lf \t\t" \ | |
119 | GPRINT:uLine:MIN:"%1.0lf \t\t" \ | |
120 | GPRINT:uLine:AVERAGE:"%1.0lf \t\t" \ | |
121 | GPRINT:uLine:MAX:"%1.0lf \n" \ | |
122 | \ | |
123 | LINE1:dLineScaled#4D18E4:"dLine\t\t\t" \ | |
124 | GPRINT:dLine:LAST:"%1.0lf \t\t" \ | |
125 | GPRINT:dLine:MIN:"%1.0lf \t\t" \ | |
126 | GPRINT:dLine:AVERAGE:"%1.0lf \t\t" \ | |
127 | GPRINT:dLine:MAX:"%1.0lf \n" \ | |
128 | ||
129 | ||
130 | ||
131 | } | |
132 | ||
133 | # Graph LTE values | |
134 | # | |
135 | # $1 - filenme | |
136 | # $2 - title | |
137 | # $3 - starttime | |
138 | # $4 - endtime | |
139 | function drawLTE | |
140 | { | |
141 | rm -f $OUTPUTDIR/$1 | |
142 | ||
143 | rrdtool graph $OUTPUTDIR/$1 \ | |
144 | -s $3 \ | |
145 | -e $4 \ | |
146 | -t "$2" \ | |
147 | -h 200 \ | |
148 | -w 548 \ | |
149 | -a PNG \ | |
150 | -v "rsrq" \ | |
151 | --right-axis 0.1:0 \ | |
152 | --right-axis-label "rsrp" \ | |
153 | DEF:rsrp=$LTEDB:rsrp:AVERAGE \ | |
154 | DEF:rsrq=$LTEDB:rsrq:AVERAGE \ | |
155 | CDEF:rsrqScaled=rsrq,10,* \ | |
156 | \ | |
157 | COMMENT:" \t\t\t" \ | |
158 | COMMENT:"Cur\: \t\t" \ | |
159 | COMMENT:"Min\: \t\t" \ | |
160 | COMMENT:"Avg\: \t\t" \ | |
161 | COMMENT:"Max\: \n" \ | |
162 | AREA:rsrqScaled#48C4EC \ | |
163 | LINE1:rsrqScaled#1598C3:"rsrq\t\t\t" \ | |
164 | GPRINT:rsrq:LAST:"%1.0lf dB\t\t" \ | |
165 | GPRINT:rsrq:MAX:"%1.0lf dB\t\t" \ | |
166 | GPRINT:rsrq:AVERAGE:"%1.0lf dB\t\t" \ | |
167 | GPRINT:rsrq:MIN:"%1.0lf dB\n" \ | |
168 | AREA:rsrp#54EC48CC \ | |
169 | LINE1:rsrp#24BC14:"rsrp \t\t\t" \ | |
170 | GPRINT:rsrp:LAST:"%1.0lf dB\t\t" \ | |
171 | GPRINT:rsrp:MAX:"%1.0lf dB\t\t" \ | |
172 | GPRINT:rsrp:AVERAGE:"%1.0lf dB\t\t" \ | |
173 | GPRINT:rsrp:MIN:"%1.0lf dB\n" | |
174 | } | |
175 | ||
176 | drawDSL dsl-1h.png "DSL line status - 1 hour" end-1h now & | |
177 | drawDSL dsl-day.png "DSL line status - by day" end-24h now & | |
178 | drawDSL dsl-week.png "DSL line status - by week" end-168h now & | |
179 | ||
180 | drawLTE lteinfo-1h.png "LTE status - 1 hour" end-1h now & | |
181 | drawLTE lteinfo-day.png "LTE status - by day" end-24h now & | |
182 | drawLTE lteinfo-week.png "LTE status - by week" end-168h now & | |
183 | ||
184 | for job in `jobs -p` | |
185 | do | |
186 | wait $job | |
187 | done |