📄 amplot.awk
字号:
}function do_quit(){ # this is issued by driver at the end # when it has nothing more to do cnt++; quit = 1; tim = $4 / time_scale; disk_alloc_time[disk_a] = tim; disk_alloc_space[disk_a] = holding_disk_old; disk_a++; max_space=disk_alloc_space[0]; for(a=0; a<disk_a; a++) { if(disk_alloc_space[a] > max_space) { max_space = disk_alloc_space[a]; } } space_change = 0; if(max_space > holding_disk) { space_change = max_space - holding_disk; holding_disk = max_space; } twait_time[twait_a] = tim; twait_wait[twait_a] = twait_old; twait_a++; min_wait=twait_wait[0]; for(a=0; a<twait_a; a++) { if(twait_wait[a] < min_wait) { min_wait = twait_wait[a]; } } if(min_wait < 0) { if(flush_size == 0) { holding_disk -= min_wait; holding_disk -= space_change; } for(a=0; a<twait_a; a++) { twait_wait[a] -= min_wait; } } if (holding_disk != 0) { const = 100/holding_disk; } else { const = 100; } for(a=0; a<disk_a; ++a) { space = (holding_disk - disk_alloc_space[a])*const+disk_raise printf plot_fmt1, disk_alloc_time[a], space >> "disk_alloc"; } for(a=0; a<twait_a; ++a) { space = (twait_wait[a])*const+disk_raise printf plot_fmt1, twait_time[a], space >> "tape_wait"; } printf plot_fmt, tim, active_old, tim, dump_raise >>"dump_idle"; printf plot_fmt, tim, state_old, tim, tape_raise >>"tape_idle"; printf plot_fmt, tim, unused_old, tim, bandw_raise >>"bandw_free"; printf plot_fmt, tim, finish_old, tim, written*count_scale+que_raise >>"finished"; printf plot_fmt, tim, run_old, tim, run_old >>"run_queue";}function do_result(){ # process lines driver: result if($7=="DONE" ) { if( $6=="taper:"){ # taper done tsize -= $14; tout += $14; tcnt--; written++; } else { # dumperx done tsize += (int($15/32)+1)*32; # in tape blocks tcnt++; done++; xx = host[$6]; d = disk[$6]; l = level[$6]; host_time[xx]+= ( tt = $4 - dmpr_strt[$6]); if(xx in disk_list) disk_list[xx] = disk_list[xx] "\n"; disk_list[xx] = disk_list[xx] \ xx ":" d "/" l "\t" \ pr_time(dmpr_strt[$6]) \ " - " pr_time($4) \ " = " pr_time(tt);# print host[$6], disk[host[$6]];# print host[$6], $4, dmpr_strt[$6], host_time[host[$6]] } } else if ($6=="taper:") { # something else than DONE if($7=="TAPE-ERROR" || $7=="TRY-AGAIN") { tape_err= 1; err_time=$4/time_scale; } else if ($7=="TAPER-OK") tape_err=0; else if ($7=="PORT") tape_err=0; else print fil, "UNKNOWN STATUS# "$0 ; } else { # something bad from dumper if ($7=="FAILED") { failed++;} else if ($7=="TRY-AGAIN"){ try++;} else if ($7=="PORT") ; # ignore from chunker else if ($7=="RQ-MORE-DISK") ; # FIXME: ignore for now else if ($7=="NO-ROOM") print fil, pr_time($4),"#" ++no_room, $0; else if( $7=="ABORT-FINISHED") print fil, "#" ++no_abort, $0; else print fil, "UNKNOWN STATUS# " $0; }}function do_moves() { # function that extracts the estimated size of dumps # by processing DELAYING and promoting lines est_size=$6; getline ; # eat get next line print out planner msg while (NF > 0 && (($1 == "delay:") || ($1 == "planner:")) ) { if( $1 == "delay:") est_size = $NF; # processing delay lines else print fil, "DELAY#", $0; getline; } getline ; # eating blank line if( $1== "PROMOTING") { # everything is dandy getline; # get first promote line while ( NF>0 && ($1 == "promote:" || $1 == "planner:" || $1 == "no" || $1 == "try") ) { if( $2 == "moving") { est_size=$8; print fil, "PROMOTING#", $1, $3; } else if($2 != "checking" && $2 != "can't" && $3 != "too" && $1 != "no" && $1 != "try" && $2 != "time") print fil,"PROMOTING#", $0; getline ; # get next promote line } } else print fil, "DID NOT FIND PROMOTING LINE IN THE RIGHT PLACE",NR,$0;}END { if( holding_disk == -1) { # bad input file print fil,": MISSING SPACE DECLARATION" ; exit; }# print headers of each graph this is for the gnulot version if( tim >maxtime && extend==0)# if graph will extend beond borders printf "Graph extends beond borders %s taking %7.3f > (max = %7.3f)\n", fil, tim, maxtime ; print_t(); # print titles if( no_room + no_abort > 0) printf "NO-ROOM=%5d ABORT-FINISHED=%5d\n", no_room, no_abort; max_out = 20; old_t = min_host * min_host; # Some thing big print "Longest dumping hosts Times", min_host; print "Host:disk/lev \t start - end = run\t=> total"; while ( max_out-- > 0 && old_t > min_host) { t = 0; for (j in host_time) { if( t < host_time[j] && host_time[j] <old_t){ t = host_time[d=j]; } } printf "%s\t=> %s\n\n", disk_list[d], pr_time(host_time[d]);# printf "%-20.20s Total Dump time %s\n", d, pr_time(host_time[d]); old_t = t; }}function print_t(){ # printing out the labels for the graph label=0; # calculating where labels go and # range for x and y axes maxy = int(no_disks/60+1)*20+que_raise; printf "set yrange[0:%d]\n",maxy >"title"; if( maxtime < tim && extend !=0) { printf "set xrange[0:%d]\n", tim+30 >>"title"; second_col = tim*0.5; key_col = tim; third_col = tim +13; } else { printf "set xrange[0:%d]\n", maxtime >>"title"; second_col = (maxtime-10) * 0.5; key_col = (maxtime-10) ; third_col = maxtime +3; } label_shift = (7 + int(no_disks/100)); lab = label_start = maxy+(6*label_shift) ; # showing 6 labels printf "set key %d, %d\n", key_col, lab >>"title"; printf "set label %d \"Amanda Dump %s\" at 10,%d\n", ++label,fil, lab >"title"; lab -= label_shift; printf "set label %d \"Bandwidth = %d\" at 10,%d\n",++label,bandw, lab >>"title"; lab -= label_shift; printf "set label %d \"Holding disk = %d\" at 10,%d\n",++label,size, lab >>"title"; lab -= label_shift; printf "set label %d \"Tape Policy = %s\" at 10,%d\n",++label,policy, lab >>"title"; lab -= label_shift; printf "set label %d \"Dumpers= %d\" at 10,%d\n",++label,dumpers, lab >>"title"; lab -= label_shift; if( alg =="drain-ends") printf "set label %d \"Driver alg = %s At big end %d\" at 10,%d\n", ++label,alg, big,lab >>"title"; else #if( alg =="InOrder") # other special cases printf "set label %d \"Driver alg = %s\" at 10,%d\n", ++label,alg, lab >>"title"; lab = label_start; printf "set label %d \"Elapsed Time = %s\" at %d,%d\n", ++label,pr_time(tim*60),second_col,lab >>"title"; lab -= label_shift; if( tape_err==1) stm = "TAPE ERROR"; else if( quit ==1) stm = "SUCCESS"; else { stm = "UNKNOWN"; print "Unknown terminating status",fil; } printf "set label %d \"Final status = %s\" at %d,%d\n", ++label,stm, second_col,lab >> "title"; lab -= label_shift; printf "set label %d \"Dumped/Failed = %3d/%d\" at %d,%d\n", ++label,done,(failed+(try/2)), second_col,lab >>"title"; lab -= label_shift; printf "set label %d \"Output data size = %d\" at %d, %d\n", ++label,int(tout/1024+0.49999),second_col,lab >>"title"; if( est_size >0) { lab -= label_shift; printf "set label %d \"Estimated data size = %d\" at %d, %d\n", ++label,int(est_size/1024+0.49999),second_col,lab >>"title"; } if (gnuplot==0) { printf "set output \"%s.ps\"\n",fil >>"title"; if(bw==1) { if(paper==1) printf "set term postscript landscape \"Times-Roman\" 10\n" >>"title"; else printf "set term postscript portrait \"Times-Roman\" 10\n" >>"title"; } else { if(paper==1) printf "set term postscript landscape color \"Times-Roman\" 10\n" >>"title"; else printf "set term postscript portrait color \"Times-Roman\" 10\n" >>"title"; } } printf "set ylabel """";" >>"title"; # make sure there is no ylabel fmt= "set label %d \"%s\" at "third_col", %d\n"; printf fmt, ++label,"%DUMPERS", 40 >>"title"; printf fmt, ++label,"TAPE", 95 >>"title"; printf fmt, ++label,"HOLDING",180 >>"title"; printf fmt, ++label,"DISK", 160 >>"title"; printf fmt, ++label,"%BANDWIDTH", 260 >>"title"; printf fmt, ++label,"QUEUES",(que_raise+maxy)/2 >>"title"; if((paper+gnuplot) > 0) print "set size 0.9, 0.9;" >>"title"; else print "set size 0.7,1.3;" >>"title";}function pr_time(pr_a){ #function to pretty print time pr_h = int(pr_a/3600); pr_m = int(pr_a/60)%60; pr_s = int(pr_a+0.5) %60; if( pr_m < 10 && pr_s < 10 ) return pr_h":0"pr_m":0"pr_s; else if( pr_s < 10) return pr_h":" pr_m":0"pr_s; else if( pr_m < 10) return pr_h":0"pr_m":" pr_s; else return pr_h":" pr_m":" pr_s;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -