[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cobalt-users] RaQ4 daily bandwidth report script
- Subject: [cobalt-users] RaQ4 daily bandwidth report script
- From: "aljuhani" <aljuhani@xxxxxxxxx>
- Date: Sat Jul 20 10:50:01 2002
- List-id: Mailing list for users to share thoughts on Sun Cobalt products. <cobalt-users.list.cobalt.com>
I have a script insalled under my /etc/cron.daily for measuring Bandwidth used every 24 hours. It sends an email every day telling me how much Tx and Rx bytes have gone over eth0. Below is a report received today. My question is about the 5th line (Total Mbytes changed : 309) what does it represnts exactly and what conversions needed to conver it to actual bandwidth value as 309 MB is not a realistic figure.
_____BANDWIDTH REPORT______
Network Usage Stats 20020720-040646
-----------------------------------
Tx bytes change from last report : 9316927
Rx bytes change from last report : 314854476
Total bytes changed from last report : 324171403
Total Kbytes changed : 316573
Total Mbytes changed : 309
Total Gbytes changed : 0
Daily allowance in Mbytes : 341
___SCRIPT USED UNDER /etc/cron.daily___
#!/bin/sh
YOUREMAIL=YourEmailAddress@xxxxxxxxxxxxxx
DATETIME=`date +%Y%m%d-%H%M%S`
OBytesIN=`cat /tmp/bytesin.txt`
OBytesOUT=`cat /tmp/bytesout.txt`
NBytesIN=`cat /proc/net/dev | grep eth0 | awk '{print $1}' | awk -F : '{print $2}'`
NBytesOUT=`cat /proc/net/dev | grep eth0 | awk '{print $9}'`
OUTChange=`expr $NBytesOUT - $OBytesOUT`
INChange=`expr $NBytesIN - $OBytesIN`
TOTChange=`expr $OUTChange + $INChange`
Kbytes=`expr $TOTChange / 1024`
Mbytes=`expr $Kbytes / 1024`
Gbytes=`expr $Mbytes / 1024`
echo $NBytesIN > /tmp/bytesin.txt
echo $NBytesOUT > /tmp/bytesout.txt
echo subject: Network Usage > /tmp/mail.txt
echo >> /tmp/mail.txt
echo Network Usage Stats $DATETIME >> /tmp/mail.txt
echo ----------------------------------- >> /tmp/mail.txt
echo Tx bytes change from last report : $OUTChange >> /tmp/mail.txt
echo Rx bytes change from last report : $INChange >> /tmp/mail.txt
echo Total bytes changed from last report : $TOTChange >> /tmp/mail.txt
echo Total Kbytes changed : $Kbytes >> /tmp/mail.txt
echo Total Mbytes changed : $Mbytes >> /tmp/mail.txt
echo Total Gbytes changed : $Gbytes >> /tmp/mail.txt
echo Daily allowance in Mbytes : 341 >> /tmp/mail.txt
echo . >> /tmp/mail.txt
/usr/sbin/sendmail $YOUREMAIL < /tmp/mail.tx
Best regards.
aljuhani
aljuhani@xxxxxxxxx