Created
September 22, 2015 18:06
-
-
Save jsimpsoncd/377cf19790532558b3e8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Data::Dumper; | |
use Term::ANSIColor; | |
use Net::Ping; | |
use Term::ANSIScreen qw(cls); | |
use Term::Screen; | |
my $clear_screen = cls(); | |
$path_to_file = $ARGV[0]; | |
open my $handle, '<', $path_to_file; | |
chomp(my @host_array = <$handle>); | |
close $handle; | |
$scr = new Term::Screen; | |
print $clear_screen; | |
$p = Net::Ping->new("icmp",'1'); | |
while (1) { | |
$scr->at(0,0); | |
$datestring = localtime(); | |
print "Last Cycle $datestring"; | |
foreach $host (@host_array){ | |
$f++; | |
$x = 30 * ($f % 2); | |
$y = (($f - ($f % 2)) / 2) + ($f % 2); | |
$scr->at($y,$x); | |
@hostinfo = $p->ping($host, 1); | |
#if ($p->ping($host,1)) { print color('green'); } else { print color('red'); } | |
if ($hostinfo[0]) { print color('green'); } else { print color('red'); } | |
print "$host"; | |
#$scr->at($f,40); | |
#print "$hostinfo[1]"; | |
print color('reset'); | |
} | |
$f=0; | |
} | |
$p->close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment