I have been given a task to write a script that sounds simple, but is beyond the scope of my perl knowledge and so I come to you seeking help.
What is required is I need to write a script that runs every half hour and checks all the processes that are running on our UNIX server (HPUX 11.00 to be exact). If it finds a process that is utilizing more than 75% of a cpu, it should "mark" that process. The next time it runs, if that process is still using more than 75%, it sends an email to our group letting us know that there is a process hog so that we may take action on it.
Now, everything in the script I can do, with the exception of figuring out which processes are taking up more than 75% of the cpu. I could sloppily make a call to top and have it dump its output to a file and get it that way, but I know there has to be a way for perl to get that information without having to resort to using something like top.
I also need to note, that we are using perl version 5.6.1 and that going to cpan for additional modules that is not in the standard build is out of the question, we have a standard build on all of our systems and even upgrading to 5.6.1 was a large undertaking due to the fact that all the powers that be around here have to give their blessing.
That being said, does anyone know of a way to quickly grab the cpu utilization percentage of a process using perl?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.