$pm->run_on_finish(
sub {
my ($pid, $exit_code, $ident) = @_;
$connected_server_count += $exit_code;
$progress = ($count / $total_server_count) * 100;
printf "Progress: %4.1f\%\r",$progress;
$count++;
}
);
Example of a bad (0) return:
$pm->finish(0); # Couldn't connect to this one, skip to next server in
+ main loop
Example of a good (1) return:
# Close ssh connection to this server
$ssh->close();
$pm->finish(1);
The point being that $count kept track of how many servers were processed ($connected_server_count is used elsewhere) but it based that count on the return code. In this code, a server returned 0 if it could not connect, but returned 1 if it could, so I just summed those values. I've not played around with it, but I assume you can map out any numeric code to suit your purposes, perhaps the number of days, etc. |