From b0dd1c44b06caeffc19f46c1d20abd6e90ac9ffa Mon Sep 17 00:00:00 2001 From: marko Date: Mon, 7 May 2007 07:35:06 +0000 Subject: [PATCH] Revert back the changes to exec.tcl rev 1.45 in RELENG_4_11 branch, i.e. add back mbuf / cluster usage monitoring routines. Bug found by: Submitted by: Requested by: Reviewed by: Approved by: Obtained from: --- exec.tcl | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/exec.tcl b/exec.tcl index 80a947a..4e13ce7 100755 --- a/exec.tcl +++ b/exec.tcl @@ -74,6 +74,48 @@ proc nexec { args } { } +#****f* exec.tcl/nexec_monitor +# NAME +# nexec_monitor -- execute monitor +# SYNOPSIS +# set result [nexec_monitor $args] +# FUNCTION +# Executes the sting given in args variable. The sting is not executed +# if IMUNES is running in editor only mode. Execution of a string can +# be local or remote. Opens a monitor socket if it is not yet opened. +# Sends the arguments to monitor socket if the remote execution is +# selected, otherwise executes arguments locally. +# INPUTS +# * args -- the string that should be executed locally or remotely. +# RESULT +# * result -- the standard output of the executed string. +#**** +proc nexec_monitor { args } { + global remote_exec editor_only + global monSock + + if { $remote_exec } { + if { ![info exists monSock] || $monSock == "" } { + remoteStart + } + } + + if { $editor_only } { + tk_messageBox -title "Editor only" \ + -message "Running in editor only mode. Cannot execute commands. Please report this problem." \ + -type ok + exit 5 + } + + if { $remote_exec } { + rexec $monSock $args + } else { + eval exec $args + } +} + + + #****f* exec.tcl/setOperMode # NAME # setOperMode -- set operating mode @@ -97,6 +139,7 @@ proc nexec { args } { #**** proc setOperMode { mode } { global oper_mode activetool node_list + global nmbufs nmbclusters global editor_only remote_exec execSock global undolevel redolevel @@ -147,6 +190,9 @@ proc setOperMode { mode } { .menubar.edit entryconfigure "Undo" -state disabled .menubar.edit entryconfigure "Redo" -state disabled set oper_mode exec + set nmbufs [lindex [split [nexec sysctl kern.ipc.nmbufs]] 1] + set nmbclusters [lindex [split [nexec sysctl kern.ipc.nmbclusters]] 1] + monitor_loop if { $remote_exec } { nexec create_conf_file config.imn dumpCfg file $execSock @@ -656,6 +702,41 @@ proc vimageCleanup {} { } +#****f* exec.tcl/monitor_loop +# NAME +# monitor_loop -- monitor loop +# SYNOPSIS +# monitor_loop +# FUNCTION +# Calculates the usage of cpu, mbuffers and mbuf clusters. +# The results are displayed in status line and updated +# every two seconds. +#**** +proc monitor_loop {} { + global oper_mode + global nmbufs nmbclusters + + if {$oper_mode != "exec"} { + .bottom.cpu_load config -text "" + .bottom.mbuf config -text "" + return + } + + set cpu_load [expr ([lindex [split [nexec_monitor sysctl kern.cp_time_avg]] end] + \ + 5000) / 10000] + .bottom.cpu_load config -text "CPU $cpu_load%" + + set nstout [split [nexec_monitor netstat -m] ] + set mbufs [lindex [split [lindex $nstout 0] /] 0] + set clusts [lindex [split [lsearch -inline $nstout "*/$nmbclusters"] /] 0] + set mbufp [expr $mbufs * 100 / $nmbufs] + set clustp [expr $clusts * 100 / $nmbclusters] + .bottom.mbuf config -text "mbuf/clus $mbufp%/$clustp%" + + after 2000 { monitor_loop } +} + + #****f* exec.tcl/execSetIfcQDisc # NAME # execSetIfcQDisc -- in exec mode set interface queuing discipline -- 2.39.5