1

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.

scottm
  • 349
  • 3
  • 5
  • 18

7 Answers7

6

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...

Evan Anderson
  • 141,071
  • 19
  • 191
  • 328
  • Very nice... but what are you talking about, I consider this solution: "Fancy". – l0c0b0x Jul 10 '09 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 '09 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 – Evan Anderson Jul 10 '09 at 15:57
  • @scotty2012: The "easy to configure GUI" for this one is Notepad! Heh heh... – Evan Anderson Jul 10 '09 at 15:57
2

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?

sleske
  • 9,851
  • 4
  • 33
  • 44
  • 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 – Kevin Kuphal Jul 10 '09 at 15:25
1

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.

moshen
  • 1,534
  • 1
  • 9
  • 13
  • +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 '09 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 '09 at 15:46
1

There is always Nagios.

voyager
  • 698
  • 1
  • 6
  • 13
0

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.

Anthony Lewis
  • 909
  • 7
  • 8
0

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.

BenMorel
  • 4,215
  • 10
  • 53
  • 81
Maxwell
  • 5,026
  • 1
  • 25
  • 31
  • I would not classify splunk as a network monitoring application... It's a filter/search utility for system logging not network monitoring... – Jeremy Bouse Jul 10 '09 at 15:39
0

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.

user200776
  • 21
  • 1