Scripts for cleaning up Perf data - BB Custom Topics A - D - Big Brother - Dell Community

Scripts for cleaning up Perf data

Big Brother

Big Brother
Access more than 800 custom test extensions to share or use in resolving your IT challenges.

Scripts for cleaning up Perf data

This question has been answered by drussell

Hi,

We are currently using BB 4.4 with the new PERF functions enabled. Does anyone have scripts for cleaning or truncating the Perf data that is collected? I know that 4.5 is suppose to have the function programmed in. We are running the BB server on unix.

The Perf data is under the $BBHOME/bbvar/perf

The files are in text format with lines like this:

Verified Answer
  • Here is a not so elegant way to truncate your files in perl. You will have to define start time as a unix time stamp.

    #Purge $BBPERF
    @files = `grep -Rl . $BBPERF/*`;

    foreach $file (@files) {
    chomp($file);
    print "$file\n";
    @data=`cat $file | awk '{ if (\$4 >= $startTime) {print \$0} }'`;
    if(!(open (FILE, ">$file"))) {print "cannot open $file: $!\n"; print LOGFILE "cannot open $file: $!\n"; next;}
    foreach $line (@data) {print FILE $line;}
    close FILE;
    }

All Replies
  • Worked with a person that knows unix scripting and we worked out something that worked for us. I know things could be done cleaner instead of using the cd command.

    We created a directory under $BBHOME/bbvar/scripts. I created the script with the filename as part of the disk name. If I didn't have the filename I was getting errors.

    I changed the _*.%used to any specific filename (i.e. conn.duration). I also did simple commands to completely wipe the *.duration files.

    cd $BBHOME/bbvar/perf

    find . -name conn.duration -exec cp /dev/null {} \;

    I could introduce sleeps/waits instead of ls functions. I had to do something there or it wouldn't replace the file properly. The ls also let me see the before and after changes.

    clean-bb_test.sh

    #!/bin/ksh

    # base directory

    BASE=$BBHOME/bbvar/perf

    # lines to keep

    KEEP=104000

    # files live here:

    # ${BASE}/<nodename>/<function>/<file>

    cd ${BASE}

    ls | {

    while read node

    do

    cd ${node}

    ls | {

    while read function

    do

    cd ${function}

    ls _*.%used | {

    while read file

    do

    pwd

    tail -${KEEP} ${file} >> ${file}-new

    ls -al

    cp ${file}-new ${file}

    rm ${file}-new

    ls -al

    done # end of files

    }

    cd ..

    done # end of functions

    }

    cd ..

    done # end of node

    }

  • Here is a not so elegant way to truncate your files in perl. You will have to define start time as a unix time stamp.

    #Purge $BBPERF
    @files = `grep -Rl . $BBPERF/*`;

    foreach $file (@files) {
    chomp($file);
    print "$file\n";
    @data=`cat $file | awk '{ if (\$4 >= $startTime) {print \$0} }'`;
    if(!(open (FILE, ">$file"))) {print "cannot open $file: $!\n"; print LOGFILE "cannot open $file: $!\n"; next;}
    foreach $line (@data) {print FILE $line;}
    close FILE;
    }