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 ?
# 8  
Old 11-12-2013

Than's for your input.

Have you got a sample on syntax on how to implement awk command : "to check for a non-zero leading (sub)field in the time rather than just checking if it exists" ?

# 9  
Old 11-12-2013
Depending how your awk handles field splitting, you might be able to just do:
awk '$2>1' FS=":| "

Alternatively, you could use split:
awk '{split($2,times,":"); if (times[1]>1) {print}}'

(That's just outputting the rows, of course - you'd need to adapt it).
# 10  
Old 11-12-2013
You can replace my previous ERE :.+: by [-1-9][0-9]*:.+:
That will match only if there is a leading non-zero number.

---------- Post updated at 04:29 AM ---------- Previous update was at 04:23 AM ----------

However, my previous idea is not fully correct.
It will not catch processes that have run normally for some time then start to consume CPU time.

Last edited by MadeInGermany; 11-12-2013 at 04:02 PM.. Reason: Added a - to the charset to include e.g. 1-00:00:00
# 11  
Old 11-12-2013
Also, you might want to look at process accounting (psacct on RHEL, iirc).
# 12  
Old 11-12-2013
Here is an improved ps command.
It reports the processes that have accumulated 1 hour CPU time and still consuming CPU time. There is a high probability that the CPU time was accumulated within the last hour.
ps -eo pid,time,pcpu,args | awk '$2~/[-1-9][0-9]*:.+:/ && $3>50.0'

NB pcpu is currently per CPU on Linux (while e.g. on Solaris it is per system, i.e. divided by the number of virtual CPUs).
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