in reply to Using Perl to find Process Hogs

Boy, this sounds like a shop I used to work at. Do I know you from somewhere? ;-)

As I recall, HP-UX doesn't have anything like a /proc file system, so you're limited to tools like ps. What I did (and you're right, it's very sloppy) was to write a script that read the output from ps, saved the TIME column against each PID in a hash, slept, then did it again, and compared the time for each matching PID. If it was greater than a threshold, it printed a message (in your case, you would send an email).

I'm reconstructing this from memory, so you'll have to make this work for real, but the code basically looks like this:

my (%current, %previous); while (1) { open PS, "ps -ef |" or die "Can't run ps: $!\n"; while (<PS>) { # you need to do this with the correct column # widths; something like split won't work, # and a regex would be way too complicated. my ($pid, $time) = unpack '...'; $current{$pid} = $time; if (exists $previous($pid}) { # difference sub is an exercise for the reader.... if (difference($current{$pid}, $previous{$pid} >= $threshold) { warn "$pid is a piggy\n"; } } } close PS; %previous = %current; sleep 3600; }
Sorry I couldn't be more specific. HTH anyway.