#!/usr/bin/perl ######################################################################## # # find_max_nmon_val.pl # Ken Lobb - version 1 - 09-10-2007 - only works for NET attrib index # - version 2 - 09-12-2007 - added capabil to work for most attrib indices (incl calc val for cpu_all %cpu=%usr+%sys) # - version 3 - 09-13-2007 - changed to put filename in same paragraph as attribs for ease in filtering report later # - version 4 - 09-14-2007 - added more suggestions to "usage" # # Runs various commands to report on raw_data_filename, field value, & max # val for field per filename for a set of nmon raw data files # (intended to help weed thru a large# nmon data files for substantive data files) # # Assembled by Ken Lobb # IBM Global Services # IBM Atlanta # kglobb@us.ibm.com # ######################################################################## if ( $#ARGV < 1 ) { print "\nUsage: $0 \n\n"; print "NOTES: \t 1) The must be full-path\n"; print "\t 2) Index to query - what specific data to report on max val for\n"; print "\t ...Example:\n"; print "\t ...NET is network kbytes/sec on all known interfaces\n"; print "\n"; print "Post-processing suggestion: Use egrep against attribs to hone\n"; print "in on particular data of interest, as in...\n"; print "\t egrep 'nmon|Attribute 2|Attribute 7' /tmp/MAX_VALUE_QUERY_INDEX.NET.webfin01.log\n"; print ".....followed by (where 8198.5 and 7213.7 are 2 highest max vals.....\n"; print "\t egrep -p '8198.5|7213.7' /tmp/MAX_VALUE_QUERY_INDEX.NET.webfin01.log |grep nmon\n"; print ".......This gives you list of two nmon data files to focus on for analysis.....\n"; print "\n"; exit(1); } $QUERY_INDEX=$ARGV[1]; open(LIST_NMON_DATAFILES,"$ARGV[0]") || die "couldn't open list_nmon_datafiles\n"; open(MAX_VALUE_QUERY_INDEX,">/tmp/MAX_VALUE_QUERY_INDEX.$QUERY_INDEX.log") || die "couldn't open /tmp/MAX_VALUE_QUERY_INDEX.log file\n"; while () { # print filename print MAX_VALUE_QUERY_INDEX "$_"; #print "$_"; open(NEXT_NMON_DATAFILE,"$_") || die "couldn't open next_nmon_datafile\n"; while () { chop; @LINE=split(/,/, $_); $LE=$#LINE; $INDEX=0; # block to eval each approp line if ( $LINE[0] =~ /\b$QUERY_INDEX\b/ && $LINE[1] !~ /T[0-9][0-9][0-9][0-9]/ ) { $INDEX=2; while ( $INDEX <= $LE ) { # initialize max val for each attrib $MAXVAL_ATTRIB[$INDEX]=0; # print next attrib name to rep file print MAX_VALUE_QUERY_INDEX "$LINE[$INDEX] "; $INDEX+=1; } # print \n at end of list of attribs print MAX_VALUE_QUERY_INDEX "\n"; # set perm val for $LE for later use $LE_perm=$LE; } if ( $LINE[0] =~ /\b$QUERY_INDEX\b/ && $LINE[1] =~ /T[0-9][0-9][0-9][0-9]/ ) { $INDEX=2; if ( $QUERY_INDEX eq CPU_ALL ) { while ( $INDEX <= $LE ) { # cpu_util = %usr+%sys if ( $INDEX == 6 ) { $LINE[6]=$LINE[2]+$LINE[3]; } if ( $LINE[$INDEX] > $MAXVAL_ATTRIB[$INDEX] ) { $MAXVAL_ATTRIB[$INDEX]=$LINE[$INDEX]; } $INDEX+=1; } } while ( $INDEX <= $LE ) { if ( $LINE[$INDEX] > $MAXVAL_ATTRIB[$INDEX] ) { $MAXVAL_ATTRIB[$INDEX]=$LINE[$INDEX]; } $INDEX+=1; } } } $INDEX=2; while ( $INDEX <= $LE_perm ) { print MAX_VALUE_QUERY_INDEX "MaxVal Attribute $INDEX is: $MAXVAL_ATTRIB[$INDEX]\n"; $INDEX+=1; } print MAX_VALUE_QUERY_INDEX "\n\n"; }