2 # Visualize RAID activity - read the README file first!
3 # Copyright (C) 2018 Red Hat Inc.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are
10 # * Redistributions of source code must retain the above copyright
11 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
17 # * Neither the name of Red Hat nor the names of its contributors may be
18 # used to endorse or promote products derived from this software without
19 # specific prior written permission.
21 # THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND
22 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24 # PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR
25 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28 # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 source "nbdcanvas.tcl"
42 # This list is used to store all the RAID handles.
45 # This function polls the log file of each handle (every 100 ms).
57 puts "usage: nbdview N size logfile-pattern errorfile-pattern"
60 set N [lindex $argv 0]
61 set size [lindex $argv 1]
62 set logpattern [lindex $argv 2]
63 set errorpattern [lindex $argv 3]
68 . configure -menu .menubar
70 .menubar add cascade -menu .menubar.file -label File
71 .menubar.file add command -label "Quit" -command { exit }
75 pack .f -anchor center -expand 1 -fill both -ipadx 10 -ipady 10
78 for { set i 1 } { $i <= $N } { incr i } {
79 set logfile($i) [format $logpattern $i]
80 set errorfile($i) [format $errorpattern $i]
82 # VBox to store the canvas and controls.
85 pack $box -side left -expand 1 -fill both
87 # Create the error checkbox.
88 set errorbutton "$box.e"
90 checkbutton $errorbutton -text "Error" -variable errorvar($i) \
91 -command "set_errorfile $i"
92 proc set_errorfile { i } {
93 global errorvar errorfile
94 if { $errorvar($i) } {
95 # Touch the error inject file.
96 close [open $errorfile($i) "w"]
99 file delete $errorfile($i)
102 pack $errorbutton -side top -anchor nw -expand 0 -fill none
104 # Create the i'th canvas.
106 set h [nbdcanvas $canvas $logfile($i) $size $blocksize $width $scale]
107 $canvas configure -borderwidth 4 -relief groove
108 pack $canvas -side top -expand 0 -fill none
114 wm attributes . -topmost 1
116 wm resizable . false false
118 # Start polling the log file.