Wie kann ich unter linux den reinen tcp traffic anzeigen (also Transferrate) up und down?
Ein simples Kommandozeilenprogramm wäre mir am liebsten.
tcp Transferrate anzeigen
- Deifl
- Beiträge: 26
- Registriert: 12.08.2003 08:22:12
- Lizenz eigener Beiträge: MIT Lizenz
- Wohnort: Esslingen
-
Kontaktdaten:
Code: Alles auswählen
#!/bin/bash
# Network statusbar for the GNU Screen v0.0
#Copyright (C) 2005 Marcel Bischoff
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#no function
refresh=1
#number of bars
bars=20
#max bytes/s incomming
maxin=130000
#max bytes/s outgoing
maxout=20000
#net device
netd=eth0
oldin=`cat /proc/net/dev |grep $netd | sed 's/:/ /' | awk '{ print $2}'`
oldout=`cat /proc/net/dev |grep $netd |sed 's/:/ /' | awk '{ print $10}'`
while newin=`cat /proc/net/dev |grep $netd | sed 's/:/ /' | awk '{ print $2}'` ; do {
newout=`cat /proc/net/dev |grep $netd | sed 's/:/ /' |awk '{ print $10}'`
in=$[($newin - $oldin)]
out=$[($newout - $oldout)]
echo -n [
for i in $(seq 1 $bars); do {
if test $i -le $[($in*$bars)/$maxin] && test $i -le $[($out*$bars)/$maxout]; then
echo -n "|";
elif test $i -le $[($in*$bars)/$maxin]; then
echo -n ">";
elif test $i -le $[($out*$bars)/$maxout]; then
echo -n "<";
else echo -n " ";
fi
}
done
echo "] in: $[$in/1024]k/s out: $[$out/1024]k/s"
sleep $refresh
oldin=$newin
oldout=$newout
}
done
#hack your ~/.screenrc like this:
#backtick 1 0 0 ~/scripts/netbar
#hardstatus alwayslastline " %1`"