LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-27-2009, 03:25 AM   #1
touser
Member
 
Registered: Apr 2005
Posts: 31

Rep: Reputation: 15
Kill process with high CPU usage after X time?


Hello everyone, running debian i have a few processes which tend to crash occasionally (game servers), which end up using 100% cpu. I'm looking for a program or script to check the cpu usage of a list of processes by name and if they are at 100% for more than X time, say 30 seconds, kill them. I tried ps-watcher but wasn't able to determine how to accomplish this. Just killing the process at 100% usage wont work as it will hit that for brief periods during normal operation. I've also found this script which seems to do what i want, however it is limited to one process: http://pastebin.com/m1c814cb4 Any help is greatly appreciated!
 
Old 12-27-2009, 01:54 PM   #2
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello touser,

this looks like you have to combine the "top" utility with "ps". This is only an idea, but I'd recommend to read the manpage of top.

Markus
 
Old 12-27-2009, 09:12 PM   #3
tanveer
Member
 
Registered: Feb 2004
Location: e@rth
Distribution: RHEL-3/4/5,Gloria,opensolaris
Posts: 525

Rep: Reputation: 39
you can take a look at monit. Hope that will server your purpose.
 
Old 12-27-2009, 09:22 PM   #4
damgar
Senior Member
 
Registered: Sep 2009
Location: dallas, tx
Distribution: Slackware - current multilib/gsb Arch
Posts: 1,949
Blog Entries: 8

Rep: Reputation: 203Reputation: 203Reputation: 203
Monit is probably the way to go.
PHP Code:
MONIT(1)                         User Commands                        MONIT(1)

NAME
       monit 
utility for monitoring services on a Unix system

SYNOPSIS
       monit 
[options] {arguments}

DESCRIPTION
       monit is a utility 
for managing and monitoring processesfilesdirec‐
       
tories and devices on a Unix systemMonit conducts automatic mainte‐
       
nance and repair and can execute meaningful causal actions in error
       situations
E.gmonit can start a process if it does not runrestart
       a process 
if it does not respond and stop a process if it uses too much
       resources
You may use monit to monitor filesdirectories and devices
       
for changessuch as timestamps changeschecksum changes or size
       changes

 
Old 12-27-2009, 09:52 PM   #5
touser
Member
 
Registered: Apr 2005
Posts: 31

Original Poster
Rep: Reputation: 15
Thanks guy's ive been looking at monit and it seems it may do the job, the only downside i can see so far is its requirement of a pid file. Each game server will need to write to one and maintaining that file could become problematic over time as there's no way I'm going to create a pid file for each game server instance. I'll post back here if i find a working solution
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
CPU usage too high! rock.k Linux - Newbie 4 03-01-2008 04:48 AM
High CPU usage ?! Why? skate Linux - Software 1 04-11-2007 05:55 AM
High Cpu usage untak Debian 21 01-23-2007 06:21 AM
high cpu usage on process "event/0" rioch Linux - Laptop and Netbook 6 05-03-2006 03:03 PM
cpu usage high corbintechboy VectorLinux 2 07-27-2005 08:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration