![]() ![]() |
crusader |
Subversion Repositories: |
Compare with Previous - Blame - Download
#!/bin/bashPATH=/opt/rrdtool/bin:$PATH:/sbin:/usr/sbindata_dir="/var/statistiky/arp"mkdir -p $data_dircd ${data_dir}config_file=/opt/statistiky/collect_arp.conffunction create(){local filename=$1echo " creating new arp2.rrd"# zakladem je krok 5 sekund# petiminutove useky se pocitaji z 60 PDP (primary data points) (12 za minutu * 5 minut)# vsechny RRA se pocitaji primo z PDP, tj. dvouhodinove useky se pocitaji z 240 PDP# za posledni tyden chceme 5minutove useky udaje => 12*24*9 = 2592 radku# za posledni mesic chceme 20minutove useky => 3*24*38 = 2736 radku# za posledni rok chceme dvouhodinove useky => 12*400 = 4800 radkurrdtool create ${filename}.rrd --step 5 --start `date +%s` \DS:count:GAUGE:10:0:100 \RRA:AVERAGE:0.7:1:1440 \RRA:MAX:0.7:4:2880 \RRA:MIN:0.7:4:2880 \RRA:AVERAGE:0.7:4:2880 \RRA:MAX:0.7:60:2592 \RRA:MIN:0.7:60:2592 \RRA:AVERAGE:0.7:60:2592 \RRA:MAX:0.7:240:2736 \RRA:MIN:0.7:240:2736 \RRA:AVERAGE:0.7:240:2736 \RRA:MAX:0.7:1440:4800 \RRA:MIN:0.7:1440:4800 \RRA:AVERAGE:0.7:1440:4800}function wait_to()# $1 date for waiting to{local time_now=`date +%s`;while [ $time_now -lt $1 ]dotime_now=`date +%s`sleep 1;done}echo "Looking for arp.rrd"if [ ! -f arp.rrd ] ; thencreate arpfisleep 2;start_time=`date +%s`interval=$(( $start_time / 5 * 5 + 5 ))while [ true ]do. ${config_file}echo "Wait to $interval"wait_to $intervaltimenow=`date +%s`echo "Time now: `date +%s`"count="0"for net_dev in $DEVICESdocount_dev=$(( `arp -n -i $net_dev | grep ether | grep -v "192.168" | wc -l` + 0 ))echo " items in arp table $net_dev: $count_dev"let count+=$count_devdoneecho "All items in arp table : $count"if [ ! -z "${count}" ]thenrrdtool update arp.rrd $timenow:$countfiinterval=$(( $interval + 5 ))done