1
vote

I am debugging a problem with one of our systems. Every Sunday, it stops communicating with another server. If we reboot both servers, communication works again.

I was wondering if there are any small footprint apps that monitor TCP port availability and network connectivity, possibly logging any downtime. I'd also like it to be open source if possible, but if there is another solution that is proprietary, I'd like to hear about it also.

0

7 Answers 7

6
votes

I'll buck the trend and give you a scripted solution.

Grab a copy of netcat for Windows and modify the script with the path of netcat (or just dump nc.exe in the %SystemRoot%\system32 directory and change that line to just nc.exe). Also, modify the script to store its log file wherever you want.

@echo off

SET NETCAT=c:\path-to-netcat\nc.exe
SET MONITOR_HOST=server-to-monitor
SET MONITOR_PORT=port-number-to-monitor
SET LOGFILE=C:\whatever.log

rem Use netcat to check for host answering on TCP port xxx
%NETCAT% -z %MONITOR_HOST% %MONITOR_PORT%
if errorlevel 1 goto _host_down

echo %DATE% %TIME% %MONITOR_HOST% answered on TCP port %MONITOR_PORT%>>%LOGFILE%
goto end

:_host_down
echo %DATE% %TIME% %MONITOR_HOST% did not answer on TCP port %MONITOR_PORT%>>%LOGFILE%

rem Do something to remote host here...
rem shutdown -r -t 1 -f -m %MONTIOR_HOST%

:end

There ya' go. You could run that as a "scheduled task".

This isn't fancy at all, but it would work. If you wanted to make it fancier, you could use the date or time to change the log file name such that you get a new log every day, week, etc. You could delete old logs, etc. There's a lot you could do with a simple script like this... heh heh...

Addendum:

Here's the fancier "command line arguments" version. It logs into whatever directory you specify, in the filename "MONTIOR_HOST_YYYY-MM-DD.log". Call with the syntax:

(filename) monitor_host monitor_port log-file-path
monitor.cmd test-srv01 80 "c:\monitor_logs\long filenames do work here\"

This would be suitable for calling from multiple scheduled tasks, scripts, etc, to monitor multiple servers or multiple ports.

@echo off
SET NETCAT=c:\path-to-netcat\nc.exe
SET MONITOR_HOST=%1
SET MONITOR_PORT=%2
SET LOGFILE="%~f3\%1_%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%.LOG"

if "%1"=="" goto _syntax
if "%2"=="" goto _syntax
if "%3"=="" goto _syntax

rem Use netcat to check for host answering on TCP port xxx
%NETCAT% -z %MONITOR_HOST% %MONITOR_PORT%
if errorlevel 1 goto _host_down

echo %DATE% %TIME% %MONITOR_HOST% answered on TCP port %MONITOR_PORT%>>%LOGFILE%
goto end

:_host_down
echo %DATE% %TIME% %MONITOR_HOST% did not answer on TCP port %MONITOR_PORT%>>%LOGFILE%

rem Do something to remote host here...
rem shutdown -r -t 1 -f -m %MONTIOR_HOST%
goto end

:_syntax
echo Syntax:
echo.
echo %0 monitor_host monitor_port log-file-path

:end

I have too much fun writing scripts...

4
  • Very nice... but what are you talking about, I consider this solution: "Fancy".
    – l0c0b0x
    Jul 10, 2009 at 15:39
  • I thought about using netcat. I was just curios if there was anything similar, maybe with an easy to configure gui. I'll be putting this in place, but others will be monitoring.
    – scottm
    Jul 10, 2009 at 15:53
  • @l0c0b0x: Heh heh. Installing a "monitoring package" (be it in a VM, installed on the bare metal, etc) seems overkill to me for simply watching for a TCP port being "live" on a remote box. (Admittedly, one should have a fairly comprehensive monitoring infrastructure in place anyway.) For getting out of a pinch, slapping together a crappy script is hard to beat, though... >smile< Jul 10, 2009 at 15:57
  • @scotty2012: The "easy to configure GUI" for this one is Notepad! Heh heh... Jul 10, 2009 at 15:57
2
votes

I can recommend Zenoss. It is quite comprehensive, but easy to set up, free software and can do everything you need.

Of course, you could also just whip up a few Perl/Shell scripts, but why reinvent the wheel?

1
  • I would recommend Zenoss as well. It also has a virtual machine option which is preconfigured and very easy to get up and running without touching existing systems or adding new hardware Jul 10, 2009 at 15:25
1
vote

My current favorite is Zabbix. There is also Nagios and maybe a few others. But if it's just one service I would probably write a perl script to monitor it and log to sqlite.

2
  • +1 zabbix is quite easy to setup; but if you don't disable unneeded or irrelevant statistics it will quickly take all available DB performance
    – Javier
    Jul 10, 2009 at 15:30
  • I've used zabbix, but I'd prefer a self contained app that can monitor a few different tcp connections, and tell me when they drop.
    – scottm
    Jul 10, 2009 at 15:46
1
vote

There is always Nagios.

0
votes

I've had good luck with What's Up Gold in the past. It's easy to configure and does keep historical information. Unfortunately, it is not open source. I would love to see an open source product with the same features.

0
votes

You have several options, with differents between them:

  • OpenNMS: more focus on snmp.
  • Cacti: nice graphs, but fails on scaling.
  • Pandora FMS: nice graphs and reporting, most based on software agents.

There are others like Ganglia and Ximon, but are even older than nagios.

0
votes

I would go to zabbix too (I'm using it and it works very great in a distributed environment) and also splunk which is a wonderful tool.

1
  • I would not classify splunk as a network monitoring application... It's a filter/search utility for system logging not network monitoring... Jul 10, 2009 at 15:39

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