in reply to Is this the most efficient way to monitor log files..
while ($percomp != 100) {
How long does $percomp take to reach 100?
If it's any decent length of time, then the above is probably the source of your CPU drain as you continually run the loop (and without pause) until $percomp does hit 100.
Slipping a sleep N; (where N is an arbitrary number of seconds) inside the while should help cure the hogging as it'll make your script pause for a little while every run of the loop, giving the the CPU breathing room to do something else.
Update: I notice that you my $percomp both inside and outside the loop, which means -- thanks to scoping -- your while is equivalent to while (1) { as the outer $percomp will never equal 100.
Perhaps you could change that loop to a favoured construct of mine ...
while ( sleep 1 ) { # ... if ($percomp == 100) { print "\n$drac{Type} job $drac{primary} ", "on $drac{hostname} -- DONE\n"; last; } else { # ... } }
--k.
|
|---|