How to check amount of connections on remote port

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
intern_nagios
Posts: 11
Joined: Wed May 27, 2015 3:39 pm

How to check amount of connections on remote port

Post by intern_nagios »

Hi there,

Do you know if there is an way to check the amount of connections on a remote host/port? Let's say I want to know how many connections on port 1723 (VPN) on "server x" are active?
I tried a couple of "check connections" plugins on the Nagios Exchange but I can't make them check an remote host.

Thanks.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: How to check amount of connections on remote port

Post by eloyd »

You need to use an agent on the remote host to run the check and return results back to Nagios, or else use passive checks. Google for NRPE, or wrap checks in the check_by_ssh wrapper, or Google for Nagios passive checks.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: How to check amount of connections on remote port

Post by jolson »

To supplement eloyds post,

Download NRPE: https://exchange.nagios.org/directory/A ... or/details

Official NRPE documentation: http://nagios.sourceforge.net/docs/nrpe/NRPE.pdf

Passive Checks: http://nagios.sourceforge.net/docs/3_0/ ... hecks.html

Let us know if you have any questions!
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
User avatar
eloyd
Cool Title Here
Posts: 2129
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: How to check amount of connections on remote port

Post by eloyd »

Sorry for my terseness. Was writing from smartphone. :)
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoydI'm a Nagios Fanatic!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: How to check amount of connections on remote port

Post by abrist »

@eloyd: terse, but correct nonetheless :)
@OP: eloyd is correct, you need to run the connections check from the remote host in order to collect the desired info.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
intern_nagios
Posts: 11
Joined: Wed May 27, 2015 3:39 pm

Re: How to check amount of connections on remote port

Post by intern_nagios »

Thanks guys.

I use the plugin "check_connections.sh" to count the amount of connections on a to be determined port. The command to run the plugin is specified as following:

Code: Select all

define command{
        command_name    check_vpn_connections
        command_line    $USER1$/check_connections.sh -s all '( dport = :1723 )' -w 200 -c 300
        }
In NRPE.cfg, I specified the following:

Code: Select all

command[check_vpn_connections]=/usr/lib64/nagios/plugins/check_connections.sh -s all '( dport = :1723 )' -w $ARG1$ -c $ARG2$
Something strange, is that the first 3 lines are yellow and red, but my line for the conncetions stays red.
command[check_dell_alertlog]=/usr/lib64/nagios/plugins/check_openmanage –only alertlog
command[check_dell_critical]=/usr/lib64/nagios/plugins/check_openmanage –only critical
command[check_dell_warning]=/usr/lib64/nagios/plugins/check_openmanage –only warning
command[check_vpn_connections]=/usr/lib64/nagios/plugins/check_connections.sh -s all '( dport = :1723 )' -w $ARG1$ -c $ARG2$

Afterwards, I restarted the NRPE service

The output is as following:

Code: Select all

[root@xxx plugins]# ./check_nrpe -H xxxx -c check_vpn_connections -a 20 30
NRPE: Command 'check_vpn_connections' not defined
I guess the color indicates I'm doing something wrong, as the output says the same. Does anyone have a clue?

Thanks
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to check amount of connections on remote port

Post by tmcdonald »

The color itself is just syntax highlighting, but you're right in that it does look weird. NRPE is probably seeing that "dport =" part and hanging on that.

Can you try to modify the check_connections.sh script to hard-code in the -s all '( dport = :1723 )' part? That might be the easiest way short of patching NRPE (which would take a while).
Former Nagios employee
intern_nagios
Posts: 11
Joined: Wed May 27, 2015 3:39 pm

Re: How to check amount of connections on remote port

Post by intern_nagios »

I'm using an other plug-in now, that's not great but it should do the work. Thanks for cooperating.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to check amount of connections on remote port

Post by tmcdonald »

I'll be closing this thread now, but feel free to open another if you need anything in the future!
Former Nagios employee
Locked