How to monitor process that consumes 100% during more than 01 hour ?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to monitor process that consumes 100% during more than 01 hour ?
# 1  
Old 11-03-2013
How to monitor process that consumes 100% during more than 01 hour ?

Hi,


On Linux RedHat 5 ( 2.6.18-194.el5 ) I need to monitor process that consumes 100% CPU during more than 01 Hour.

Are there command lines ? scripts ?

Regards,
# 2  
Old 11-06-2013
you can use sar.
# 3  
Old 11-06-2013
A ps command that finds processes with >= 1 hour CPU time
Code:
ps -eo pid,time,args | awk '$2~/:.+:/'

---------- Post updated at 04:45 PM ---------- Previous update was at 04:27 PM ----------

Comparing CPU time with elapsed time seems to meet your requirement
Code:
ps -eo pid,time,etime,args | awk '$2~/:.+:/ && $3~/:.+:/ && substr($2,1,index($2,":")) == substr($3,1,index($3,":"))'


Last edited by MadeInGermany; 11-06-2013 at 05:50 PM..
# 4  
Old 11-07-2013
Hi,

Thank's very much for your input :

The Command you provided does not return any output.

Top Output :
Code:
Tasks: 324 total,   2 running, 321 sleeping,   0 stopped,   1 zombie
Cpu(s):  6.6%us,  0.1%sy,  0.0%ni, 93.4%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:  24682292k total, 24482668k used,   199624k free,   358612k buffers
Swap: 18874360k total,      280k used, 18874080k free, 15356824k cached
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                
16459 appl12r   25   0  103m  58m  17m R 99.7  0.2   1058:32 frmweb                                                                 
 7863 appl12r   15   0 98.6m  55m  14m S  4.0  0.2   0:56.67 frmweb                                                                 
 9882 appl12r   15   0 12888 1296  808 R  0.7  0.0   0:00.12 top

Code:
[erpprda1:appl12r /home/appl12r]$ ps -eo pid,time,etime,args | awk '$2~/:.+:/ && $3~/:.+:/ && substr($2,1,index($2,":")) == subst>
[erpprda1:appl12r /home/appl12r]$


Last edited by Franklin52; 11-10-2013 at 04:28 PM.. Reason: Please use code tags
# 5  
Old 11-07-2013
What output do you get from:
Code:
ps -eo pid,time,etime,args

# 6  
Old 11-10-2013
Hi,

Sample output of the following Command : ps -eo pid,time,etime,args
Code:
[erpprda1:appl12r /home/appl12r]$ ps -eo pid,time,etime,args
  PID     TIME     ELAPSED COMMAND
    1 00:00:11 220-19:01:04 init [3]         
    2 00:00:32 220-19:01:04 [migration/0]
    3 00:00:00 220-19:01:04 [ksoftirqd/0]
    4 00:00:00 220-19:01:04 [watchdog/0]
    5 00:00:44 220-19:01:04 [migration/1]
    6 00:00:00 220-19:01:04 [ksoftirqd/1]
    7 00:00:00 220-19:01:04 [watchdog/1]
    8 00:00:03 220-19:01:04 [migration/2]
    9 00:00:01 220-19:01:04 [ksoftirqd/2]
   10 00:00:00 220-19:01:04 [watchdog/2]
   11 00:00:02 220-19:01:04 [migration/3]
   12 00:00:01 220-19:01:04 [ksoftirqd/3]
   13 00:00:00 220-19:01:04 [watchdog/3]
   14 00:00:02 220-19:01:04 [migration/4]
   15 00:00:00 220-19:01:04 [ksoftirqd/4]
   16 00:00:00 220-19:01:04 [watchdog/4]
   17 00:00:03 220-19:01:04 [migration/5]
   18 00:00:00 220-19:01:04 [ksoftirqd/5]
   19 00:00:00 220-19:01:04 [watchdog/5]
   20 00:00:07 220-19:01:04 [migration/6]
   21 00:00:00 220-19:01:04 [ksoftirqd/6]
   22 00:00:00 220-19:01:04 [watchdog/6]
   23 00:00:08 220-19:01:04 [migration/7]
   24 00:00:00 220-19:01:04 [ksoftirqd/7]
   25 00:00:00 220-19:01:04 [watchdog/7]
   26 00:00:08 220-19:01:04 [migration/8]
   27 00:04:34 220-19:01:04 [ksoftirqd/8]
   28 00:00:00 220-19:01:04 [watchdog/8]
   29 00:00:07 220-19:01:04 [migration/9]
   30 00:02:45 220-19:01:04 [ksoftirqd/9]
   31 00:00:00 220-19:01:04 [watchdog/9]
   32 00:00:12 220-19:01:04 [migration/10]
   33 00:03:04 220-19:01:04 [ksoftirqd/10]


Regards,

Last edited by Franklin52; 11-10-2013 at 04:28 PM.. Reason: Please use code tags
# 7  
Old 11-11-2013
I'm guessing MadeInGermany's output didn't include empty time fields - you'd need to update the awk to check for a non-zero leading (sub)field in the time rather than just checking if it exists.

EDIT: And also handle days somehow...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run a process continuously for an hour then stop?

Hi I have a shell script I would like to run it has to run twice a day every 5 seconds for an hour I can do this with cron but I was hoping there was an easier way. Is there a way to make a process sleep only at a certain time of day say between 1 and 2 pm? Or under certain conditions? Any help... (8 Replies)
Discussion started by: Paul Walker
8 Replies

2. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

3. Shell Programming and Scripting

How to find which process consumes more memory

in our Oracle DB server, the free RAM is very low. we would like to know which process consumes more RAM what is the comand I can use ? (1 Reply)
Discussion started by: johnveslin
1 Replies

4. Shell Programming and Scripting

Monitor file generation for an hour using Korn shell script

Hi, I am new to this unix scripting, I got a requirement like.. Files with *.XML extension will be generating in a /home/sample/ folder for every 15 mins. I need to monitor those files in that particular folder for every hour. If no file has been generated in that particular folder for an... (7 Replies)
Discussion started by: siri_886
7 Replies

5. UNIX for Advanced & Expert Users

code to monitor a process

hi, I need to change the code such that it becomes configurable to send email or sms or both. At the moment the code works like sending both email and sms for any alert now want to change it to send email/sms as per my demand. 1. Like for a particular alert I only want email 2. If the alert... (2 Replies)
Discussion started by: madfox
2 Replies

6. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

7. Shell Programming and Scripting

not able to monitor the process

hi all I am running a script monitor using source command. the shell script monitor is used to execute a pl/sql procedure. when i do source monitor and then ps -ef | grep <procedure name> i do not get any info but when i do sh monitor and then ps -ef | grep <procedure name> i... (8 Replies)
Discussion started by: infyanurag
8 Replies

8. Solaris

Kill a particular process if it's over an hour hold

I meant old not hold :) I need to kill a process if it's over an hour old and then send an e-mail of the list that was killed.....? I need to kill ps -ef | grep stashd | grep ' older than an hour?' #! /bin/bash if test ps -ef | grep <stashd> (Is over an hour old)???? >>stashd_old.txt ... (9 Replies)
Discussion started by: xgringo
9 Replies

9. Shell Programming and Scripting

Need to process files created an hour ago

Hello all, I would like to ask for an advice on how to deal with the following scenario. Every now and then, our ERP system creates an interface text file with the following file format - XORD????.DLD where ???? is a sequence number. We can have 1 or more XORD files created in an hour. ... (9 Replies)
Discussion started by: negixx
9 Replies

10. Shell Programming and Scripting

Lightwight Process monitor

We've been having some problems with a specific program in our nightly processing, so I whipped up a little script to run to monitor it, and send an e-mail when it's complete (failure or not). My primary problem is that I cannot modify the binary or the script that calls it, since the developers... (7 Replies)
Discussion started by: LivinFree
7 Replies
Login or Register to Ask a Question