This is a simple traffictool which shows incoming and outgoing data and packets.
Introduction:
Save the file to yourfile.tcl
Start it by using tclsh yourfile.tcl
Note: this script is linux only.
proc getfirst {} {
foreach i [split [exec cat /proc/net/dev] \n] {
if {[string match -nocase *eth0:* "$i"]} {
set firstin [lindex [split [lindex $i 0] :] 1]
set firstout [lindex $i 8]
set fpackin [lindex $i 1]
set fpackout [lindex $i 9]
after 1000 [list getsecond $firstin $firstout $fpackin $fpackout]
}
}
}
proc len {data} {
if {$data>=1000000} {
return [expr {$data/1000000}]mbit/s
} elseif {$data>=1000} {
return [expr {$data/1000}]kbit/s
} else {
return $datab/s
}
}
proc getsecond {firstin firstout fpackin fpackout} {
set a $firstin
set b $firstout
set c $fpackin
set d $fpackout
foreach i [split [exec cat /proc/net/dev] \n] {
if {[string match -nocase *eth0:* "$i"]} {
set secondin [lindex [split [lindex $i 0] :] 1]
set secondout [lindex $i 8]
set spackin [lindex $i 1]
set spackout [lindex $i 9]
exec clear >@ stdout
puts "Bandwidth: In: [len [expr {$secondin-$a}]] | Out: [len [expr {$secondout-$b}]]"
puts "Packets: In: [expr {$spackin-$c}]packets/s | Out: [expr {$spackout-$d}]packets/s"
getfirst
}
}
}
exec clear >@ stdout
puts "Traffictool by shitbreak is starting."
after 2000 [list exec clear >@ stdout]
after 2000 getfirst
vwait forever