| 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 | rm -f $OUTPUTDIR/$1 |
| 30 | |
| 31 | rrdtool graph $OUTPUTDIR/$1 \ |
| 32 | -s $3 \ |
| 33 | -e $4 \ |
| 34 | -t "$2" \ |
| 35 | -h 200 \ |
| 36 | -w 600 \ |
| 37 | -a PNG \ |
| 38 | -v "Upstream / Downstream" \ |
| 39 | --upper-limit 16000 --rigid \ |
| 40 | DEF:dactual=$DSLDB:dactual:AVERAGE \ |
| 41 | DEF:dattainable=$DSLDB:dattainable:AVERAGE \ |
| 42 | DEF:uactual=$DSLDB:uactual:AVERAGE \ |
| 43 | DEF:uattainable=$DSLDB:uattainable:AVERAGE \ |
| 44 | DEF:uLine=$DSLDB:uLine:AVERAGE \ |
| 45 | DEF:dLine=$DSLDB:dLine:AVERAGE \ |
| 46 | DEF:uSNR=$DSLDB:uSNR:AVERAGE \ |
| 47 | DEF:dSNR=$DSLDB:dSNR:AVERAGE \ |
| 48 | DEF:dHEC=$DSLDB:dHEC:MAX \ |
| 49 | DEF:dCRC=$DSLDB:dCRC:MAX \ |
| 50 | CDEF:dCRCScaled=dCRC,20000,* \ |
| 51 | CDEF:dHECScaled=dHEC,20000,* \ |
| 52 | CDEF:uLineScaled=uLine,10,* \ |
| 53 | CDEF:dLineScaled=dLine,10,* \ |
| 54 | CDEF:uSNRScaled=uSNR,80,* \ |
| 55 | CDEF:dSNRScaled=dSNR,80,* \ |
| 56 | CDEF:dHECOutline=dHECScaled,dCRCScaled,dHECScaled,+,UNKN,IF \ |
| 57 | \ |
| 58 | COMMENT:" \t\t\t" \ |
| 59 | COMMENT:"Cur\: \t\t" \ |
| 60 | COMMENT:"Min\: \t\t" \ |
| 61 | COMMENT:"Avg\: \t\t" \ |
| 62 | COMMENT:"Max\: \n" \ |
| 63 | \ |
| 64 | AREA:dattainable#54EC48CC \ |
| 65 | LINE1:dattainable#24BC14:"dattainable\t\t" \ |
| 66 | GPRINT:dattainable:LAST:"%1.0lf kBps\t" \ |
| 67 | GPRINT:dattainable:MIN:"%1.0lf kBps\t" \ |
| 68 | GPRINT:dattainable:AVERAGE:"%1.0lf kBps\t" \ |
| 69 | GPRINT:dattainable:MAX:"%1.0lf kBps\n" \ |
| 70 | \ |
| 71 | LINE1:dactual#ff3535:"dactual\t\t" \ |
| 72 | GPRINT:dactual:LAST:"%1.0lf kBps\t" \ |
| 73 | GPRINT:dactual:MIN:"%1.0lf kBps\t" \ |
| 74 | GPRINT:dactual:AVERAGE:"%1.0lf kBps\t" \ |
| 75 | GPRINT:dactual:MAX:"%1.0lf kBps\n" \ |
| 76 | \ |
| 77 | AREA:uattainable#48C4EC \ |
| 78 | LINE1:uattainable#1598C3:"uattainable\t\t" \ |
| 79 | GPRINT:uattainable:LAST:"%1.0lf kBps\t" \ |
| 80 | GPRINT:uattainable:MIN:"%1.0lf kBps\t" \ |
| 81 | GPRINT:uattainable:AVERAGE:"%1.0lf kBps\t" \ |
| 82 | GPRINT:uattainable:MAX:"%1.0lf kBps\n" \ |
| 83 | \ |
| 84 | LINE1:uactual#0000FF:"uactual\t\t" \ |
| 85 | GPRINT:uactual:LAST:"%1.0lf kBps\t" \ |
| 86 | GPRINT:uactual:MIN:"%1.0lf kBps\t" \ |
| 87 | GPRINT:uactual:AVERAGE:"%1.0lf kBps\t" \ |
| 88 | GPRINT:uactual:MAX:"%1.0lf kBps\n" \ |
| 89 | \ |
| 90 | AREA:dHECScaled#EC9D48AA:"Header Errors\t" \ |
| 91 | GPRINT:dHEC:LAST:"%1.0lf \t\t" \ |
| 92 | GPRINT:dHEC:MIN:"%1.0lf \t\t" \ |
| 93 | GPRINT:dHEC:AVERAGE:"%1.0lf \t\t" \ |
| 94 | GPRINT:dHEC:MAX:"%1.0lf \n" \ |
| 95 | \ |
| 96 | AREA:dCRCScaled#ECD748AA:"CRC Errors\t\t":STACK \ |
| 97 | LINE1:dHECScaled#CC7016AA \ |
| 98 | LINE1:dHECOutline#C9B215AA \ |
| 99 | GPRINT:dCRC:LAST:"%1.0lf \t\t" \ |
| 100 | GPRINT:dCRC:MIN:"%1.0lf \t\t" \ |
| 101 | GPRINT:dCRC:AVERAGE:"%1.0lf \t\t" \ |
| 102 | GPRINT:dCRC:MAX:"%1.0lf \n" \ |
| 103 | \ |
| 104 | LINE1:uSNRScaled#DE48EC:"uSNR\t\t\t" \ |
| 105 | GPRINT:uSNR:LAST:"%1.0lf \t\t" \ |
| 106 | GPRINT:uSNR:MIN:"%1.0lf \t\t" \ |
| 107 | GPRINT:uSNR:AVERAGE:"%1.0lf \t\t" \ |
| 108 | GPRINT:uSNR:MAX:"%1.0lf \n" \ |
| 109 | \ |
| 110 | LINE1:dSNRScaled#B415C7:"dSNR\t\t\t" \ |
| 111 | GPRINT:dSNR:LAST:"%1.0lf \t\t" \ |
| 112 | GPRINT:dSNR:MIN:"%1.0lf \t\t" \ |
| 113 | GPRINT:dSNR:AVERAGE:"%1.0lf \t\t" \ |
| 114 | GPRINT:dSNR:MAX:"%1.0lf \n" \ |
| 115 | \ |
| 116 | LINE1:uLineScaled#7648EC:"uLine\t\t\t" \ |
| 117 | GPRINT:uLine:LAST:"%1.0lf \t\t" \ |
| 118 | GPRINT:uLine:MIN:"%1.0lf \t\t" \ |
| 119 | GPRINT:uLine:AVERAGE:"%1.0lf \t\t" \ |
| 120 | GPRINT:uLine:MAX:"%1.0lf \n" \ |
| 121 | \ |
| 122 | LINE1:dLineScaled#4D18E4:"dLine\t\t\t" \ |
| 123 | GPRINT:dLine:LAST:"%1.0lf \t\t" \ |
| 124 | GPRINT:dLine:MIN:"%1.0lf \t\t" \ |
| 125 | GPRINT:dLine:AVERAGE:"%1.0lf \t\t" \ |
| 126 | GPRINT:dLine:MAX:"%1.0lf \n" |
| 127 | } |
| 128 | |
| 129 | # Graph LTE values |
| 130 | # |
| 131 | # $1 - filenme |
| 132 | # $2 - title |
| 133 | # $3 - starttime |
| 134 | # $4 - endtime |
| 135 | function drawLTE { |
| 136 | rm -f $OUTPUTDIR/$1 |
| 137 | |
| 138 | rrdtool graph $OUTPUTDIR/$1 \ |
| 139 | -s $3 \ |
| 140 | -e $4 \ |
| 141 | -t "$2" \ |
| 142 | -h 200 \ |
| 143 | -w 548 \ |
| 144 | -a PNG \ |
| 145 | -v "rsrp" \ |
| 146 | --right-axis 0.1:0 \ |
| 147 | --right-axis-label "rsrq" \ |
| 148 | DEF:rsrq=$LTEDB:rsrq:AVERAGE \ |
| 149 | DEF:rsrp=$LTEDB:rsrp:AVERAGE \ |
| 150 | CDEF:rsrqScaled=rsrq,10,* \ |
| 151 | \ |
| 152 | COMMENT:" \t\t\t" \ |
| 153 | COMMENT:"Cur\: \t\t" \ |
| 154 | COMMENT:"Min\: \t\t" \ |
| 155 | COMMENT:"Avg\: \t\t" \ |
| 156 | COMMENT:"Max\: \n" \ |
| 157 | \ |
| 158 | AREA:rsrqScaled#48C4EC \ |
| 159 | LINE1:rsrqScaled#1598C3:"rsrq\t\t\t" \ |
| 160 | GPRINT:rsrq:LAST:"%1.0lf dB\t\t" \ |
| 161 | GPRINT:rsrq:MAX:"%1.0lf dB\t\t" \ |
| 162 | GPRINT:rsrq:AVERAGE:"%1.0lf dB\t\t" \ |
| 163 | GPRINT:rsrq:MIN:"%1.0lf dB\n" \ |
| 164 | \ |
| 165 | AREA:rsrp#54EC48CC \ |
| 166 | LINE1:rsrp#24BC14:"rsrp \t\t\t" \ |
| 167 | GPRINT:rsrp:LAST:"%1.0lf dB\t\t" \ |
| 168 | GPRINT:rsrp:MAX:"%1.0lf dB\t\t" \ |
| 169 | GPRINT:rsrp:AVERAGE:"%1.0lf dB\t\t" \ |
| 170 | GPRINT:rsrp:MIN:"%1.0lf dB\n" |
| 171 | } |
| 172 | |
| 173 | drawDSL dsl-1h.png "DSL line status - 1 hour" end-1h now & |
| 174 | drawDSL dsl-day.png "DSL line status - by day" end-24h now & |
| 175 | drawDSL dsl-week.png "DSL line status - by week" end-168h now & |
| 176 | |
| 177 | drawLTE lteinfo-1h.png "LTE status - 1 hour" end-1h now & |
| 178 | drawLTE lteinfo-day.png "LTE status - by day" end-24h now & |
| 179 | drawLTE lteinfo-week.png "LTE status - by week" end-168h now & |
| 180 | |
| 181 | for job in `jobs -p` |
| 182 | do |
| 183 | wait $job |
| 184 | done |