#!/usr/bin/perl # -- device -- # # change this to your net device # # ppp0 or eth0 etc are common ones :) # $netdevice1 = "eth0"; $netdevice2 = "eth1"; while(1){ ($stat = qx!cat /proc/net/dev | grep $netdevice1 !) =~ s!$netdevice1:\s*!!; ($in1a,$out1a) = (split(/\s+/, $stat))[1,9]; ($stat = qx!cat /proc/net/dev | grep $netdevice2 !) =~ s!$netdevice2:\s*!!; ($in2a,$out2a) = (split(/\s+/, $stat))[1,9]; sleep 1; ($stat = qx!cat /proc/net/dev | grep $netdevice1!) =~ s!$netdevice1:\s*!!; ($in1b,$out1b) = (split(/\s+/, $stat))[1,9]; ($stat = qx!cat /proc/net/dev | grep $netdevice2!) =~ s!$netdevice2:\s*!!; ($in2b,$out2b) = (split(/\s+/, $stat))[1,9]; printf("$netdevice1: Incoming: %.2fk/s | Outgoing: %.2fk/s\n", ($in1b-$in1a)/1024, ($out1b-$out1a)/1024); printf("$netdevice2: Incoming: %.2fk/s | Outgoing: %.2fk/s\n\n", ($in2b-$in2a)/1024, ($out2b-$out2a)/1024); } ##printf("Incoming: %.2fk/s | Outgoing: %.2fk/s\n", ($in2-$in1)/1024, ($out2-$out1)/1024);