Ich habe nun durch das Spicken bei euch beiden ein saberen chart, so wie er sein soll.
Mit diesem Script ist eine gute Auswertung unter openwrt möglich. Ich habe dazu einen usbstick gemountet.
Es ist nicht unbedingt nötig, da die Show ca 1,5mb an Flash belegen würde. Man kann die auch gut in den Ram verlagern.
Die rrds können auf dem Flash liegen (600kb) und den Rest im /tmp, also ram.
Es ist natürlich viel zusammengespickt hier aber es ist ein File welches in Verbindung mit dem Sundtek stick die Sache schlank genug über die Bühne bringt
um den Router nicht übermäßig zu beeinflussen.
tools insallieren:
opkg update
opkg install rrdtool rrdtool1 coreutils-timeout
Code: Alles auswählen
#!/bin/sh
# Kann im Flash liegen ~ 600kb
rrdpath="/root/rrd/table"
# Sollte im Ram liegen da diese recht Groß werden und immer neu erzeugt werden können.
pngpath="/tmp/png"
frequenzen="546000000 554000000 562000000 570000000 578000000 586000000 594000000 602000000"
TIMES="end-1d end-1w end-4w end-1y"
create_rrd () {
[ -e $rrdpath ] || mkdir -p $rrdpath
[ -e $pngpath ] || mkdir -p $pngpath
for freq in $frequenzen; do
if [ ! -e $rrdpath/$freq.rrd ];then
rrdtool create $rrdpath/$freq.rrd --step 60 \
DS:bandwidth:GAUGE:105:0:U \
RRA:MIN:0.5:5:288 \
RRA:MIN:0.5:30:336 \
RRA:MIN:0.5:120:372 \
RRA:MIN:0.5:1440:366 \
RRA:MIN:0.5:2880:732 \
RRA:MAX:0.5:5:288 \
RRA:MAX:0.5:30:336 \
RRA:MAX:0.5:120:372 \
RRA:MAX:0.5:1440:366 \
RRA:MAX:0.5:2880:732 \
RRA:AVERAGE:0.5:5:288 \
RRA:AVERAGE:0.5:30:336 \
RRA:AVERAGE:0.5:120:372 \
RRA:AVERAGE:0.5:1440:366 \
RRA:AVERAGE:0.5:2880:732 \
RRA:LAST:0.5:5:288 \
RRA:LAST:0.5:30:336 \
RRA:LAST:0.5:120:372 \
RRA:LAST:0.5:1440:366 \
RRA:LAST:0.5:2880:732
fi
done
}
create_png () {
for time in $TIMES;do
rrdtool graph $pngpath/combined_$time.png \
--title='Wolfenbüttel | Acht Kanäle | 5 Minuten Durchschnitt' \
--vertical-label='Bit pro Sekunde' \
-W "NoGiPi @ $(date '+%F %T %Z')" \
--slope-mode \
--start $time \
-w 1124 -h 500 \
-l 0 -u 444960000 \
--color BACK#ededed \
--color ARROW#000000 \
DEF:b546min=$rrdpath/546000000.rrd:bandwidth:MIN \
DEF:b546avg=$rrdpath/546000000.rrd:bandwidth:AVERAGE \
DEF:b546max=$rrdpath/546000000.rrd:bandwidth:MAX \
DEF:b546last=$rrdpath/546000000.rrd:bandwidth:LAST \
DEF:b554min=$rrdpath/554000000.rrd:bandwidth:MIN \
DEF:b554avg=$rrdpath/554000000.rrd:bandwidth:AVERAGE \
DEF:b554max=$rrdpath/554000000.rrd:bandwidth:MAX \
DEF:b554last=$rrdpath/554000000.rrd:bandwidth:LAST \
DEF:b562min=$rrdpath/562000000.rrd:bandwidth:MIN \
DEF:b562avg=$rrdpath/562000000.rrd:bandwidth:AVERAGE \
DEF:b562max=$rrdpath/562000000.rrd:bandwidth:MAX \
DEF:b562last=$rrdpath/562000000.rrd:bandwidth:LAST \
DEF:b570min=$rrdpath/570000000.rrd:bandwidth:MIN \
DEF:b570avg=$rrdpath/570000000.rrd:bandwidth:AVERAGE \
DEF:b570max=$rrdpath/570000000.rrd:bandwidth:MAX \
DEF:b570last=$rrdpath/570000000.rrd:bandwidth:LAST \
DEF:b578min=$rrdpath/578000000.rrd:bandwidth:MIN \
DEF:b578avg=$rrdpath/578000000.rrd:bandwidth:AVERAGE \
DEF:b578max=$rrdpath/578000000.rrd:bandwidth:MAX \
DEF:b578last=$rrdpath/578000000.rrd:bandwidth:LAST \
DEF:b586min=$rrdpath/586000000.rrd:bandwidth:MIN \
DEF:b586avg=$rrdpath/586000000.rrd:bandwidth:AVERAGE \
DEF:b586max=$rrdpath/586000000.rrd:bandwidth:MAX \
DEF:b586last=$rrdpath/586000000.rrd:bandwidth:LAST \
DEF:b594min=$rrdpath/594000000.rrd:bandwidth:MIN \
DEF:b594avg=$rrdpath/594000000.rrd:bandwidth:AVERAGE \
DEF:b594max=$rrdpath/594000000.rrd:bandwidth:MAX \
DEF:b594last=$rrdpath/594000000.rrd:bandwidth:LAST \
DEF:b602min=$rrdpath/602000000.rrd:bandwidth:MIN \
DEF:b602avg=$rrdpath/602000000.rrd:bandwidth:AVERAGE \
DEF:b602max=$rrdpath/602000000.rrd:bandwidth:MAX \
DEF:b602last=$rrdpath/602000000.rrd:bandwidth:LAST \
AREA:444960000#c9feb8 \
STACK:55040000#feb8b8 \
COMMENT:"Separate Channel Statistics\n" \
AREA:b546avg#fffc00:'546 Mhz ' \
GPRINT:b546avg:AVERAGE:"Avg %5.2lf %s " \
GPRINT:b546min:MIN:"Min %5.2lf %s " \
GPRINT:b546max:MAX:"Max %5.2lf %s" \
GPRINT:b546last:LAST:" Last %5.2lf %s\n" \
STACK:b554avg#ffc600:'554 Mhz ' \
GPRINT:b554avg:AVERAGE:"Avg %5.2lf %s " \
GPRINT:b554min:MIN:"Min %5.2lf %s " \
GPRINT:b554max:MAX:"Max %5.2lf %s" \
GPRINT:b554last:LAST:" Last %5.2lf %s\n" \
STACK:b562avg#ffa200:'562 Mhz ' \
GPRINT:b562avg:AVERAGE:"Avg %5.2lf %s " \
GPRINT:b562min:MIN:"Min %5.2lf %s " \
GPRINT:b562max:MAX:"Max %5.2lf %s" \
GPRINT:b562last:LAST:" Last %5.2lf %s\n" \
STACK:b570avg#ff6c00:'570 Mhz ' \
GPRINT:b570avg:AVERAGE:"Avg %5.2lf %s " \
GPRINT:b570min:MIN:"Min %5.2lf %s " \
GPRINT:b570max:MAX:"Max %5.2lf %s" \
GPRINT:b570last:LAST:" Last %5.2lf %s\n" \
STACK:b578avg#00c6ff:'578 Mhz ' \
GPRINT:b578avg:AVERAGE:"Avg %5.2lf %s " \
GPRINT:b578min:MIN:"Min %5.2lf %s " \
GPRINT:b578max:MAX:"Max %5.2lf %s" \
GPRINT:b578last:LAST:" Last %5.2lf %s\n" \
STACK:b586avg#0090ff:'586 Mhz ' \
GPRINT:b586avg:AVERAGE:"Avg %5.2lf %s " \
GPRINT:b586min:MIN:"Min %5.2lf %s " \
GPRINT:b586max:MAX:"Max %5.2lf %s" \
GPRINT:b586last:LAST:" Last %5.2lf %s\n" \
STACK:b594avg#0066ff:'594 Mhz ' \
GPRINT:b594avg:AVERAGE:"Avg %5.2lf %s " \
GPRINT:b594min:MIN:"Min %5.2lf %s " \
GPRINT:b594max:MAX:"Max %5.2lf %s" \
GPRINT:b594last:LAST:" Last %5.2lf %s\n" \
STACK:b602avg#0042ff:'602 Mhz ' \
GPRINT:b602avg:AVERAGE:"Avg %5.2lf %s " \
GPRINT:b602min:MIN:"Min %5.2lf %s " \
GPRINT:b602max:MAX:"Max %5.2lf %s" \
GPRINT:b602last:LAST:" Last %5.2lf %s\n" \
COMMENT:"Aggregierte Frequenzstatistiken\n" \
HRULE:444960000#000000:'Grenze (444,96 Mbit/s)'
done
}
update_data () {
for freq in $frequenzen; do
lock=$(/opt/bin/mediaclient -m DVBC -f $freq -S 6952000 -M Q256 | grep 'LOCKED')
if [ -z "$lock" ]; then
logger "FAILURE: Not possible to lock ($freq) MHz"
export bw$freq=0
else
bw=$(timeout 3s /opt/bin/mediaclient --cat /dev/dvb/adapter0/dvr0 | timeout 2s /opt/bin/mediaclient --pipecount=1000 2>&1 | awk '{print $3}')
bw=$(echo $bw | awk '{print $1}')
let bw=bw*8
rrdtool update $rrdpath/$freq.rrd N:$bw
fi
done
}
echo 0 > /sys/module/dvb_core/parameters/dvb_powerdown_on_sleep
[ "$(ps | grep -c mediasrv)" -lt 2 ] && /opt/bin/mediasrv -d
case "$1" in
data)
create_rrd
update_data
;;
png)
create_png
;;
esac
Code: Alles auswählen
* * * * * /root/rrd.sh data
*/120 * * * * nice -n20 /root/rrd.sh png
[ externes Bild ]
[ externes Bild ]