Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Operating System - Tru64 Unix
cancel
Showing results for 
Search instead for 
Did you mean: 

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
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