Check UDP ports?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
riahc3
Posts: 58
Joined: Thu Apr 05, 2018 9:36 am

Check UDP ports?

Post by riahc3 »

What is the easiest way to check UDP ports if they are open?

The plug in Nagios expects me to send and way for a expected string. Dont quite understand stand.

Id also avoid using external tools like nmap and such and would perfer to use what is built in the OS (CentO)
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check UDP ports?

Post by mcapra »

check_udp is the easiest plugin for this. What you should send/receive depends on the process bound to the port. You could experiment with this plugin using the -v or --verbose flags to see what is returned when providing various send/expect strings. Or ask the vendor/developer for valid request/response pairs.

Send it total junk with whatever for the expect value and see what gets returned. Use that to inform your expect string.

More info:
https://support.nagios.com/forum/viewto ... 00#p251500
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Check UDP ports?

Post by scottwilkerson »

check_udp comes with the standard nagios-plugins package most people install as part of their nagios setup.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
riahc3
Posts: 58
Joined: Thu Apr 05, 2018 9:36 am

Re: Check UDP ports?

Post by riahc3 »

mcapra wrote:check_udp is the easiest plugin for this. What you should send/receive depends on the process bound to the port. You could experiment with this plugin using the -v or --verbose flags to see what is returned when providing various send/expect strings. Or ask the vendor/developer for valid request/response pairs.

Send it total junk with whatever for the expect value and see what gets returned. Use that to inform your expect string.

More info:
https://support.nagios.com/forum/viewto ... 00#p251500
Is there some kind of list Nagios provides? It is impossible to know what every single vendor and application expects to be sent and as a reply...

I personally find it stupid; There must be some implementation (NRPE or SNMP) that can correctly detect if a UDP port is open....
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: Check UDP ports?

Post by mcapra »

Validating a request/response pair is the only way you could feasibly know whether or not a UDP port is actually capable of receiving traffic. This is a limitation of UDP as it is a connectionless protocol. Simply checking if routing rules allow for access of a port is no guarantee that traffic can actually reach the port and transmit data, only that the route itself is unrestricted. Even if the port is in a "listening" state as far as the host OS is concerned, this is still not a guarantee that traffic can be transmitted. Given all that, it's not entirely surprising to me that I've been unable to find community plugins supporting this particular use case.

You're quite right that it is practically impossible to know what every single vendor/application will return for any given protocol. That's why I suggested a bit of simple investigation.

If you're looking for something that can detect, on a host system, if a given port is in a "listening" state, I'd recommend combining this plugin with an agent like NRPE or NCPA:
https://github.com/karatalapu80/Nagios- ... enPorts.py

Which leverages netstat. You may need to install a system package (most commonly net-tools) if the host system does not have the netstat binary available. Though if you're just curious on whether or not the port's parent process is running, there's always check_procs which would accomplish roughly the same thing in most cases.

Here is another non-Python option that could be run on the host system via NRPE which leverages netstat, sed, and grep:
https://exchange.nagios.org/directory/P ... sh/details
Former Nagios employee
https://www.mcapra.com/
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Check UDP ports?

Post by scottwilkerson »

Also, there is no way to know in advance what to expect as a response because what the response is depends on the application that is listening on the UDP port.

This can be any application and as such Nagios, or anything else cannot know in advance what an appropriate response is.
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked