#!/bin/sh #------------------------------------------------------------------------------ # Creation: bastard # Last Update: $Id$ # Mod: Helper included to be compatible with old version 3.0.x #------------------------------------------------------------------------------ db_path=$1 source=$2 # U.W.: because of compatibility I check for /sbin/route = fli4L 3.0.x !! if [ -f /sbin/ip ] then { intervall=$3 shift } else { intervall=0 } fi shift shift options=$* # U.W.: because of compatibility helper is included here !! rrdheartbeat_change () { rrdheartbeat=`rrdtool info $db_path/$item.rrd|grep heart| cut -d\ -f3|sort -u` rrdheartbeat=`echo $rrdheartbeat|cut -d\ -f1` if [ "$rrdheartbeat" != "$heartbeat" ] then echo "change heartbeat for existing rrd $source - $item from $rrdheartbeat to $heartbeat" rrdds= for rrdidx in `rrdtool info $db_path/$item.rrd |grep "_heartbeat "|cut -d[ -f2|cut -d] -f1` do rrdds="$rrdds `echo -h $rrdidx:$heartbeat`" done rrdtool tune $db_path/$item.rrd $rrdds else echo "use existing rrd for $source - $item" fi } intervall=`echo $intervall|sed "s/[^0-9]//g"` [ $intervall -eq 0 ]&&intervall=1 heartbeat=`echo "$intervall * 120"|bc` rrdaverage="RRA:AVERAGE:0.5:1:1500 \ RRA:AVERAGE:0.5:10:1100 \ RRA:AVERAGE:0.5:30:1600 \ RRA:AVERAGE:0.5:720:800" rrdmin="RRA:MIN:0.5:1:1500 \ RRA:MIN:0.5:10:1100 \ RRA:MIN:0.5:30:1600 \ RRA:MIN:0.5:720:800" rrdmax="RRA:MAX:0.5:1:1500 \ RRA:MAX:0.5:10:1100 \ RRA:MAX:0.5:30:1600 \ RRA:MAX:0.5:720:800" rrdlast="RRA:LAST:0.5:1:1500 \ RRA:LAST:0.5:10:1100 \ RRA:LAST:0.5:30:1600 \ RRA:LAST:0.5:720:800" for item in $options do # # semaphore against spikes in network-graphs # > /var/run/rrdtool.olsr.$item if [ ! -f "$db_path/$item-olsr.rrd" ] then echo "create new rrd for $source - $item" rrdtool create $db_path/$item-olsr.rrd --step 60 \ DS:lq:GAUGE:$heartbeat:0:4294967295 \ DS:nlq:GAUGE:$heartbeat:0:4294967295 \ DS:lost:GAUGE:$heartbeat:0:4294967295 \ $rrdaverage $rrdmax $rrdmin else rrdheartbeat_change fi # # Avoid huge peaks at reboot # rrdtool update $db_path/$item-olsr.rrd \ N:U:U:U if [ $? -eq "0" ] then rm /var/run/rrdtool.olsr.$item fi done