Operating System - HP-UX
1747997 Members
4579 Online
108756 Solutions
New Discussion

help inserting headings/title on a script

 
SOLVED
Go to solution
NDO
Super Advisor

help inserting headings/title on a script

Hi all!

Please can somebody help, I wrote a small script that provides info on performance, but, I´ve not managed to put headings for the values to be displayed. For example:
N. of CPUs, CPU Utiliz, Mem Utili, Runqueue
4 50 44 3
4 57 34 2
4 45 45 1

Please can you help?

F.R.
7 REPLIES 7
Doug O'Leary
Honored Contributor
Solution

Re: help inserting headings/title on a script

Hey;

This seems pretty easy:

printf "%s %2s %2s %s\n" "C" "CU" "MU" "R"
echo "=============="

at the top of your script before you collect the sar or vmstat output.

That seems pretty self evident, so I'm assuming I'm missing something?

Doug

------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
NDO
Super Advisor

Re: help inserting headings/title on a script

Hi Doug!

Thanx for your prompt response, but I´m new into scripting, the idea below the headings is to use gbl_cpu_util, gbl_mem_util, etc, and use that file as an advise syntax file to be used with glance. Pls can you explain your code, if is not asking too much.

regards

FR
Hein van den Heuvel
Honored Contributor

Re: help inserting headings/title on a script

If you show us yours, we'll show you our s olutions.

- What tools are you using? Shell (which?) Awk?
- What tools can you use? Perl?
- Where does the data come from?
- What should the result ideally look like?
- If you can, provide a .TXT attachement with code and data examples, in addition to the posted text to get a clear view on spaces/spacing.

Doug unconditionally uses 2 disting methods of printing. The crude 'echo' and the refined printf with full formatting control.

When dealing with header lines, I often use conditional prints like (perl)

print "heading\n" unless $lines++

in AWK I might use BEGIN { } or (NR=-1)

Please help us help you!
Regards,
Hein
NDO
Super Advisor

Re: help inserting headings/title on a script

Hi

I am using this comand:(opt/perf/bin/glance -adviser_only -iterations 5 -j10 -syntax /tmp/fr/advtest > /tmp/fr/streess.out )
with that adviser file: (print " ", gbl_statdate, " ", gbl_stattime

print "number of CPUs online,",gbl_active_cpu
print "Total CPU utilization, ",gbl_cpu_total_util
print "Average n of processes using CPU,",gbl_cpu_queue
print "% of physical mem in use, ",gbl_mem_util
print "% of swap space available,",gbl_swap_space_util
print "Average of time of all disks being used,",gbl_disk_util
print "% of time of busiest disk had I/O in progress, ",gbl_disk_util
)
but for easy formating in excel I want to change the layout, so puting the headings in one line, and the values at the bottom.

regards

FR
Hein van den Heuvel
Honored Contributor

Re: help inserting headings/title on a script

( Earlier I meant to write $. == 1 )

Hmmm, some of us do not have those tools handy, but they know what to do with the input/output if shown in detail.

Given the width of the heading the current format with heading on left would seem 'nicer' than the classic heading on top.

Anyway,
Can you not just re-arrange those 'nice' print lines with ugly (for you) result into really ugly print lines with nice results?

Something like (and you complete...) :

print "number of CPUs online,Total CPU utilization,Average n of processes using CPU,% of physical mem in use"...

print gbl_active_cpu, gbl_cpu_total_util,gbl_cpu_queue,gbl_mem_util ....

In a pinch you can teach Excell to rotate the data, or post process the text file to do so. For example with perl something like:

$ perl -lne '($nam[$i],$val[$i++]) = split /,/ }{ print join q(,),@nam; print join q(,),@val' < bad > good

Btw... you had gbl_disk_util used twice.

Good luck,
Hein

NDO
Super Advisor

Re: help inserting headings/title on a script

Hein!

I tought you were going to show yours:)?

FR

NDO
Super Advisor

Re: help inserting headings/title on a script

Hi

The answers provided did shed some light into it.

thanx

FR