in reply to Re: Re: Pinging.
in thread Pinging.

aaarrrgghh, now i have a real problem. I forgot that the firewall between my server and the outside world drops ping requests. is there any way to check to see if my server is alive using a TCP connect method to see if it recieves a response form a port? i.e connect to port 25 and see if my smtp server responds? thanks

Replies are listed 'Best First'.
Re: Re: Re: Re: Pinging.
by valdez (Monsignor) on Aug 07, 2002 at 14:01 UTC

    You can do as follow:

    use Net::SMTP; @verify = ('smtp.host1.tld', 'smtp.host2.tld'); foreach $host (@verify) { $smtp = Net::SMTP->new($host); if (ref($smtp)) { print $smtp->banner(); } else { print "failed $host!\n"; } }

    This kind of check probably is better than pinging a host, but still doesn't tell you what is happening. A better solution would be to download a file from every remote host to be checked; if you can make these files contain some useful informations, like uptime, load average and disk usage, you can check what is happening and prevent also some kind of errors (i.e. disk full).
    You can generate those files automatically via a cron job and download them via HTTP or FTP, as you prefer.

    Ciao, Valerio