rrd_scripts/update_rrds.sh

46 lines
1.1 KiB
Bash
Raw Normal View History

2014-06-10 14:35:54 -04:00
#!/bin/bash
CONFIGPATH=$(pwd)
while [ true ]
do
. ${CONFIGPATH}/rrd_config
cd $RRDDIR
for i in "${INTERFACES[@]}"
do
# By default I use ifconfig, if you prefer
# iproute2 simply comment out the next two lines
# and uncomment the other ones.
RX=$(/sbin/ifconfig $i | grep bytes | cut -f2 -d":" | cut -f1 -d " ")
TX=$(/sbin/ifconfig $i | grep bytes | cut -f3 -d":" | cut -f1 -d " ")
#RX=$(/sbin/ip -o -s link show eth0 | cut -f40 -d" ")
#TX=$(/sbin/ip -o -s link show eth0 | cut -f84 -d" ")
$RRDTOOL update ${i}_day.rrd --template RXBytes:TXBytes N:${RX}:${TX}
done
for i in "${DISKS[@]}"
do
READS=$(${IOSTAT} -d $i | grep $i | awk {'print $5'})
WRITES=$(${IOSTAT} -d $i | grep $i | awk {'print $6'})
READSB=$((${READS}*1000))
WRITESB=$((${WRITES}*1000))
$RRDTOOL update ${i}.rrd --template reads:writes N:${READSB}:${WRITESB}
done
ONEMIN=$(cat /proc/loadavg | awk {'print $1'})
FIVEMIN=$(cat /proc/loadavg | awk {'print $2'})
FIFTEENMIN=$(cat /proc/loadavg | awk {'print $3'})
$RRDTOOL update loadavg.rrd --template one:five:fifteen N:${ONEMIN}:${FIVEMIN}:${FIFTEENMIN}
sleep 7
done