Simon icon Simon
Flexible server monitoring

Using TCP Port Scanner/Port Available

I want to scan ports 6180, 6181, 6182, 6183, 6185, and 6188 of a remote server and be notified if one of those ports is closed or non-responsive. I can't specify a range like "6180-6183,6185,6188" and "start:6180,end:6188" doesn't fail when there's no response from 6184 or 6187.

What's the best way to do this? Should I have a Port Available test for each of the ports?

David Sinclair's picture

Re: Using TCP Port Scanner/Port Available

Yes, you probably should set up separate tests for each. Simon is based around the idea of one test per server/port/thing.

However, the Port Available service is actually a script, so you could duplicate that and customize it to scan multiple ports, if the nc command supports that.

Re: Using TCP Port Scanner/Port Available

Ahh! Here's what I've got for the new service:

nc -zw 3 {IP} 6180-6183
nc -zw 3 {IP} 6185
nc -zw 3 {IP} 6188

That should return:

Connection to 127.0.0.1 6180 port [tcp/*] succeeded!
Connection to 127.0.0.1 6181 port [tcp/*] succeeded!
Connection to 127.0.0.1 6182 port [tcp/*] succeeded!
Connection to 127.0.0.1 6183 port [tcp/*] succeeded!
Connection to 127.0.0.1 6185 port [tcp/*] succeeded!
Connection to 127.0.0.1 6188 port [tcp/*] succeeded!

I then add six filters, one for each port:

Any | Find Required | Input: Response Text | Text matching (contains): 6180
...

If any of those ports are missing from the return text, I get notified on failure. I imagine there's some way to create a filter that looks for all the ports in one shot, but this will work for now.

Re: Using TCP Port Scanner/Port Available

No, sorry, not quite working yet. If any single port isn't open or even if all but one port isn't open, I get a failure. But if all ports are not open, the activity shows:

8/23/13 10:26 PM Localhost | Daylite  Service Script Daylite Ports  Port isn't open

and even though this looks like a failure (a downward-pointing red arrow next to "Port isn't open") the activity doesn't show under the Failures tab and there is no notification of the failure. How can I force a failure if the Service/Script gives me this result?

BTW: Folders. Just sayin'.

David Sinclair's picture

Re: Using TCP Port Scanner/Port Available

Not sure I understand what's going on there. If a service has a failure, the test will be a failure, unless a filter overrides that. So check your filters.

Folders/groups is something I'd like to add in the future.

Re: Using TCP Port Scanner/Port Available

Maybe these images will help. Here's what I get when the test succeeds (because all the ports are available):

http://cl.ly/image/2K2L0R1s0j1x

This is the activity for a test when any single port is unavailable:

http://cl.ly/image/3W0p2N3h431Z

And this is the activity for a test where all ports are unavailable:

http://cl.ly/image/0c3e2I3g0a41

Two differences that I see between these is that initial Service/Script result is "Port isn't open" for the problem test (Filter/Find all return that same result) and Test Stop is part of the problem test. Filters don't seem to be the issue.

Re: Using TCP Port Scanner/Port Available

I think my reply to your last comment is being held up in moderation or got deleted automatically by Mollom. Do I need to repost?

David Sinclair's picture

Re: Using TCP Port Scanner/Port Available

Yes, the comment was being moderated, due to the links; now approved.

The service itself is failing, since the last nc command is failing (and thus that is used as the exit value). So the filters are correct to also be failing.

The puzzling thing is the "Test stop" — I think that should only occur if you manually stop the check, which I assume you aren't doing?

Try changing all your filters in the test from "Any" to "Success". That will only use them when the test is successful; there's no point in using them when there's already a failure. I don't know if that'd make a difference, but is worth trying.

Re: Using TCP Port Scanner/Port Available

Right, I hadn't manually stopped the check. Just to be sure, I looked at my logs from overnight and saw where one of my customers must have changed some settings and the result went from Test Stop (port isn't open) to Test Failure (connection succeeded, but find required failed), to Test Success (required ports were open).

Oddly, though, changing the filters from Any to Success *does* give me Test Failure instead of Test Stop. Woo-hoo! This is going to be extremely handy for monitoring my clients' networks from afar.

David Sinclair's picture

Re: Using TCP Port Scanner/Port Available

Excellent; I'm glad that solved it.

Re: Using TCP Port Scanner/Port Available

The Test Stop is intermittent. Here's how the last hour's results look for a test that's failing:

9/10/13 8:23 PM Power Training | Billings Pro  Test viewed Script...Port isn't open
9/10/13 8:22 PM Power Training | Billings Pro  Notifier Growl Prowl Notifier 
9/10/13 8:22 PM Power Training | Billings Pro  Notifier Sound Annoying buzzer 
9/10/13 8:22 PM Power Training | Billings Pro  Test failure Script...Port isn't open
9/10/13 8:22 PM Power Training | Billings Pro  Service Script...Port isn't open
9/10/13 8:22 PM Power Training | Billings Pro  Test start Script Billings Pro Ports 
9/10/13 8:17 PM Power Training | Billings Pro  Notifier Growl Prowl Notifier 
9/10/13 8:17 PM Power Training | Billings Pro  Notifier Sound Annoying buzzer 
9/10/13 8:17 PM Power Training | Billings Pro  Test failure Script...Port isn't open
9/10/13 8:17 PM Power Training | Billings Pro  Service Script Billings Pro Ports  Port isn't open
9/10/13 8:17 PM Power Training | Billings Pro  Test start Script Billings Pro Ports 
9/10/13 8:12 PM Power Training | Billings Pro  Test stop Script Billings Pro Ports 
9/10/13 8:12 PM Power Training | Billings Pro  Service Script Billings Pro Ports  Port isn't open
9/10/13 8:08 PM Power Training | Billings Pro  Test start Script Billings Pro Ports 
9/10/13 8:03 PM Power Training | Billings Pro  Notifier Growl Prowl Notifier 
9/10/13 8:03 PM Power Training | Billings Pro  Notifier Sound Annoying buzzer 
9/10/13 8:03 PM Power Training | Billings Pro  Test failure Script...Port isn't open
9/10/13 8:03 PM Power Training | Billings Pro  Service Script...Port isn't open
9/10/13 8:03 PM Power Training | Billings Pro  Test start Script Billings Pro Ports 
9/10/13 7:58 PM Power Training | Billings Pro  Test stop Script Billings Pro Ports 
9/10/13 7:58 PM Power Training | Billings Pro  Service Script...Port isn't open
9/10/13 7:54 PM Power Training | Billings Pro  Test start Script Billings Pro Ports 
9/10/13 7:54 PM Power Training | Billings Pro  Test stop Script Billings Pro Ports 
9/10/13 7:54 PM Power Training | Billings Pro  Service Script...Port isn't open
9/10/13 7:49 PM Power Training | Billings Pro  Test start Script Billings Pro Ports 
9/10/13 7:49 PM Power Training | Billings Pro  Test stop Script Billings Pro Ports 
9/10/13 7:49 PM Power Training | Billings Pro  Service Script...Port isn't open
9/10/13 7:44 PM Power Training | Billings Pro  Test start Script Billings Pro Ports 
9/10/13 7:39 PM Power Training | Billings Pro  Notifier Growl Prowl Notifier 
9/10/13 7:39 PM Power Training | Billings Pro  Notifier Sound Annoying buzzer 
9/10/13 7:39 PM Power Training | Billings Pro  Test failure Script...Port isn't open
9/10/13 7:39 PM Power Training | Billings Pro  Service Script...Port isn't open
9/10/13 7:38 PM Power Training | Billings Pro  Test start Script Billings Pro Ports 
9/10/13 7:33 PM Power Training | Billings Pro  Notifier Growl Prowl Notifier 
9/10/13 7:33 PM Power Training | Billings Pro  Notifier Sound Annoying buzzer 
9/10/13 7:33 PM Power Training | Billings Pro  Test unviewed Script Billings Pro Ports 
9/10/13 7:33 PM Power Training | Billings Pro  Test failure Script...Port isn't open
9/10/13 7:33 PM Power Training | Billings Pro  Service Script...Port isn't open
9/10/13 7:31 PM Power Training | Billings Pro  Test start Script Billings Pro Ports 

BTW, a post just before this one is in moderation.