# Countdown Timer sub sleep_count { my $minutes = shift; my $string = shift; my $command = shift; my $command_time_interval = shift; my $countdown = $minutes*60; # in secs. $| = 1; my $beg_time = time; my $end_time = $beg_time + $countdown; for (;;) { my $time = time; last if ($time >= $end_time); printf("\r[ %02d:%02d ] $string", ($end_time - $time) / ( 60) % 60, ($end_time - $time) % 60, ); sleep(1); } } #### my $pid = fork(); if ($pid == 0) { sleep_count(3, 'Verifying with Nagios that resin is down: '); } else { my $nagios_check = `/usr/lib/nagios/plugins/check_http -H host.com -I $ip -p 80`; until ( $nagios_check !~ /HTTP OK HTTP\/1.0 200 OK/ ) { $nagios_check = `/usr/lib/nagios/plugins/check_http -H host.com -I $ip -p 80`; sleep 10; } waitpid($pid,0); }