SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I need a linux script to control a runaway process...

    Do you know if this is possible, and how hard it would be to write?

    I need a script that does the following for linux:

    1. Checks for the existence of a specified process.
    2. If the process is found, has it been running for longer than 5 minutes at greater than 25% CPU usage?
    3. If so, then kill the process, write the event to a log file, and optionally send an email to admin.

    The script should accept input switches. For example:

    scriptname -p process_name -s 300 -u 25 -e admin@domain.com

    -p is the process name to monitor
    -s is the number of seconds the process must have been running before action is taken
    -u is the % of CPU that the process must be using before action is taken
    -e is the email address to receive event notification. Only send email if this switch is specified.

    The script should be executable via cron.

    Thanks!
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I reckon you could do it. The script would have to be run by a superuser (root,etc). But I don't know how

  3. #3
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What kind of script do you want this to be? PHP. If any of this is through a web browser, you can't do it without putting your su - info into the PHP which I highly warn against. This is because PHP runs as Apache which runs as nobody and you have to run as root.

    Now if you are talking about a C or Perl script, that is different, but still you can't call them via a web browser. If you have this access to the server and want to run it there as root, then that's another story but I reckon clarification is in the works.

    Aaron
    Aaron Brazell
    Technosailor




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •