Operating System - Tru64 Unix
1751698 Members
5420 Online
108781 Solutions
New Discussion юеВ

Re: Collect output

 
SOLVED
Go to solution
Sivasingam Santhakumar
Frequent Advisor

Collect output

Hi Admins,

Does any have written script to extract info from collect output?. For example I have output as in attached text file. How could I use awk/sed/perl to extract the data column wise?

Thanks
Siva
6 REPLIES 6
Matt Palmer_2
Respected Contributor

Re: Collect output

Hi, There is no attached file that I could find,but if you wanted to format the file, using awk/sed,etc you could try something like:

awk -F "\t" '{print $NR, ($1)" "($2)}' filename >newfile.txt

this assumes using "\t" that the file is delimited using tab, $NR number of 'records' and the other $ pertain to column ids,etc.

if you have access to gawk, this lets you use functions such as toupper and tolower, which you may also find helpful.


hope this helps.

regards

Matt
Sivasingam Santhakumar
Frequent Advisor

Re: Collect output

Sorry for not attaching. It should be now.
Matt Palmer_2
Respected Contributor
Solution

Re: Collect output

not really sure what u r trying to acheive, but you can try all sorts of stuff, i.e:

awk -F " " '{print $1 $2}' 99749.txt

this will print the first and second columns of the file using space as a delimiter, you might find it easier to use the -h (header) switch for collect to exclude the header information, which might also make the information easier to organize.

hope this helps

regards

Matt
Sivasingam Santhakumar
Frequent Advisor

Re: Collect output

Thanks Matt, I use collect out put to create monthly report to customer.

Regards
Siva
Hein van den Heuvel
Honored Contributor

Re: Collect output

Siva,

It woudl really help if you also included a template of what you want in yuo output. We are not mindreaders!

When parsing collect output you need to learn to recognize 'sections', or be able to distiguish the sometime minor difference in the dataline. Like a line with 13 words all numbers is possible the CPU SUMMARY.
For each line you gather 'interesting' data points and print them all out when done.
For example:

perl collect-summary your-file
will print: io=586, mb=52.38, cpu=6, free=23

-------- collect-summary ----

while (<>) {
$section=$1 if (/^# (DISK|LSM|CPU|MEMORY|SINGLE)/);
@words = split;
print "$section $words[0] $words[1]\n";
if (($section eq "DISK") && (/dsk/)) {
$io += $words[4] + $words[6];
$mb += $words[5] + $words[7];
}
if ($section eq "CPU") {
$cpu = $1 + $2 if (/^\s+(\d+)\s+(\d+)/);
}
if ($section eq "MEMORY") {
next if ($memory_header++ < 3); #skip header lines
$free = $words[0];
}
}
print "io=$io, mb=$mb, cpu=$cpu, free=$free\n"

Enjoy!
Hein.



Joris Denayer
Respected Contributor

Re: Collect output

Siva,

To make grepping easier, you could add the "-t" flag in your collect command.
This will add a tag before each line.

Here is an example for the CPU figures
# CPU SUMMARY
# USER SYS IDLE WAIT INTR SYSC CS RUNQ AVG5 AVG30 AVG60 FORK VFORK
cpusum: 0 2 98 0 252 1820 1693 0 0.07 0.03 0.01 0.00 0.00
# SINGLE CPU STATISTICS
# CPU USER SYS IDLE WAIT
cpusin: 8 0 3 97 0
cpusin: 9 0 1 99 0
cpusin: 10 0 2 98 0
cpusin: 11 1 1 98 0

Hope it might be useful

Joris
To err is human, but to really faul things up requires a computer