📄 isag
字号:
set sag_if_reboot_flag 0# NOTE: The func __output_zero_metrics() cannot be used, because 'u' don't have sag_if_out_tokens puts $fp "$time 0 0 0 0 0" } set nums [parse_line $rest] # user nice system iowait steal (idle) set user [lindex $nums 0] set nice [lindex $nums 1] set syst [lindex $nums 2] set iow [lindex $nums 3] set steal [lindex $nums 4] set total [expr $user + $nice + $syst + $iow + $steal] if {$total > $val_max(u)} {set val_max(u) $total} puts $fp "$time $total [expr $nice + $syst + $iow + $steal] [expr $syst + $iow + $steal] [expr $iow + $steal] $steal" set rval 1 set sag_if_last_time $time } else {if {-1 != [string first "RESTART" $line]} { set sag_if_reboot_flag 1# see previous NOTE if {$sag_if_last_time != ""} { puts $fp "$sag_if_last_time 0 0 0 0 0" set rval 1 } }} return $rval}proc sag_if__output_zero_metrics_u {time} { return "$time 0 0 0 0 0"}# $Source: /var/CVSROOT/cvs/i-sag/isag/isag.perf_data_procs.m4,v $################################################################################ Performance Data Processing and Drawing functions# proces line functions## $Id: proc_line_generic.m4,v 1.11 2004/03/22 19:39:14 david Exp $# $State: Exp $# $Log: proc_line_generic.m4,v $# Revision 1.11 2004/03/22 19:39:14 david# fully avoided shell script, i hope the temp file issue is fixed## Revision 1.10 2003/01/26 20:41:49 david# partially renamed variables, 1st implementation of "Save Graph"## Revision 1.9 2002/03/24 15:18:26 david# added## Revision 1.8 2002/03/04 20:23:26 david# fixed whole day functionality## Revision 1.7 2001/07/30 18:06:25 sarrep# Fixed one debug print. It was on wrong place.## Revision 1.6 2001/03/30 16:42:26 sarrep# Fixed bug about _last_time, (mangled graph)## Revision 1.5 2001/03/17 17:30:23 sarrep# CVSizing, unified headers of each element file## Revision 1.4 2001/03/17 16:55:28 sarrep# LINUX RESTART zeroes all counters.################################################################################### NOTE: following function is used when# graph of whole day is required (see: draw() function)#proc sag_if__output_zero_metrics {time l} { global sag_if_out_tokens sag_if_out_tokens2 set out "$time " foreach N $sag_if_out_tokens($l) { set out "$out 0" } foreach N $sag_if_out_tokens2($l) { set out "$out 0" } return "$out"}## NOTE: `_last_time' related functionality is used when# graph of whole day is required (see: draw() function)#set sag_if_last_time ""set sag_if_reboot_flag 0# generic line processingproc sag_if_proc_line_generic {l fp line} { global val_cur val_max sag_if_out_tokens sag_if_out_tokens2 sag_if_last_time sag_if_reboot_flag set time [string trim [string range $line 0 12]] # Here was a problem, time string was badly cutten set time [time_normalize "$time"] set rest [string trim [string range $line 12 end]] ## Sebastien's isag specific# check for line: "time LINUX RESTART" and reset counter to next# valid time stamp.# NOTE: Values must be zeroed also for first valid time after reboot. For# explanation you can imagin the chart# if {-1 == [string first "RESTART" $rest]} { if {1 == $sag_if_reboot_flag} {# after reboot, set to zero also, all charts are with lines set sag_if_reboot_flag 0 puts $fp [sag_if__output_zero_metrics $time $l] } set nums [parse_line $rest] set out "$time " foreach N $sag_if_out_tokens($l) { set n [lindex $nums $N] set out "$out $n" if {$n > $val_max($l)} {set val_max($l) $n} } foreach N $sag_if_out_tokens2($l) { set n [lindex $nums $N] set out "$out $n" } set sag_if_last_time $time unset nums n N } else {# reboot detected, drop all metrics to zero set sag_if_reboot_flag 1 if {$sag_if_last_time != ""} { set out [sag_if__output_zero_metrics $sag_if_last_time $l] } } catch { puts $fp "$out" unset out } unset rest time return 1}# $Source: /var/CVSROOT/cvs/i-sag/common/proc_line_generic.m4,v $################################################################################ Performance Data Processing and Drawing functions# generic draw function# parametrical draw func for each kind of graph## $Id: draw.m4,v 1.16 2004/03/22 19:39:14 david Exp $# $State: Exp $# $Log: draw.m4,v $# Revision 1.16 2004/03/22 19:39:14 david# fully avoided shell script, i hope the temp file issue is fixed## Revision 1.15 2004/03/22 19:13:18 david# eliminated shell script, security issue## Revision 1.14 2004/02/27 19:26:06 david# fixed bug: CAN-2004-0108## Revision 1.13 2003/02/23 19:48:16 david# unified redundant code which generates data file## Revision 1.12 2003/01/26 20:41:48 david# partially renamed variables, 1st implementation of "Save Graph"## Revision 1.11 2002/03/24 15:18:26 david# added## Revision 1.10 2002/03/04 20:23:43 david# fixed whole day functionality## Revision 1.9 2002/03/04 18:36:37 david# grid feature implemented## Revision 1.8 2002/03/03 19:45:19 david# added parameters to create_gnuplot_file()## Revision 1.7 2001/03/30 16:42:26 sarrep# Fixed bug about _last_time, (mangled graph)## Revision 1.6 2001/03/17 17:30:10 sarrep# CVSizing, unified headers of each element file##################################################################################proc sag_prepare_datafile {l} { global sar sar_data_path sag_if_archive sag_if_out_tokens \ sag_opt_whole_day sag_if_last_time sar_elim set sag_if_last_time "" set fp [open "|$sar -$l -f $sar_data_path/$sag_if_archive" "r"] set fgrname [exec mktemp "/tmp/isag.XXXXXX"] set fpgr [open $fgrname w] set nlines 0 # if needed set starting time if { 0 != $sag_opt_whole_day } { set sag_if_last_time "00:00" if {"" != $sag_if_out_tokens($l)} { puts $fpgr [sag_if__output_zero_metrics $sag_if_last_time $l] } else { puts $fpgr [sag_if__output_zero_metrics_$l $sag_if_last_time] } } while {[gets $fp line] != -1} { if {(1 == [string match \[0-9\]* $line]) && (0 == [string match *$sar_elim($l)* $line])} { if {"" != $sag_if_out_tokens($l)} { set n [sag_if_proc_line_generic $l $fpgr "$line"] } else { set n [sag_if_proc_line_$l $fpgr "$line"] } incr nlines $n } } ## make closing remark if necessary# finishing whole day if { 0 != $sag_opt_whole_day } { if {"" != $sag_if_out_tokens($l)} { puts $fpgr [sag_if__output_zero_metrics $sag_if_last_time $l] } else { puts $fpgr [sag_if__output_zero_metrics_$l $sag_if_last_time] } if {"" != $sag_if_out_tokens($l)} { puts $fpgr [sag_if__output_zero_metrics "23:59" $l] } else { puts $fpgr [sag_if__output_zero_metrics_$l "23:59"] } } catch {close $fp} catch {close $fpgr} unset fp fpgr line return [list $nlines $fgrname]}## generic draw function# Parameter:# l - graph letter other values are parameters#proc sag_draw {l} { global sag_if_archive isag_title sh sar grep sar_data_path gnuplot \ sag_gr_scale val_cur val_max view_n sag_if_cmd xlabel sag_if_out_tokens \ ylabel y2label plotstr has_negative \ sag_if_last_time sag_opt_grid sag_opt_whole_day if {$sag_if_archive == ""} { out_msg "Error" "No data source selected for: $view_n($l)" return } wm title . "$isag_title: $view_n($l)" set prepared [sag_prepare_datafile $l] set nlines [lindex $prepared 0] set fgrname [lindex $prepared 1]# at least two lines of data if {$nlines > 1} { set_cur_max $l if {1 == $has_negative($l)} { set yrange "\[-$val_cur($l):$val_cur($l)\]" } else { set yrange "\[0:$val_cur($l)\]" } set fngr [exec mktemp "/tmp/isag.XXXXXX"] create_gnuplot_file tkcanvas tk $fngr "$view_n($l)" \ "$xlabel" \ "$ylabel($l)" $y2label($l) \ $yrange \ [strrep "$plotstr($l)" __FNGR__ $fgrname] $sag_opt_grid exec $gnuplot $fngr.gp source $fngr.tk gnuplot .graph.canv file delete $fngr.gp file delete $fngr.tk file delete $fngr } else { .graph.canv delete all out_msg "Datafile: sag_if_archive" "No data to show" } file delete $fgrname unset nlines }# $Source: /var/CVSROOT/cvs/i-sag/isag/draw.m4,v $################################################################################ Performance Data Processing and Drawing functions# proces line functions## $Id: sag.save_graph.m4,v 1.3 2003/02/23 21:07:41 david Exp $# $State: Exp $# $Log: sag.save_graph.m4,v $# Revision 1.3 2003/02/23 21:07:41 david# first prototype of sag## Revision 1.2 2003/02/23 19:48:16 david# unified redundant code which generates data file## Revision 1.1 2003/01/26 20:41:49 david# partially renamed variables, 1st implementation of "Save Graph"## Revision 1.9 2002/03/24 15:18:26 david# added## Revision 1.8 2002/03/04 20:23:26 david# fixed whole day functionality## Revision 1.7 2001/07/30 18:06:25 sarrep# Fixed one debug print. It was on wrong place.## Revision 1.6 2001/03/30 16:42:26 sarrep# Fixed bug about _last_time, (mangled graph)## Revision 1.5 2001/03/17 17:30:23 sarrep# CVSizing, unified headers of each element file## Revision 1.4 2001/03/17 16:55:28 sarrep# LINUX RESTART zeroes all counters.#################################################################################proc sag_save_graph {} { global sag_if_archive isag_title sh sar grep sar_data_path gnuplot \ sag_gr_scale val_cur val_max view_n sag_if_cmd xlabel sag_if_out_tokens \ ylabel y2label plotstr has_negative \ sag_if_last_time sag_opt_grid sag_opt_whole_day last_graph set l $last_graph if {$sag_if_archive == ""} {# out_msg "Error" "No data source selected for: $view_n($l)" return } set prepared [sag_prepare_datafile $l] set nlines [lindex $prepared 0] set fgrname [lindex $prepared 1]# at least two lines of data if {$nlines > 1} {# set_cur_max $l if {$val_cur($l) != 0} { if {1 == $has_negative($l)} { set yrange "\[-$val_cur($l):$val_cur($l)\]" } else { set yrange "\[0:$val_cur($l)\]" } } else { set yrange "" } set fngr [exec mktemp "/tmp/isag.XXXXXX"] create_gnuplot_file jpeg jpg $fngr "$view_n($l)" \ "$xlabel" \ "$ylabel($l)" $y2label($l) \ $yrange \ [strrep "$plotstr($l)" __FNGR__ $fgrname] $sag_opt_grid exec $gnuplot $fngr.gp file delete $fngr.gp file delete $fngr file rename -force $fngr.jpg $sag_if_archive.$l.jpg } else { .graph.canv delete all out_msg "Datafile: sag_if_archive" "No data to show" } file delete "$fgrname" unset nlines }# $Source: /var/CVSROOT/cvs/i-sag/common/sag.save_graph.m4,v $################################################################################ $Id: isag_cfg_file.m4,v 1.10 2004/03/22 19:39:14 david Exp $# $State: Exp $## $Log: isag_cfg_file.m4,v $# Revision 1.10 2004/03/22 19:39:14 david# fully avoided shell script, i hope the temp file issue is fixed## Revision 1.9 2004/03/22 19:13:18 david# eliminated shell script, security issue## Revision 1.8 2004/02/27 19:53:28 david# hide temporary files## Revision 1.7 2004/02/27 19:26:06 david# fixed bug: CAN-2004-0108## Revision 1.6 2003/01/26 20:41:48 david# partially renamed variables, 1st implementation of "Save Graph"## Revision 1.5 2002/03/04 20:21:51 david# make new end line## Revision 1.4 2002/03/04 18:36:37 david# grid feature implemented## Revision 1.3 2001/03/17 17:30:19 sarrep# CVSizing, unified headers of each element file##################################################################################if {[file isfile $isag_cfg_file] == 1} { source $isag_cfg_file if {"" != $last_graph} { if {$val_max($last_graph) > 0} { .graph.scale configure -to 0 \ -from $val_max($last_graph) set sag_gr_scale $val_cur($last_graph) } }}## Finishing a program and writting of config file#proc exit_program {} { global isag_cfg_file prog_swtch val_max val_cur last_graph \ sag_opt_whole_day sag_opt_grid set fp [open $isag_cfg_file w] foreach l $prog_swtch { puts $fp "set val_max($l) $val_max($l)" puts $fp "set val_cur($l) $val_cur($l)" } if {$last_graph == ""} { puts $fp "set last_graph \"\"" } else { puts $fp "set last_graph $last_graph" } puts $fp "set sag_opt_whole_day $sag_opt_whole_day" puts $fp "set sag_opt_grid $sag_opt_grid" close $fp destroy . exit}# $Source: /var/CVSROOT/cvs/i-sag/isag/isag_cfg_file.m4,v $# $Source: /var/CVSROOT/cvs/i-sag/isag/isag.m4,v $
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -