Created
June 9, 2020 22:33
-
-
Save rubemlrm/7e62c5edfe3b6c6898664891c92298e7 to your computer and use it in GitHub Desktop.
CheckNetworkMachines.pl
This file contains hidden or 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
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use Net::Ping; | |
use autodie; | |
my $host; | |
my $my_addr="<ip>"; | |
my $ping; | |
my @reportlist; | |
chomp(my $date = `date +%a%d%m%y%k%M`); | |
open(FILE, "<ficheiro com ips>"); | |
chomp (my @ips = <FILE>); | |
close(FILE); | |
foreach $host (@ips){ | |
$ping = Net::Ping->new(); | |
if ($ping->ping($host)){ | |
#print "$host -> está activo.n"; | |
push(@reportlist,"$host -> está activo."); | |
}else{ | |
#print "$host -> está offlinen"; | |
push(@reportlist,"$host -> está offline."); | |
} | |
$ping ->close(); | |
} | |
#Reporte da lista | |
foreach (@reportlist) | |
{ | |
print "$_n"; | |
} | |
#para um ficheiro a ser enviado por mail</p> | |
open(FILE , ">../logs/'$date_machine_networking_report.txt'"); | |
foreach (@reportlist){ | |
print FILE "$_n"; | |
} | |
close(FILE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment