Is there some way to detect if gateway is dead?
I am not good at networking aspects, all I know is that it is
not as trivial as use ruby/ping
Jacek Balcerski
(focus from a network point of view, not necessarily a Ruby point of view)
Well, pinging isn't that great because it just says "I can't get there" and
tells you nothing about where the connection failed. Plus, ICMP traffic
(specifically pinging) is frequently blocked on many networks at the gateway
level.
That aside, if you use tracert / traceroute (pending your OS), you can
actually find out where outtages are occuring.
Another thing is what are you exactly trying to monitor? Just that the
machine is up and running or that it is successfully routing traffic to
external sites? One thing I've done in the past at a previous company was
made a simple script that would GET a static HTML page. If it's able to
connect and see the very basic content that I could always compare against
(since it never changed), I knew I was routing externally through my
gateway. If it fails, then there's either a problem with your webserver or
the gateway. Through the use of ping and traceroute, you can probably
identify which is which.
Another aspect that may be a consideration is if your gateway also performs
DNS. If so, then you'll likely want to do these tests with both IP and the
domain name, to ensure that DNS works to resolve the name.
I would not rule out ping as a useful tool, but I agree that it's not the
only thing that's needed to positively identify a successful connection.
As you can see, there's tons of options, but it will largely come down to
your -specific- needs and setup.
-M