Saturday, March 14, 2015

Output Network Outages to a File with Netout

If you want to just to check that an individual computer has connectivity, pinging can be a decent way to do that. While you can just start up a ping, you may be looking for something that only outputs the time periods of outages. After a connectivity problem at work after an office move that seemed to only affect my computer, I went home and wrote a small script called netout to help me identify and quantify these outages.

Though it can take more options, it's simplest usage is this:

netout 

Which logs any problems pinging 8.8.8.8 (google-public-dns-a.google.com) to outages_8.8.8.8.txt, e.g.:

Outage started 2015-03-13 22:05:56 -0400 (No route to host) and ended 2015-03-13 22:06:06 -0400
Outage started 2015-03-13 22:06:12 -0400 (No route to host) and ended 2015-03-13 22:06:16 -0400
Outage started 2015-03-13 22:06:32 -0400 (No route to host) and ended 2015-03-13 22:06:36 -0400

If you want to tail that file, in another terminal window, or even on another computer if you log to a share, do:

tail -f outages_8.8.8.8.txt

The output is not 100% accurate because long ping times (over 500ms by default) would be considered an outage, where it really may be a latency issue. Also, the reason specified for the outage is only the first error that comes back from what is assumed to be a failed ping, and that reason could change over time. Netout assumes you care more about the outages and their duration over a longer time period and logging those to a file. That's all it does.

And if you need something more, here are some other free tools:

  • Ping - Just using "ping 8.8.8.8 >> ping.log" is a great way to collect data to provide to an ISP, etc. about outages.
  • Nagios - free monitoring tool that's been around a long time and is a good choice for your organization, but overkill for simple monitoring.
  • MRTG - I remember this being used many years ago and is a great free tool. It is also overkill for just logging ping outages. This is what you use if you want to tinker and create your own outage page.
  • Smokeping - seems like a good tool, but at the time of writing, there was no (OS X) Homebrew recipe for it, and I didn't have time to perform the installation.
  • mtr - also been around a long time. It is like a minified console version of the above types of graphing tools with a one character status for checks, so it is easy to see status of lot of hosts at once.

See also this question on superuser.

No comments: