Forgive me, monks. My copy of
Learning Perl,
The Perl Cookbook, and
Programming Perl is buried in a storage locker.
I'm currently working on a simple script that watches for processing that hog the CPU. I'm not really interested in monitoring CPU time. I want to take the "ps" output from a Linux system, snap up the PIDs of processes "currently" using > $percentage of the CPU, sleep for a bit, and repeat the process. After a few loops, I want to kill these processes.
I'm getting stuck at using a custom if() statement. I have a neat and clean variable at the top of the script:
$operator = '> 98.0';
This doesn't seem to work in this context:
if ($consumption $operator) { do something; }
I know there's a way to achieve this, but I don't remember how. Any help, is as always, very much appreciated.
Thanks guys!
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.