Révision d81a0f06
Initial version
| plugins/other/network-usage | ||
|---|---|---|
| 1 |
#!/bin/sh |
|
| 2 |
|
|
| 3 |
# Change to show your outside interface |
|
| 4 |
INTERFACE="eth2" |
|
| 5 |
|
|
| 6 |
case $1 in |
|
| 7 |
config) |
|
| 8 |
cat <<'EOM' |
|
| 9 |
graph_title Monthly Bandwidth average |
|
| 10 |
graph_vlabel Bytes |
|
| 11 |
average.label current average |
|
| 12 |
monthly.label monthly projection |
|
| 13 |
average.info Your average bandwidth usage based on uptime |
|
| 14 |
monthly.info Your projected monthly bandwidth usage based on uptime |
|
| 15 |
graph_category network |
|
| 16 |
graph_args --base 1024 -l 0 |
|
| 17 |
graph_info This graph show your current average bandwidth usage and projected 30 day average based on your current consumption since the last reboot |
|
| 18 |
average.warning 8.33 |
|
| 19 |
monthly.warning 250 |
|
| 20 |
EOM |
|
| 21 |
exit 0;; |
|
| 22 |
esac |
|
| 23 |
|
|
| 24 |
|
|
| 25 |
INPUT=`ifconfig $INTERFACE|grep bytes|awk '{print $2}'|sed s/bytes://g`
|
|
| 26 |
OUTPUT=`ifconfig $INTERFACE|grep bytes|awk '{print $6}'|sed s/bytes://g`
|
|
| 27 |
|
|
| 28 |
TOTAL=$(($INPUT+$OUTPUT)) |
|
| 29 |
|
|
| 30 |
UPTIME=`cat /proc/uptime | cut -d'.' -f1-1` |
|
| 31 |
UPV=`echo "scale=3;$UPTIME/60/60/24"|bc` |
|
| 32 |
|
|
| 33 |
DAILY=`echo "scale=3;$TOTAL/$UPV"|bc` |
|
| 34 |
MONTHLY=`echo "scale=3;$DAILY*30"|bc` |
|
| 35 |
|
|
| 36 |
|
|
| 37 |
echo "average.value $DAILY" |
|
| 38 |
echo "monthly.value $MONTHLY" |
|
Formats disponibles : Unified diff