2 # Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 # Copyright (c) 1992-1998, 2000 University of Maryland at College Park
6 # Permission to use, copy, modify, distribute, and sell this software and its
7 # documentation for any purpose is hereby granted without fee, provided that
8 # the above copyright notice appear in all copies and that both that
9 # copyright notice and this permission notice appear in supporting
10 # documentation, and that the name of U.M. not be used in advertising or
11 # publicity pertaining to distribution of the software without specific,
12 # written prior permission. U.M. makes no representations about the
13 # suitability of this software for any purpose. It is provided "as is"
14 # without express or implied warranty.
16 # U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 # BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 # Author: Olafur Gudumundsson, ogud@tis.com
24 # formerly at: Systems Design and Analysis Group
25 # Computer Science Department
26 # University of Maryland at College Park
28 # An awk program to parse the amdump file and output the information
29 # in a form at the gnuplot program amplot.g wants
31 # Creation Date: April 1992
33 # Modified for Amanda-2.2: Dec 1993
34 # Modified for Amanda-2.2: Mar 1994 and May 1994 and June 1994
35 # Enhanced: April 1995
36 # Input: One amdump file
37 # Output: Number of files that get fed into gnuplot
40 # The folowing parameters may have to be set to suit each site, both
41 # parameters are expressed in HOUR's.
42 # If your average amanda dump is more than 3 hours you should increase the
43 # value of maxtime, similary if your dumps are finishing in less than 2 hours
44 # you should decrease the value of maxtime.
45 # This is now setable from amplot's command line.
46 # maxtime = 4; # how long to plot graph for in hours
48 # Min host controls the reporting of hosts that take long in dumping
49 # This varible can be set explicity or as a fraction of maxtime
50 # If you are seeing too many hosts reported increase the value of this
53 min_host = maxtime * 0.75; # good rule of thumb
54 # min_host = 2.5; # expicit cutoff value in hours
57 # DO NOT CHANGE ANYTHING BELOW THIS LINE
59 time_scale = 60; # display in minutes DO NOT CHANGE
60 maxtime *= time_scale; # convert to minutes
61 min_host *= time_scale *time_scale; # convert to seconds
63 disk_raise = 120; # scaling factors for Holding disk graph
65 dump_shift = 7.5; # scaling factors for Dumpers idle graph
67 que_raise = 300; # scaling factors for the queue's
68 count_scale= 1.0/3.0; # new scale
69 # scaling factors for the x axis
71 bandw_scale = 30/300; # default calculated below
73 holding_disk = -1; # uninitialized
75 cnt = 0; # default values for counters
76 din = 0; # number of dumps to holding disk
77 dout = 0; # number of dumps to tape
78 tapeq = 0; # how many dumps in tape queue
79 tape_err = 0; # how many tape errors
80 tout = 0; # data written out to tape
81 quit = 0; # normal end of run
82 plot_fmt = "%7.2f %6.2f\n%7.2f %6.2f\n"; # format of files for gnuplot
83 plot_fmt1 = "%7.2f %6.2f\n"; # format of files for gnuplot
86 { # state machine for processing input lines lines
87 if( $1 == "driver:") {
88 if($2=="result") do_result();
89 else if( $2=="state") do_state();
90 else if( $2=="interface-state") ;
91 else if( $2=="hdisk-state") do_hdisk++;
92 else if( $2=="flush" && $3=="size" ) {
95 else if( $2=="start" && $3=="time") do_start();
96 else if( $2=="send-cmd") {
104 else if( $7 == "FILE-WRITE") file_write++;
105 else if( $7 == "START-TAPER") fil = $9;
107 else if( $2=="finished-cmd") cmd_fin++;
108 else if( $2=="started") forked++;
109 else if( $2=="QUITTING") do_quit();
110 else if( $2=="find_diskspace:") ; #eat this line
111 else if( $2=="assign_holdingdisk:") ; #eat this line
112 else if( $2=="adjust_diskspace:") ; #eat this line
113 else if( $2=="tape" && $3=="size") ; #eat this line
114 else if( $2=="dump" && $3=="failed") ; #eat this line
115 else if( $2=="taper" && $3=="failed") ; #eat this line
116 else if( $2=="dumping" || $2 == "adding" || $2 == "holding-disks:")
117 dumping++; # eat this line
118 else if( $2!="FINISHED" && $2 != "pid" && $2 != "taper-tryagain"&& $2!="startaflush:")
119 print fil,"Unknown statement#",$0;
121 else if ( $1 == "planner:") {
122 if( $2 == "SKIPPED" || $2 == "FAILED") {
124 print fil, "INFO#", $0;
127 else if( $1 == "GENERATING") sched_start=NR;
128 else if( $1 == "ENDFLUSH") sched_start=NR;
129 else if( $1 == "DELAYING") do_moves(); # find estimated size
130 else if( $1 == "dumper:") {
131 if($4 != "starting" && $2 != "pid" && $2 != "stream_client:" && $2 != "dgram_bind:")
132 print fil, "INFO#", $0;
134 else if( $1 == "taper:") {
135 if($3 != "label" && $3 != "end" && $2 != "DONE" && $2 != "pid" && $2 != "slot" && $2 != "reader-side:" && $2 != "page" && $2 != "buffer" && $3 != "at" && $3 != "switching" && $2 != "slot:" && $2 != "status")
136 print fil, "INFO#", $0;
138 else if( $1 == "FLUSH") {
141 else if( NF==1 && sched_start > 0 && NR-sched_start > 1) { # new style end of schedule
142 no_disks = NR-sched_start-2; # lets hope there are no extra lines
147 function do_state(){ # state line is printed out after driver
148 # finishes pondering new actions
149 # it reports the state as seen be driver
150 # fields in the state line
151 # $2 = "state" # $3 = "time" # $4 = time_val
152 # $5 = "free" # $6 = "kps:" # $7 = free_kps
153 # $8 = "space:" # $9 = space # $10 = "taper:"
154 # $11 = "writing"/"idle"# $12 = "idle-dumpers:"
155 # $13 = #idle # $14 = "qlen" # $15 = "tapeq:"
156 # $16 = #waiting # $17 = "runq:" # $18 = #not started
157 # $19 = "roomq" # $20 = #roomq # $21 = "wakeup:"
158 # $22 = #wakeup # $23 = "driver-idle:" # $23 = status
160 cnt++; # number of event
161 time = $4/time_scale;
162 #Check overflow in driver ouput (big value instead of negative)
163 if($7>0 && $7 < 0x7fffffff)
164 unused = (bandw - $7)*bandw_scale+bandw_raise;
166 unused = bandw_raise;
167 if( unused != unused_old)
168 printf plot_fmt, time, unused_old, time,unused >>"bandw_free";
171 if(holding_disk_old != $9) {
172 disk_alloc_time[disk_a] = time;
173 disk_alloc_space[disk_a] = holding_disk_old;
175 disk_alloc_time[disk_a] = time;
176 disk_alloc_space[disk_a] = $9;
178 holding_disk_old = $9;
182 if(twait_old != twait) {
183 twait_time[twait_a] = time;
184 twait_wait[twait_a] = twait_old;
186 twait_time[twait_a] = time;
187 twait_wait[twait_a] = twait;
192 active = (dumpers-$13)*dump_shift+dump_raise;
193 if( active != active_old )
194 printf plot_fmt, time, active_old, time, active >> "dump_idle";
198 if($11=="writing")state = tape_raise+10;
199 else state = tape_raise;
200 if( state != state_old )
201 printf plot_fmt, time, state_old, time, state >> "tape_idle";
204 run = $18*count_scale+que_raise;
206 printf plot_fmt, time, run_old, time, run >> "run_queue";
209 finish = written * count_scale+que_raise;
210 if( finish != finish_old )
211 printf plot_fmt, time, finish_old, time, finish >> "finished";
214 tapeQ = $16 * count_scale+que_raise;
215 if( tapeQ != tapeQ_old )
216 printf plot_fmt, time, tapeQ_old, time, tapeQ >> "tape_queue";
221 function do_start() { # get configuration parameters
222 dumpers = $6; # how many
224 dump_shift = 75/dumpers;
226 bandw_scale = (30/bandw);
227 unused_old = bandw_raise;
228 print 0, unused_old > "bandw_free";
229 if( sched_start >0 ) {
230 no_disks = NR-sched_start-1; # backward compatability
232 print "do_start: no_disks", no_disks, $0;
234 no_disks += no_flush;
235 size = $10/1024; # size of holding disk in MB
236 holding_disk= $10 + flush_size;
237 init_holding_disk= $10 + flush_size;
238 holding_disk_old = $10;
240 disk_alloc_time[disk_a] = 0;
241 disk_alloc_space[disk_a] = holding_disk_old;
246 twait_time[twait_a] = 0;
247 twait_wait[twait_a] = twait_old;
249 if( NF==14) { # original file was missing this
253 else if(NF>=18) { # newer files have this format
256 if( alg=="drain-ends") big = $20;
259 start = $4; # this is the start time of the first dump
260 # taper idle to this point should not be included
261 run_old = no_disks*cont_scale+que_raise;
262 print 0, run_old >"run_queue";
263 finish_old = tapeQ_old = que_raise;
264 print 0, finish_old >"finished";
265 print 0, tapeQ_old >"tape_queue" ;
266 state_old = tape_raise;
267 print 0, state_old > "tape_idle";
268 active_old = dump_raise;
269 print 0,active_old >"dump_idle";
273 function do_quit(){ # this is issued by driver at the end
274 # when it has nothing more to do
277 tim = $4 / time_scale;
279 disk_alloc_time[disk_a] = tim;
280 disk_alloc_space[disk_a] = holding_disk_old;
282 max_space=disk_alloc_space[0];
283 for(a=0; a<disk_a; a++) {
284 if(disk_alloc_space[a] > max_space) {
285 max_space = disk_alloc_space[a];
290 if(max_space > holding_disk) {
291 space_change = max_space - holding_disk;
292 holding_disk = max_space;
295 twait_time[twait_a] = tim;
296 twait_wait[twait_a] = twait_old;
298 min_wait=twait_wait[0];
299 for(a=0; a<twait_a; a++) {
300 if(twait_wait[a] < min_wait) {
301 min_wait = twait_wait[a];
305 if(flush_size == 0) {
306 holding_disk -= min_wait;
307 holding_disk -= space_change;
309 for(a=0; a<twait_a; a++) {
310 twait_wait[a] -= min_wait;
313 if (holding_disk != 0) {
314 const = 100/holding_disk;
319 for(a=0; a<disk_a; ++a) {
320 space = (holding_disk - disk_alloc_space[a])*const+disk_raise
321 printf plot_fmt1, disk_alloc_time[a], space >> "disk_alloc";
323 for(a=0; a<twait_a; ++a) {
324 space = (twait_wait[a])*const+disk_raise
325 printf plot_fmt1, twait_time[a], space >> "tape_wait";
328 printf plot_fmt, tim, active_old, tim, dump_raise >>"dump_idle";
329 printf plot_fmt, tim, state_old, tim, tape_raise >>"tape_idle";
330 printf plot_fmt, tim, unused_old, tim, bandw_raise >>"bandw_free";
331 printf plot_fmt, tim, finish_old, tim, written*count_scale+que_raise >>"finished";
332 printf plot_fmt, tim, run_old, tim, run_old >>"run_queue";
335 function do_result(){ # process lines driver: result
337 if( $6=="taper:"){ # taper done
342 else { # dumperx done
343 tsize += (int($15/32)+1)*32; # in tape blocks
348 host_time[xx]+= ( tt = $4 - dmpr_strt[$6]);
349 if(xx in disk_list) disk_list[xx] = disk_list[xx] "\n";
350 disk_list[xx] = disk_list[xx] \
351 xx ":" d "/" l "\t" \
352 pr_time(dmpr_strt[$6]) \
355 # print host[$6], disk[host[$6]];
356 # print host[$6], $4, dmpr_strt[$6], host_time[host[$6]]
359 else if ($6=="taper:") { # something else than DONE
360 if($7=="TAPE-ERROR" || $7=="TRY-AGAIN") {
362 err_time=$4/time_scale;
364 else if ($7=="TAPER-OK") tape_err=0;
365 else if ($7=="PORT") tape_err=0;
366 else if ($7=="REQUEST-NEW-TAPE") tape_err=0;
367 else if ($7=="NEW-TAPE") tape_err=0;
368 else if ($7=="PARTDONE") tape_err=0;
369 else if ($7=="DUMPER-STATUS") tape_err=0;
370 else print fil, "UNKNOWN STATUS# "$0 ;
372 else { # something bad from dumper
373 if ($7=="FAILED") { failed++;}
374 else if ($7=="TRY-AGAIN"){ try++;}
375 else if ($7=="PORT") ; # ignore from chunker
376 else if ($7=="RQ-MORE-DISK") ; # FIXME: ignore for now
377 else if ($7=="NO-ROOM")
378 print fil, pr_time($4),"#" ++no_room, $0;
379 else if( $7=="ABORT-FINISHED") print fil, "#" ++no_abort, $0;
380 else print fil, "UNKNOWN STATUS# " $0;
384 function do_moves() { # function that extracts the estimated size of dumps
385 # by processing DELAYING and promoting lines
387 getline ; # eat get next line print out planner msg
388 while (NF > 0 && (($1 == "delay:") || ($1 == "planner:")) ) {
389 if( $1 == "delay:") est_size = $NF; # processing delay lines
390 else print fil, "DELAY#", $0;
393 getline ; # eating blank line
394 if( $1== "PROMOTING") { # everything is dandy
395 getline; # get first promote line
396 while ( NF>0 && ($1 == "promote:" || $1 == "planner:" || $1 == "no" || $1 == "try") ) {
397 if( $2 == "moving") {
399 print fil, "PROMOTING#", $1, $3;
401 else if($2 != "checking" && $2 != "can't" && $3 != "too" && $1 != "no" && $1 != "try" && $2 != "time")
402 print fil,"PROMOTING#", $0;
403 getline ; # get next promote line
406 else print fil, "DID NOT FIND PROMOTING LINE IN THE RIGHT PLACE",NR,$0;
411 if( holding_disk == -1) { # bad input file
412 print fil,": MISSING SPACE DECLARATION" ;
415 # print headers of each graph this is for the gnulot version
416 if( tim >maxtime && extend==0)# if graph will extend beond borders
417 printf "Graph extends beond borders %s taking %7.3f > (max = %7.3f)\n",
419 print_t(); # print titles
420 if( no_room + no_abort > 0)
421 printf "NO-ROOM=%5d ABORT-FINISHED=%5d\n", no_room, no_abort;
423 old_t = min_host * min_host; # Some thing big
424 print "Longest dumping hosts Times", min_host;
425 print "Host:disk/lev \t start - end = run\t=> total";
426 while ( max_out-- > 0 && old_t > min_host) {
428 for (j in host_time) {
429 if( t < host_time[j] && host_time[j] <old_t){
433 printf "%s\t=> %s\n\n", disk_list[d], pr_time(host_time[d]);
434 # printf "%-20.20s Total Dump time %s\n", d, pr_time(host_time[d]);
439 function print_t(){ # printing out the labels for the graph
440 label=0; # calculating where labels go and
441 # range for x and y axes
442 maxy = int(no_disks/60+1)*20+que_raise;
443 printf "set yrange[0:%d]\n",maxy >"title";
444 if( maxtime < tim && extend !=0) {
445 printf "set xrange[0:%d]\n", tim+30 >>"title";
447 second_col = (tim+30) * 0.45;
448 key_col = (tim+30) * 1.042;
449 third_col = (tim+30) * 1.0125;
452 printf "set xrange[0:%d]\n", maxtime >>"title";
453 first_col = maxtime * 0.042
454 second_col = maxtime * 0.45
456 third_col = maxtime*1.0125;
458 label_shift = (7 + int(no_disks/100));
459 lab = label_start = maxy+(6*label_shift) ; # showing 6 labels
460 printf "set key at %d, %d\n", key_col, lab+4 >>"title";
461 printf "set label %d \"Amanda Dump %s\" at %d,%d\n", ++label,fil,
462 first_col,lab >"title";
464 printf "set label %d \"Bandwidth = %d\" at %d,%d\n",++label,bandw,
465 first_col,lab >>"title";
468 printf "set label %d \"Holding disk = %d\" at %d,%d\n",++label,size,
469 first_col,lab >>"title";
472 printf "set label %d \"Tape Policy = %s\" at %d,%d\n",++label,policy,
473 first_col,lab >>"title";
476 printf "set label %d \"Dumpers= %d\" at %d,%d\n",++label,dumpers,
477 first_col,lab >>"title";
480 if( alg =="drain-ends")
481 printf "set label %d \"Driver alg = %s At big end %d\" at %d,%d\n",
482 ++label,alg, big,first_col,lab >>"title";
483 else #if( alg =="InOrder") # other special cases
484 printf "set label %d \"Driver alg = %s\" at %d,%d\n",
485 ++label,alg,first_col, lab >>"title";
488 printf "set label %d \"Elapsed Time = %s\" at %d,%d\n",
489 ++label,pr_time(tim*60),second_col,lab >>"title";
492 if( tape_err==1) stm = "TAPE ERROR";
493 else if( quit ==1) stm = "SUCCESS";
494 else { stm = "UNKNOWN";
495 print "Unknown terminating status",fil;
497 printf "set label %d \"Final status = %s\" at %d,%d\n",
498 ++label,stm, second_col,lab >> "title";
501 printf "set label %d \"Dumped/Failed = %3d/%d\" at %d,%d\n",
502 ++label,done,(failed+(try/2)), second_col,lab >>"title";
505 printf "set label %d \"Output data size = %d\" at %d, %d\n",
506 ++label,int(tout/1024+0.49999),second_col,lab >>"title";
509 printf "set label %d \"Estimated data size = %d\" at %d, %d\n",
510 ++label,int(est_size/1024+0.49999),second_col,lab >>"title";
514 printf "set output \"%s.ps\"\n",fil >>"title";
516 if(paper==1) printf "set term postscript landscape \"Times-Roman\" 10\n" >>"title";
517 else printf "set term postscript portrait \"Times-Roman\" 10\n" >>"title";
520 if(paper==1) printf "set term postscript landscape color \"Times-Roman\" 10\n" >>"title";
521 else printf "set term postscript portrait color \"Times-Roman\" 10\n" >>"title";
524 printf "set term x11\n" >> "title";
526 printf "set ylabel """";" >>"title"; # make sure there is no ylabel
527 fmt= "set label %d \"%s\" at "third_col", %d\n";
528 printf fmt, ++label,"%DUMPERS", 40 >>"title";
529 printf fmt, ++label,"TAPE", 95 >>"title";
530 printf fmt, ++label,"HOLDING",180 >>"title";
531 printf fmt, ++label,"DISK", 160 >>"title";
532 printf fmt, ++label,"%BANDWIDTH", 260 >>"title";
533 printf fmt, ++label,"QUEUES",(que_raise+maxy)/2 >>"title";
534 if((paper+gnuplot) > 0) print "set size 0.9, 0.9;" >>"title";
535 else print "set size 0.7,1.3;" >>"title";
538 function pr_time(pr_a){ #function to pretty print time
539 pr_h = int(pr_a/3600);
540 pr_m = int(pr_a/60)%60;
541 pr_s = int(pr_a+0.5) %60;
542 if( pr_m < 10 && pr_s < 10 ) return pr_h":0"pr_m":0"pr_s;
543 else if( pr_s < 10) return pr_h":" pr_m":0"pr_s;
544 else if( pr_m < 10) return pr_h":0"pr_m":" pr_s;
545 else return pr_h":" pr_m":" pr_s;