Operating System - HP-UX
1834533 Members
3021 Online
110069 Solutions
New Discussion

single process cpu utilization

 
Court Campbell
Honored Contributor

single process cpu utilization

I am trying to figure out a way to see the cpu utilization of a process. My goal is to have a script that checks whether a particular process is using 100% of the a cpu. My company has HIDS implemented and it chews up a processor every week. I would like to either alert meyself so I can stop and restart the process or have a script that does it for me. Any ideas? I thought of outputing top to a file and parsing the output, but that looks ugly. I was also thinking of using glance in advisor only mode. Not sure how to get it to watch that particular process.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
5 REPLIES 5
Court Campbell
Honored Contributor

Re: single process cpu utilization

All right. I looked at the man for top and saw the -f switch. I think I have an idea now. Before I was doing:

top -d 1 > top.out

this included a bunch of formatting in the file. Using this is workable:

top -d 1 -h -f top.out

I can then write a script to find the process in the output and work from there.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Court Campbell
Honored Contributor

Re: single process cpu utilization

found my answer.

P.S. I just noticed that I only needed to do

top -f top.out

also it appends to the file if you use it again. it doesn't overwrite the file.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Abhinesh AV
Occasional Advisor

Re: single process cpu utilization

You can also use the command
#timex command.
Court Campbell
Honored Contributor

Re: single process cpu utilization

Dude, I am looking at an already running process. Timex is far from what I was looking for. I solved my problem.
"The difference between me and you? I will read the man page." and "Respect the hat." and "You could just do a search on ITRC, you don't need to start a thread on a topic that's been answered 100 times already." Oh, and "What. no points???"
Pierre Pasturel
Respected Contributor

Re: single process cpu utilization