[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tcldrop/CVS] tcldrop/modules core.tcl
From: |
Philip Moore |
Subject: |
[Tcldrop/CVS] tcldrop/modules core.tcl |
Date: |
Sat, 22 Nov 2003 00:01:58 -0500 |
CVSROOT: /cvsroot/tcldrop
Module name: tcldrop
Branch:
Changes by: Philip Moore <address@hidden> 03/11/22 00:01:57
Modified files:
modules : core.tcl
Log message:
Forgot to make the [traffic] command show the total bytes in/out also.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/tcldrop/tcldrop/modules/core.tcl.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
Patches:
Index: tcldrop/modules/core.tcl
diff -u tcldrop/modules/core.tcl:1.20 tcldrop/modules/core.tcl:1.21
--- tcldrop/modules/core.tcl:1.20 Fri Nov 21 21:52:36 2003
+++ tcldrop/modules/core.tcl Sat Nov 22 00:01:56 2003
@@ -1,6 +1,6 @@
# core.tcl --
#
-# $Id: core.tcl,v 1.20 2003/11/22 02:52:36 fireegl Exp $
+# $Id: core.tcl,v 1.21 2003/11/22 05:01:56 fireegl Exp $
#
# Copyright (C) 2003 FireEgl (Philip Moore) <address@hidden>
#
@@ -47,7 +47,7 @@
# Provide the users module:
variable version {0.3}
package provide tcldrop::core $version
- variable rcsid {$Id: core.tcl,v 1.20 2003/11/22 02:52:36 fireegl Exp $}
+ variable rcsid {$Id: core.tcl,v 1.21 2003/11/22 05:01:56 fireegl Exp $}
# Initialize variables:
variable Binds
variable Timers
@@ -482,7 +482,7 @@
proc ::tcldrop::traffic {{type {*}} {direction {}} {bytes {0}}} {
variable Traffic
- if {$type != {*}} {
+ if {$type != {}} {
if {[info exists Traffic($type)]} {
# Set the info array to the current counts.
array set info $Traffic($type)
@@ -492,7 +492,8 @@
}
# Increase the counters:
if {($bytes) && ($direction == {in} || $direction == {out})} {
- array set info [list total-$direction [incr
info(total-$direction) $bytes] daily-$direction [incr info(daily-$direction)
$bytes]]
+ incr info(total-$direction) $bytes
+ incr info(daily-$direction) $bytes
}
# See if 24 hours have elapsed, and if it has then clear the
daily counts.
if {[expr { [unixtime] - $info(restart) > 86400 }]} {
@@ -509,11 +510,16 @@
}
} else {
# Show them all the traffic stats.
- set out [list]
+ array set total [list total-out 0 total-in 0 daily-out 0
daily-in 0]
foreach t [array names Traffic] {
array set info $Traffic($t)
lappend out [list $t $info(daily-in) $info(total-in)
$info(daily-out) $info(total-out)]
+ incr total(total-out) $info(total-out)
+ incr total(total-in) $info(total-in)
+ incr total(daily-out) $info(daily-out)
+ incr total(daily-in) $info(daily-in)
}
+ lappend out [list Total $total(daily-in) $total(total-in)
$total(daily-out) $total(total-out)]
return $out
}
}