LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Monitor a Process (https://www.linuxquestions.org/questions/linux-server-73/monitor-a-process-752691/)

linuxaddict7 09-04-2009 11:41 AM

Monitor a Process
 
Hello, I am looking for utility or ideas on how to monitor a process. If the process consumes, say 98% of CPU, I wanted to restart a service or run a script which will do some maintenance.

thanks in advance.

~LA

Zarniwoop79 09-04-2009 11:43 AM

Have you tried top? It shows memory usage, cpu usage etc, and lists the "heaviest" processes including the cpu usage.

If you just run it with "top" it keeps running and updates every 3 (?) seconds, but if you want to output the result to e.g. a file you can do

"top -b -n1", then it just updates the information once, and this can of course also be redirected to a file or a script.

RaelOM 09-04-2009 01:19 PM

Look into nagios. It has alert threashold and you can trigger actions on alerts. Not too difficult to setup if your an experienced UNIX Admin.

Otherwise, I would just write a script that would monitor the cpu utilization of the process.

EricTRA 09-04-2009 01:22 PM

Hello,

If the obligation of having to edit text files to configure Nagios then have a look at GroundWork OpenSource, it's based on Nagios 3.0 and has a very easy web interface to configure it.

Kind regards,

Eric

linuxaddict7 09-08-2009 09:40 AM

I dont have Nagios infrastrature, but I would like to do it via cron. One of the main reason is, when its done thru agent/server, the cpu is at 99%, the agent may time out.

I looked at the top output, I can get a better output with ps, but my problem is I need monitor for pid for atleast say 3 minutes to restart the service.


All times are GMT -5. The time now is 06:56 AM.