📄 amplot.awk
字号:
## Amanda, The Advanced Maryland Automatic Network Disk Archiver# Copyright (c) 1992-1998, 2000 University of Maryland at College Park# All Rights Reserved.## Permission to use, copy, modify, distribute, and sell this software and its# documentation for any purpose is hereby granted without fee, provided that# the above copyright notice appear in all copies and that both that# copyright notice and this permission notice appear in supporting# documentation, and that the name of U.M. not be used in advertising or# publicity pertaining to distribution of the software without specific,# written prior permission. U.M. makes no representations about the# suitability of this software for any purpose. It is provided "as is"# without express or implied warranty.## U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.## Author: Olafur Gudumundsson, ogud@tis.com# formerly at: Systems Design and Analysis Group# Computer Science Department# University of Maryland at College Park## An awk program to parse the amdump file and output the information# in a form at the gnuplot program amplot.g wants## Creation Date: April 1992# modified: Aug 1993# Modified for Amanda-2.2: Dec 1993# Modified for Amanda-2.2: Mar 1994 and May 1994 and June 1994# Enhanced: April 1995# Input: One amdump file # Output: Number of files that get fed into gnuplot#BEGIN{# The folowing parameters may have to be set to suit each site, both # parameters are expressed in HOUR's. # If your average amanda dump is more than 3 hours you should increase the# value of maxtime, similary if your dumps are finishing in less than 2 hours# you should decrease the value of maxtime.# This is now setable from amplot's command line.# maxtime = 4; # how long to plot graph for in hours# Min host controls the reporting of hosts that take long in dumping# This varible can be set explicity or as a fraction of maxtime# If you are seeing too many hosts reported increase the value of this # constant# min_host = maxtime * 0.75; # good rule of thumb# min_host = 2.5; # expicit cutoff value in hours## DO NOT CHANGE ANYTHING BELOW THIS LINE# time_scale = 60; # display in minutes DO NOT CHANGE maxtime *= time_scale; # convert to minutes min_host *= time_scale *time_scale; # convert to seconds # dumping than this disk_raise = 120; # scaling factors for Holding disk graph tape_raise = 90; dump_shift = 7.5; # scaling factors for Dumpers idle graph dump_raise = 0; que_raise = 300; # scaling factors for the queue's count_scale= 1.0/3.0; # new scale # scaling factors for the x axis bandw_raise = 250; bandw_scale = 30/300; # default calculated below holding_disk = -1; # uninitialized cnt = 0; # default values for counters din = 0; # number of dumps to holding disk dout = 0; # number of dumps to tape tapeq = 0; # how many dumps in tape queue tape_err = 0; # how many tape errors tout = 0; # data written out to tape quit = 0; # normal end of run plot_fmt = "%7.2f %6.2f\n%7.2f %6.2f\n"; # format of files for gnuplot plot_fmt1 = "%7.2f %6.2f\n"; # format of files for gnuplot} { # state machine for processing input lines lines if( $1 == "driver:") { if($2=="result") do_result(); else if( $2=="state") do_state(); else if( $2=="interface-state") ; else if( $2=="hdisk-state") do_hdisk++; else if( $2=="flush" && $3=="size" ) { flush_size = $4; } else if( $2=="start" && $3=="time") do_start(); else if( $2=="send-cmd") { if( $7=="FILE-DUMP"){ file_dump++; dmpr_strt[$6]=$4; host[$6]=$10; disk[$6]=$12; level[$6]=$14; } else if( $7 == "FILE-WRITE") file_write++; else if( $7 == "START-TAPER") fil = $8; } else if( $2=="finished-cmd") cmd_fin++; else if( $2=="started") forked++; else if( $2=="QUITTING") do_quit(); else if( $2=="find_diskspace:") ; #eat this line else if( $2=="assign_holdingdisk:") ; #eat this line else if( $2=="adjust_diskspace:") ; #eat this line else if( $2=="tape" && $3=="size") ; #eat this line else if( $2=="dump" && $3=="failed") ; #eat this line else if( $2=="taper" && $3=="failed") ; #eat this line else if( $2=="dumping" || $2 == "adding" || $2 == "holding-disks:") dumping++; # eat this line else if( $2!="FINISHED" && $2 != "pid" && $2 != "taper-tryagain"&& $2!="startaflush:") print fil,"Unknown statement#",$0; } else if ( $1 == "planner:") { if( $2 == "SKIPPED" || $2 == "FAILED") { failed++; print fil, "INFO#", $0; } } else if( $1 == "GENERATING") sched_start=NR; else if( $1 == "ENDFLUSH") sched_start=NR; else if( $1 == "DELAYING") do_moves(); # find estimated size else if( $1 == "dumper:") { if($4 != "starting" && $2 != "pid" && $2 != "stream_client:" && $2 != "dgram_bind:") print fil, "INFO#", $0; } else if( $1 == "taper:") { if($3 != "label" && $3 != "end" && $2 != "DONE" && $2 != "pid" && $2 != "slot" && $2 != "reader-side:" && $2 != "page" && $2 != "buffer" && $3 != "at" && $3 != "switching" && $2 != "slot:") print fil, "INFO#", $0; } else if( $1 == "FLUSH") { no_flush++; } else if( NF==1 && sched_start > 0 && NR-sched_start > 1) { # new style end of schedule no_disks = NR-sched_start-2; # lets hope there are no extra lines sched_start = 0; }}function do_state(){ # state line is printed out after driver # finishes pondering new actions # it reports the state as seen be driver# fields in the state line # $2 = "state" # $3 = "time" # $4 = time_val# $5 = "free" # $6 = "kps:" # $7 = free_kps# $8 = "space:" # $9 = space # $10 = "taper:"# $11 = "writing"/"idle"# $12 = "idle-dumpers:"# $13 = #idle # $14 = "qlen" # $15 = "tapeq:"# $16 = #waiting # $17 = "runq:" # $18 = #not started # $19 = "roomq" # $20 = #roomq # $21 = "wakeup:"# $22 = #wakeup # $23 = "driver-idle:" # $23 = status cnt++; # number of event time = $4/time_scale; #Check overflow in driver ouput (big value instead of negative) if($7>0 && $7 < 0x7fffffff) unused = (bandw - $7)*bandw_scale+bandw_raise; else unused = bandw_raise; if( unused != unused_old) printf plot_fmt, time, unused_old, time,unused >>"bandw_free"; unused_old = unused; if(holding_disk_old != $9) { disk_alloc_time[disk_a] = time; disk_alloc_space[disk_a] = holding_disk_old; disk_a++; disk_alloc_time[disk_a] = time; disk_alloc_space[disk_a] = $9; disk_a++; holding_disk_old = $9; } twait = tsize; if(twait_old != twait) { twait_time[twait_a] = time; twait_wait[twait_a] = twait_old; twait_a++; twait_time[twait_a] = time; twait_wait[twait_a] = twait; twait_a++; twait_old = twait; } active = (dumpers-$13)*dump_shift+dump_raise; if( active != active_old ) printf plot_fmt, time, active_old, time, active >> "dump_idle"; active_old = active;# tape on or off if($11=="writing")state = tape_raise+10; else state = tape_raise; if( state != state_old ) printf plot_fmt, time, state_old, time, state >> "tape_idle"; state_old = state; run = $18*count_scale+que_raise; if( run != run_old ) printf plot_fmt, time, run_old, time, run >> "run_queue"; run_old = run; finish = written * count_scale+que_raise; if( finish != finish_old ) printf plot_fmt, time, finish_old, time, finish >> "finished"; finish_old = finish; tapeQ = $16 * count_scale+que_raise; if( tapeQ != tapeQ_old ) printf plot_fmt, time, tapeQ_old, time, tapeQ >> "tape_queue"; tapeQ_old = tapeQ;}function do_start() { # get configuration parameters dumpers = $6; # how many day = $14; dump_shift = 75/dumpers; bandw = $8; bandw_scale = (30/bandw); unused_old = bandw_raise; print 0, unused_old > "bandw_free"; if( sched_start >0 ) { no_disks = NR-sched_start-1; # backward compatability sched_start =0; print "do_start: no_disks", no_disks, $0; } no_disks += no_flush; size = $10/1024; # size of holding disk in MB holding_disk= $10 + flush_size; init_holding_disk= $10 + flush_size; holding_disk_old = $10; disk_a = 0; disk_alloc_time[disk_a] = 0; disk_alloc_space[disk_a] = holding_disk_old; disk_a++; tsize = flush_size; twait_old = tsize; twait_a = 0; twait_time[twait_a] = 0; twait_wait[twait_a] = twait_old; twait_a++; if( NF==14) { # original file was missing this policy="FIFO"; alg ="InOrder"; } else if(NF>=18) { # newer files have this format policy = $18; alg = $16; if( alg=="drain-ends") big = $20; } start = $4; # this is the start time of the first dump # taper idle to this point should not be included run_old = no_disks*cont_scale+que_raise; print 0, run_old >"run_queue"; finish_old = tapeQ_old = que_raise; print 0, finish_old >"finished"; print 0, tapeQ_old >"tape_queue" ; state_old = tape_raise; print 0, state_old > "tape_idle"; active_old = dump_raise; print 0,active_old >"dump_idle";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -