jablonka.czprosek.czf

crusader

Subversion Repositories:
[/] [trunk/] [statistiky/] [opt/] [statistiky/] [collect_arp.sh] - Blame information for rev 3

 

Line No. Rev Author Line
11simandl#!/bin/bash
2 
3PATH=/opt/rrdtool/bin:$PATH:/sbin:/usr/sbin
4 
5data_dir="/var/statistiky/arp"
6mkdir -p $data_dir
7 
8cd ${data_dir}
9 
10config_file=/opt/statistiky/collect_arp.conf
11 
12function create()
13{
14 local filename=$1
15 echo " creating new arp2.rrd"
16 
17# zakladem je krok 5 sekund
18# petiminutove useky se pocitaji z 60 PDP (primary data points) (12 za minutu * 5 minut)
19# vsechny RRA se pocitaji primo z PDP, tj. dvouhodinove useky se pocitaji z 240 PDP
20# za posledni tyden chceme 5minutove useky udaje => 12*24*9 = 2592 radku
21# za posledni mesic chceme 20minutove useky => 3*24*38 = 2736 radku
22# za posledni rok chceme dvouhodinove useky => 12*400 = 4800 radku
23rrdtool create ${filename}.rrd --step 5 --start `date +%s` \
24 DS:count:GAUGE:10:0:100 \
25 RRA:AVERAGE:0.7:1:1440 \
26 RRA:MAX:0.7:4:2880 \
27 RRA:MIN:0.7:4:2880 \
28 RRA:AVERAGE:0.7:4:2880 \
29 RRA:MAX:0.7:60:2592 \
30 RRA:MIN:0.7:60:2592 \
31 RRA:AVERAGE:0.7:60:2592 \
32 RRA:MAX:0.7:240:2736 \
33 RRA:MIN:0.7:240:2736 \
34 RRA:AVERAGE:0.7:240:2736 \
35 RRA:MAX:0.7:1440:4800 \
36 RRA:MIN:0.7:1440:4800 \
37 RRA:AVERAGE:0.7:1440:4800
38 
39}
40 
41function wait_to()
42# $1 date for waiting to
43{
44 local time_now=`date +%s`;
45 while [ $time_now -lt $1 ]
46 do
47 time_now=`date +%s`
48 sleep 1;
49 done
50}
51 
52echo "Looking for arp.rrd"
53if [ ! -f arp.rrd ] ; then
54 create arp
55fi
56sleep 2;
57 
58 
59start_time=`date +%s`
60interval=$(( $start_time / 5 * 5 + 5 ))
61 
62while [ true ]
63do
64 . ${config_file}
65 
66 echo "Wait to $interval"
67 wait_to $interval
68 timenow=`date +%s`
69 echo "Time now: `date +%s`"
70 
71 count="0"
72 for net_dev in $DEVICES
73 do
74 count_dev=$(( `arp -n -i $net_dev | grep ether | grep -v "192.168" | wc -l` + 0 ))
75 echo " items in arp table $net_dev: $count_dev"
76 let count+=$count_dev
77 done
78 echo "All items in arp table : $count"
79 
80 
81 if [ ! -z "${count}" ]
82 then
83 rrdtool update arp.rrd $timenow:$count
84 fi
85 
86 interval=$(( $interval + 5 ))
87 
88done
89 

Powered by WebSVN 2.2.1