Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

script to monitor pid process

Jim Gerken
Occasional Advisor

script to monitor pid process

My oracle instance is in a shared environemt. I need a script to monitor the memory and cpu consumed by these processes.
12 REPLIES
Steven E. Protter
Exalted Contributor

Re: script to monitor pid process

This has been done.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0xf0fc5dc05a7ad711abdc0090277a778c,00.html

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x836cc1c4ceddd61190050090279cd0f9,00.html

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x026250011d20d6118ff40090279cd0f9,00.html

My Oracle scripts thread comes to mind.

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x4177ef70e827d711abdc0090277a778c,00.html

It is in there somewhere.

Lots of good scripts to think about using anyway.

Good Luck,

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Jean-Louis Phelix
Honored Contributor

Re: script to monitor pid process

Hi,

I would use a loop containing something like :

UNIX95= ps -ef -o vsz,pcpu | grep list_of_process

Regards.
It works for me (© Bill McNAMARA ...)
Bruno Vidal
Respected Contributor

Re: script to monitor pid process

Hi,
Tow solution:
1. If you have glance, a good option
is to use:
glance -adviser_only -syntaxe filename
where filename is a small glance script, you have really good example in:
/opt/perf/examples/adviser

2. Or use this small script:
export UNIX95=1
while true
do
ps -o vsz,pcpu,comm -C cmd_name
sleep 5
done

Cheers.
Jim Gerken
Occasional Advisor

Re: script to monitor pid process

Hey you guys are right on it...

I have the following script which seems to give me what I need.

echo "PID USER CPU% MEM_SIZE COMMAND"
while true
do
UNIX95= ps -eo "pid ruser pcpu vsz=Kbytes" -o comm | grep oracleT5751
sleep 1
done

It returns something like this...

8532 ormesa 0.02 32832 oracleT5751
536 ormesa 0.02 32832 oracleT5751
524 ormesa 0.02 32832 oracleT5751
22005 ormesa 0.02 32832 oracleT5751
8536 ormesa 0.02 40128 oracleT5751

I need to graph this in excel to show the memory / cpu consumed by each pid. I'm a little confused on how to setup the graph? any ideas...
Jean-Louis Phelix
Honored Contributor

Re: script to monitor pid process

hi,

You could add some formatting to your output like :

echo "PID USER CPU% MEM_SIZE COMMAND"
while true
do
UNIX95= ps -eo "pid ruser pcpu vsz=Kbytes" -o comm | grep oracleT5751
sleep 1
done | sort | tr ' ' ','

Put this output into a file which can then be easily imported in Excel as a csv file (comma separated values).

Regards.
It works for me (© Bill McNAMARA ...)
Jim Gerken
Occasional Advisor

Re: script to monitor pid process

How can I add a time stamp to this script?

echo "PID USER CPU% MEM_SIZE COMMAND"
while true
do
UNIX95= ps -eo "pid ruser pcpu vsz=Kbytes" -o comm | grep oracleT5751
sleep 1
done

Jean-Louis Phelix
Honored Contributor

Re: script to monitor pid process

echo "PID USER CPU% MEM_SIZE COMMAND"
while true
do
UNIX95= ps -eo "pid ruser pcpu vsz=Kbytes" -o comm | grep oracleT5751
sleep 1
done | sed 's;^;'$(date +'%y%y%m%d%H%S')' ;'

Regards
It works for me (© Bill McNAMARA ...)
H.Merijn Brand (procura
Honored Contributor

Re: script to monitor pid process

#!/usr/bin/perl
$ENV{UNIX95} = " ";
print "Stamp PID USER CPU% MEM_SIZE COMMAND\n";
while (1) {
my @t = localtime;
printf "%02d:%02d:%02d %s", @t[2,1,0], grep /oracleT5751/, `ps -eo "pid ruser pcpu vsz=Kbytes" -o comm`;
sleep 1 ;
}

spaces get lost in forum traffic. Add to your own needs.

Of course this should be done using Unix::Procestable, and plotted with Perl/Tk on the fly ...

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Jim Gerken
Occasional Advisor

Re: script to monitor pid process

Thanks you guys are all right....
H.Merijn Brand (procura
Honored Contributor

Re: script to monitor pid process

You /can/ express your thanks in a more forum appropriate way:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x022718276953d61190040090279cd0f9,00.html

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Jim Gerken
Occasional Advisor

Re: script to monitor pid process


I put he following into a file called "CPU"

echo "PID USER CPU% MEM_SIZE COMMAND"
while true
do
UNIX95= ps -eo "pid ruser pcpu vsz=Kbytes" -o comm | grep oracleD5751
sleep 10
done | sed 's;^;'$(date +'%m%d%H%M%S')' ;'

I execute this file to put the contents into a log.

date > cpu.log ; cpu >> /tmp/junk/cpu.log

However the date time stamp on the output never increments. It prints the first date time and then repeats it with each interation? Any thoughts...



H.Merijn Brand (procura
Honored Contributor

Re: script to monitor pid process

yes, re-read both my replies :)

Enjoy, have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn