-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.sh
executable file
·39 lines (32 loc) · 912 Bytes
/
create.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# create a rrd file
rrdfile="/data/vpntrafic.rrd"
STEP=300
HEARTBEAT=600
now=`date +%s`
if [ ! -f $rrdfile ]
then
rrdtool create $rrdfile --start $now --step $STEP \
DS:IN:COUNTER:$HEARTBEAT:U:U \
DS:OUT:COUNTER:$HEARTBEAT:U:U \
RRA:AVERAGE:0.5:1:603 \
RRA:AVERAGE:0.5:6:603 \
RRA:AVERAGE:0.5:24:603 \
RRA:AVERAGE:0.5:288:800 \
RRA:LAST:0.5:1:603 \
RRA:LAST:0.5:6:603 \
RRA:LAST:0.5:24:603 \
RRA:LAST:0.5:288:800 \
else
echo "$rrdfile already exists, remove it"
fi
TEMPLATE_STR="IN:OUT"
while :
do
IN=`snmpwalk -cpublic -v2c 172.16.100.2 IF-MIB::ifInOctets.2|awk '{print $NF}'`
OUT=`snmpwalk -cpublic -v2c 172.16.100.2 IF-MIB::ifOutOctets.2|awk '{print $NF}'`
rrdtool update $rrdfile \
--template $TEMPLATE_STR \
N:$IN:$OUT
sleep $STEP
done