solignis has asked for the wisdom of the Perl Monks concerning the following question:
At first I thought maybe it was my script, so I made a really small perl script to check that it was NOT my script.
#!/usr/bin/perl use strict; use warnings; use Net::Ping; my $target = 'esxi01'; my $ping_obj = Net::Ping->new(); if ($ping_obj->ping($target)) { print "Yes, I can ping $target\n"; } else { print "No, I cannot ping $target\n"; }
The script fails to ping anything but 127.0.0.1
**Update**After plugging the right word in the magical Google, I got post from someone who had the same problem and their problem was fixed by doing;
my $ping_obj = Net::Ping->new('icmp');The part I cannot figure out is why does it work when specify "icmp" but not work when I use the defaults? That is how I have used it in the past and it worked fine.
I just tried to test for an open port using the function I have used in my last script(s), once again I made a test script based off the once above with the needed modifications.
#!/usr/bin/perl use strict; use warnings; use Net::Ping; my $target = 'esxi01'; my $ping_obj = Net::Ping->new('tcp'); $ping_obj->service_check('1'); $ping_obj->port_number('22'); if ($ping_obj->ping($target)) { print "Yes, I can ping $target\n"; } else { print "No, I cannot ping $target\n"; } $ping_obj->close();
This script also tells me the host is not pingable but yet I can already get into via SSH so its very much alive and open.
What is going on here?
|
|---|