"Fossies" - the Fresh Open Source Software Archive

Member "coda-6.9.5/coda-src/vtools/logbandwidth.in" (23 May 2003, 4793 Bytes) of package /linux/misc/old/coda-6.9.5.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!+TIXWISH+
    2 # BLURB gpl
    3 # 
    4 #                            Coda File System
    5 #                               Release 6
    6 # 
    7 #           Copyright (c) 1987-2003 Carnegie Mellon University
    8 #                   Additional copyrights listed below
    9 # 
   10 # This  code  is  distributed "AS IS" without warranty of any kind under
   11 # the terms of the GNU General Public Licence Version 2, as shown in the
   12 # file  LICENSE.  The  technical and financial  contributors to Coda are
   13 # listed in the file CREDITS.
   14 # 
   15 #                         Additional copyrights
   16 #                            none currently
   17 # 
   18 #*/
   19 
   20 #
   21 # initialize chart parameters
   22 #
   23 set strip_value1   0
   24 set strip_value2   0
   25 set strip_value3   0
   26 set strip_interval 1000
   27 set strip_log1     [ list ]
   28 set strip_log2     [ list ]
   29 set strip_log3     [ list ]
   30 set strip_idx      0
   31 set strip_label    ""
   32 
   33 #
   34 # create graphical stuff
   35 #
   36 label .strip_label -text ""
   37 pack .strip_label
   38 canvas .strip_graph -height 100 -width 200 \
   39 		    -relief sunken -border 2
   40 pack .strip_graph
   41 
   42 for { set x 0 } { $x < 200 } { incr x } {
   43   lappend strip_log1 0
   44   lappend strip_log2 0
   45   lappend strip_log3 0
   46 }
   47 
   48 proc strip_draw {} {
   49   global strip_log1 strip_value1
   50   global strip_log2 strip_value2
   51   global strip_log3 strip_value3
   52   global strip_interval strip_idx strip_label
   53 
   54   set strip_log1 [ lreplace $strip_log1 $strip_idx $strip_idx $strip_value1 ]
   55   set strip_log2 [ lreplace $strip_log2 $strip_idx $strip_idx $strip_value2 ]
   56   set strip_log3 [ lreplace $strip_log3 $strip_idx $strip_idx $strip_value3 ]
   57 
   58   .strip_graph delete data
   59 
   60   set i [ expr 202 - $strip_idx ]
   61   foreach v1 $strip_log1 v2 $strip_log2 v3 $strip_log3 {
   62     if { $v1 < 100 } { set v1 100 }
   63     if { $v2 < 100 } { set v2 100 }
   64     if { $v3 < 100 } { set v3 100 }
   65     set val1 [ expr ( ( log10($v1) - 3 ) * 20 ) ]
   66     set val2 [ expr ( ( log10($v2) - 3 ) * 20 ) ]
   67     set val3 [ expr ( ( log10($v3) - 3 ) * 20 ) ]
   68     .strip_graph create line $i 103 \
   69 			     $i [ expr 102 - $val1 ] \
   70 			     -tags data -fill LightSlateBlue
   71     .strip_graph create line $i [ expr 102 - $val1 ] \
   72 			     $i [ expr 102 - $val3 ] \
   73 			     -tags data -fill SkyBlue
   74     .strip_graph create line $i [ expr 102 - $val2 ] \
   75 			     $i [ expr 103 - $val2 ] \
   76 			     -tags data -fill Red
   77 
   78     incr i
   79     if { $i >= 202 } { set i 2 }
   80   }
   81   # 1,000 Bps (modem 4800-28800)
   82   .strip_graph create text 4 99 -text "Modem" -tags data -anchor w -font 5x7
   83 
   84   # 10,000 Bps (ISDN (64k-128k))
   85   .strip_graph create line 2 83 202 83 -tags data -fill DarkSlateGray
   86   .strip_graph create text 4 79 -text "ISDN" -tags data -anchor w -font 5x7
   87 
   88   # 100,000 Bps
   89   .strip_graph create line 2 63 202 63 -tags data -fill DarkSlateGray
   90   .strip_graph create text 4 59 -text "Wavelan" -tags data -anchor w -font 5x7
   91 
   92   # 1,000,000 Bps (10base-T)
   93   .strip_graph create line 2 43 202 43 -tags data -fill DarkSlateGray
   94   .strip_graph create text 4 39 -text "Ethernet" -tags data -anchor w -font 5x7
   95 
   96   # 10,000,000 Bps (100base-T)
   97   .strip_graph create line 2 23 202 23 -tags data -fill DarkSlateGray
   98   .strip_graph create text 4 19 -text "Fast Ethernet" -tags data -anchor w -font 5x7
   99 
  100   .strip_graph create text 200 10 -text "$strip_label" -tags data -anchor e
  101 
  102   incr strip_idx
  103   if { $strip_idx >= 200 } { set strip_idx 0 }
  104 
  105   after $strip_interval strip_draw
  106 }
  107 
  108 proc strip_title {text} {
  109   .strip_label configure -text $text
  110 }
  111 
  112 #########################################################################
  113 #
  114 # Venus related stuff
  115 #
  116 proc updatestats {} {
  117   global input
  118   #
  119   # Get a line (may be empty or not ready yet)
  120   #
  121   set n [ gets $input line ]
  122   if { $n == -1 } {
  123     if [ eof $input ] {
  124       puts "Connection to venus lost"
  125       exit 0
  126     }
  127     return
  128   }
  129 
  130   checkline $line
  131 }
  132 
  133 #
  134 # connect to the venus port
  135 #
  136 set input [ socket localhost venus ]
  137 puts "Connected to venus"
  138 puts $input "set:fetch"
  139 flush $input
  140 
  141 #
  142 # set the socket to non-blocking and attach the callback
  143 #
  144 fconfigure $input -blocking off
  145 fileevent $input readable updatestats
  146 
  147 #########################################################################
  148 #
  149 # Customized stuff
  150 #
  151 proc checkline {line} {
  152   global who strip_value1 strip_value2 strip_value3 strip_label
  153 
  154   #
  155   # match our patterns
  156   #
  157   if [ string match "connection::bandwidth $who*" $line ] {
  158     if { $who == "" } { set who [ lindex $line 1 ] }
  159     strip_title [ lindex $line 1]
  160     set strip_value1 [ lindex $line 2 ]
  161     set strip_value2 [ lindex $line 3 ]
  162     set strip_value3 [ lindex $line 4 ]
  163     if { $strip_value1 < 0 } { set strip_value1 0 }
  164     if { $strip_value2 < 0 } { set strip_value2 0 }
  165     if { $strip_value3 < 0 } { set strip_value3 0 }
  166     set strip_label "[ expr $strip_value2 * 8 ] bps"
  167   }
  168 }
  169 
  170 #
  171 # configure and start drawing
  172 #
  173 set who [ lindex $argv 0 ]
  174 set strip_interval 100
  175 strip_draw