1

What is the best approach to setting up a script to monitor and report a server's connection to the Internet? I'm not referring to connection to the local network, but rather a server's (or the whole network's) ability to access the Internet, for the cases when your ISP's connection goes down.

It would need to be a script that tests for an Internet connection 24/7 and logs the results (or possibly just logs when there is an outage), and then some other way to read these logs and generate a report, showing various stats (what % of the time was the ISP connection offline, etc).

Would this just be something as simple as pinging various popular URLs (google.com, amazon.com, etc), and using that as a test to determine if you have internet access? Or is there a better approach?

The purpose of this is mostly to log all the time our ISP is failing us, so we can show them and they can use it to fix the problem or to use the logs as leverage for my boss to use to switch ISPs.

4
  • What scripting languages do you have at your disposal? You don't even mention windows or unix based. Something like Nagios or Zabbix or any other monitoring system can do that, but might be a bit complex for your needs.
    – Grant
    Oct 1, 2013 at 20:04
  • Sorry. Linux server here. So Bash or Python or whatever. Oct 1, 2013 at 20:19
  • 1
    You really don't want to re-invent the wheel when it comes to monitoring. Monit is a really light weight monitor. Smokeping will make nice graphs that can easily be used to convince an ISP that the connection has problems.
    – Zoredache
    Oct 1, 2013 at 20:34
  • Good point @Zoredache. I will look deeper into Monit to see how to handle this. Oct 2, 2013 at 21:00

3 Answers 3

1

This is typically done through interface monitoring using SNMP on the firewall/router itself. In addition, you could use netflow/sflow/jflow on the interfaces to gather deeper stats/info.

Larger ISPs will also offer portals with monitoring tools (Sprint/Cox/TW and others come to mind).

In addition, you can setup tools like Nagios, etc. that can ping outbound as well as an additional layer/check

You can also use 3rd party tools such as http://newrelic.com/monitor-everything or similar to monitor from the outside in, verifying your server is reachable. Or something as simple as a free online ping monitor (just search) that will ping your firewall's WAN IP and if it is unreachable alert you.

Monitoring it only from your server's perspective is myopic and may not accurately reflect a true outage of the ISP itself.

1
  • Great idea for pinging the firewall from an external source as opposed to pinging hosts from within the local network! Oct 2, 2013 at 20:59
2

Generically, the first thing you need to do it define exactly what you call an internet outage. Does an "outage" mean you can't reach:

  • the CPE router on your local network?
  • the ISP router on the other end of your PPP link?
  • A host somewhere in the middle of your ISP network such as a DNS or Mail server (but the ISP could have lost all upstream connectivity)?
  • A 'general' host out on the internet? What if that host is down but the rest of the internet is "up"?
  • Various hosts out on the internet? What exactly is a "fail" condition then? How many need to be unreachable before you consider the internet to be "down"?

For your specific instance (trying to pin down the stability of your internet connection), monitoring logs and/or SNMP from your router should give you the information you need, although "real-world" tests of traffic passing is probably useful to. If it's the link between you and the ISP, then pinging some of your ISP hosts (DNS/Mail etc) would be good, or better script and actual DNS lookup against their DNS server, and try to establish an SMTP connection to their mail server. Of course, don't do this too often or they might accuse you breaching Acceptable Use Policy, Terms of Service etc.

1
  • By "outage" I mean that our connection to the Internet (for the whole network) is lost due to our ISP. Oct 2, 2013 at 20:56
1

I use a great tool for monitoring connections like this.

MTR or My Trace route.

It's very much an evolution from singular ping operations and trace routes, almost a hybrid of the two.

MTR has a few modes of operation

mtr --report google.com

will generate a report for you to send to the ISP for analysis.

OR you can try

mtr google.com and press d twice to see the latency or loss between all hops over a period of time.

Depending on the flavour of Linux you are referring to, most distributions have MTR in their native repos.

1
  • 1
    Cool tool thanks! But I'm looking for something that is a bit more of a long term report, rather than a single snapshot of a moment in time. Like for example, I want to send the ISP a report showing what percentage of the current month our Internet connection was down. Oct 2, 2013 at 20:58

Not the answer you're looking for? Browse other questions tagged .