1819836 Members
3091 Online
109607 Solutions
New Discussion юеВ

Re: topas

 
SOLVED
Go to solution
Mark Brook_3
Advisor

topas

Hi,

I dont really know unix, but sometimes use glance to check the performance of the system, what I need to know is if there is a command to run which will just to pull off the CPU performance to the screen, rather than GUI.

Hope this makes sense.

THanks
25 REPLIES 25
Robert-Jan Goossens
Honored Contributor

Re: topas

Hi,

Topas is the AIX version of top.

# top

Regards,
Robert-Jan
Anshumali
Esteemed Contributor

Re: topas

one small from my side..
top is resource extensive command.
Please run it using
nice top

:)
Dreams are not which you see while sleeping, Dreams are which doesnt allow you to sleep while you are chasing for them!!
Mark Brook_3
Advisor

Re: topas

Thanks for the replys.

I may have mis typed my post (sorry)

What I am trying to do is monitor the processor every hour to a flat file.
So I can review the next day.

Hope it's explained better this time.

Mark
James R. Ferguson
Acclaimed Contributor
Solution

Re: topas

Hi Mark:

You can collect 'top' output into a file by using the '-f -file' switch and argument with 'top':

# top -s 3600 -f /tmp/topoutput

...would snapshot every 3600 seconds to the file "/tmp/topoutput".

Regards!

...JRF...
Robert-Jan Goossens
Honored Contributor

Re: topas

Hi,

No problem!

heck the root's crontab for the lines containing sa1 and sa2 eg.

* * * * /usr/lbin/sa/sa1 1200 3
0 0 * * * /usr/lbin/sa/sa2 -s 00:00 -e 23:45 -1 3600 -A

run the sar command

# sar
00:00:00 %usr %sys %wio %idle
00:10:00 0 1 1 98
00:20:00 0 1 1 98
00:30:00 0 1 1 98
00:40:00 0 1 1 98
00:50:00 0 1 1 98
01:00:00 0 1 1 98
01:10:00 0 1 1 98
....

Regards,
Robert-Jan
Mark Brook_3
Advisor

Re: topas

Thanks again.

One last question now sorry if it's dragging on.

What I am trying to do is be alerted to a file when the CPU is less than 70% idle.

What I have done with your help and someone at work is

sar 1 1 > filename.txt
got the following
14:07:49 1 1 0 98
then
cut -c39-40 filename |tail -1 > filename2.txt
which then contains
98

The question is then how do I create a text file if the figure in the file is less than 70.

Hope you can help.

Again sorry for it dragging on.

Thanks

Mark


Wim Rombauts
Honored Contributor

Re: topas

Maybe something like this in a script ?

LOAD=$(sar 1 1 | tail -n 1)
IDLE=$(echo $LOAD | cut -d " " -f 5)
if [ $IDLE -lt 70 ]
then
echo "$LOAD" >> /path/to/cpu_logile.log
fi
Mark Brook_3
Advisor

Re: topas

Thank you that works till a point. My scripting isnt too good.

I get an error

/sarwatch.txt[5]: [81: not found.

which appears when it gets to the if statment.

LOAD=$(sar 1 1 | tail -n 1)
IDLE=$(echo $LOAD | cut -d " " -f 5)
if [ $IDLE -lt 70 ]
then
echo "$LOAD" >> /path/to/cpu_logile.log
fi

Thanks again.

Mark
Dennis Handly
Acclaimed Contributor

Re: topas

>I get an error
/sarwatch.txt[5]: [81: not found.

This means your cut didn't work and it has a "[" in the field?

LOAD=$(sar 1 1 | tail -n 1)
IDLE=$(echo $LOAD | cut -d " " -f 5)
if [ $IDLE -lt 70 ]

If you don't use LOAD anywhere else, you could just pass the sar output directly to awk. awk has a more usable interface to select fields. cut(1) would treat each space as a delimiter, even if two in a row.

If you quoted "$IDLE" above, you wouldn't get that "not found" error but you wouldn't know your script was broken:
if [ "$IDLE" -lt 70 ]; then
Wim Rombauts
Honored Contributor

Re: topas

What happens if you execute the commands one by one on the shell prompt ?

LOAD=$(sar 1 1 | tail -n 1)
echo $LOAD
IDLE=$(echo $LOAD | cut -d " " -f 5)
echo $IDLE

End then :

if [ $IDLE -lt 70 ]
then
echo "less then 70"
else
echo "more then 70"
fi
Mark Brook_3
Advisor

Re: topas


Thanks everyone

I have typed in the commands manually can get the following.
LOAD=$(sar 1 1 | tail -n 1)
echo $LOAD
07:39:51 53 13 25 9
IDLE=$(echo $LOAD | cut -d " " -f 5)
echo $IDLE
9

however when I type in the if statment it goes to a different prompt >
$ if [ $IDLE -lt 70 ]
> then
> echo "less then 70"
> else
> echo "more then 70"
> fi
Wim Rombauts
Honored Contributor

Re: topas

The different prompt is normal, since the shell cannot execute the first line of the if-statement alone, it needs all commands until the "fi" to complete the command.
As long as you type no "fi", you will keep receiving the ">" prompt.

Did the if command return a "less than 70" output ?
Mark Brook_3
Advisor

Re: topas

Thanks

No it didnt echo anything
$ if [ $IDLE -lt 70 ]
> then
> echo "less then 70"
> else
> echo "more then 70"
> fi



Wim Rombauts
Honored Contributor

Re: topas

Strange, it should echo something ...
When I enter :
$ IDLE=66
$ if [ $IDLE -eq 66 ]
> then
> echo XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
> fi
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
$

Whatever if-statement you write, it should execute the 'then' OR the 'else' and both contain an echo command, so there should be output allways.

At the other hand : If you cut and paste the commands that you typed manually into a script and execute the script, does it still return an error as before ? Since the individual commands work, they should also work in a script.
Mark Brook_3
Advisor

Re: topas

Sorry for been a pain.

The scriptLOAD=$(sar 1 1 | tail -n 1)
echo $LOAD
IDLE=$(echo $LOAD | cut -d " " -f5)
echo $IDLE
if [$IDLE -lt 70] then
echo $LOAD
else
echo "more than 70"
fi

The output08:57:34 22 7 36 36
36
/sarwatch.txt[5]: Syntax error at line 8 : `else' is not expected.

It's doing my head in now..........

THanks

Mark



Wim Rombauts
Honored Contributor

Re: topas

You need to put the "then" on a new line, that is the reason for the error.
Mark Brook_3
Advisor

Re: topas

Thanks.

The results are now

11:10:34 0 1 6 93
93
/sarwatch.txt[5]: [93: not found.
more than 70

Which it's reporting its more than 70 now, but still get the not found bit.

Mark
Mark Brook_3
Advisor

Re: topas

Thanks everyone.

Got it to work.

the -lt 70 needed to be a variable.

ie

1 LOAD=$(sar 1 1 | tail -n 1)
2 IDLE=$(echo $LOAD | cut -d " " -f5) >/dev/null
3 VAR1=10
4 echo $IDLE
5 if [ $IDLE -lt $VAR1 ] ; then
6 echo "less than"
7 else
8 echo "more than 70"
9 fi
Wim Rombauts
Honored Contributor

Re: topas

Strange, I think you have an issue in your shell.
On my system "if [ $IDLE -lt 70 ]" works fine.
What is your OS-version and what shell are you working in (I am using sh on HP-UX 11i v2, the default posix-shell on HPUX)? And what is your patch level of the shell (swlist -l product | grep PHCO | grep sh) ? I have PHCO_32444 fo sh-posix.
Dennis Handly
Acclaimed Contributor

Re: topas

if [$IDLE -lt 70] then

This fails for 3 reasons, you need a ";" after the "]". You need a space before and after "[" and before the "]":
if [ $IDLE -lt 70 ]; then

You need to attach your script next time because you had the spaces when posted the first time.

>Wim: You need to put the "then" on a new line,

Only if you like that yukky style. :-)

/sarwatch.txt[5]: [93: not found.

This is exactly what you get with:
if [$IDLE ...

>Got it to work. the -lt 70 needed to be a variable.

No, you need to have consistent spacing. When you changed to a variable, you put in some spaces.

>Wim: I think you have an issue in your shell.

No, with the shell input that keeps changing. :-)
Mark Brook_3
Advisor

Re: topas

The version of unix is 11 and it hasnt been patched since year 2000.

Mark
Dennis Handly
Acclaimed Contributor

Re: topas

>The version of unix is 11

This is not that helpful. Please provide all 5 chars: 11.00?
Mark Brook_3
Advisor

Re: topas

Sorry

B.11.00 U 9000/800 (tm)
Dennis Handly
Acclaimed Contributor

Re: topas

I assume you saw my reply about spacing being your problem, rather than OS version?