Check_connections

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
ednaldojta
Posts: 103
Joined: Tue Apr 07, 2015 7:52 am

Check_connections

Post by ednaldojta »

Friends,
They've helped me a lot in the Post concerning check_by_ssh, however now I need a way to monitor the number of connections per port on servers.

And I need it with some plugin because the SSH is a bit complicated for commercial reasons. The servers to be monitored are from another company, and so I can not create an account to access via SSH, for security reasons.

For this need, through a plugin to bring number of connections per port.

I saw check_connections.sh the Nagios Exchange, but did not know how to set up the syntax in commands.cfg file Nagios.
What can help me thank you.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Check_connections

Post by rkennedy »

Your previous thread about the check_netstat_conn (https://support.nagios.com/forum/viewto ... 67#p177367) should work fine for this, if you don't want to use the SSH route, you can always take a look at executing the script through NRPE.
Former Nagios Employee
ednaldojta
Posts: 103
Joined: Tue Apr 07, 2015 7:52 am

Re: Check_connections

Post by ednaldojta »

configuring check_netstat_conn
because you need a syntax in commmands.cfg file.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Check_connections

Post by rkennedy »

Can you please clarify what you're saying?
Former Nagios Employee
ednaldojta
Posts: 103
Joined: Tue Apr 07, 2015 7:52 am

Re: Check_connections

Post by ednaldojta »

So I can install a plugin, I must first configure commands.cfg, correct file?

Yeah, I installed the plugin, however when I run the plugin appears that critique.
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Check_connections

Post by lmiltchev »

I haven't used this plugin, but it seems to me that it could be only used locally, for example:

Code: Select all

/usr/local/nagios/libexec/check_netstat_conn -p <port>
I don't believe you will be able to check a remote server, unless you run it locally (on the remote server), and call it from XI via check_nrpe.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ednaldojta
Posts: 103
Joined: Tue Apr 07, 2015 7:52 am

Re: Check_connections

Post by ednaldojta »

there was a critical implementation.
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Check_connections

Post by rkennedy »

Can you post the full script you're running?
Former Nagios Employee
ednaldojta
Posts: 103
Joined: Tue Apr 07, 2015 7:52 am

Re: Check_connections

Post by ednaldojta »

is the Nagios Plugin itself that is on the Nagios Exchange page.

Code: Select all

#!/bin/sh
# 
# check_netstat_conn - Check listening ports using netstat utility
#
# Author:	Aaron Eidt ([email protected])
#

STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4

PROGRAM="check_netstat_conn"

usage () {
	printf "\n%s - Check port using netstat utility\n" $0
	printf "$Id: $PROGRAM 1 2013-07-08 $"
	printf "\nUsage: %s: -p\n\n" $0
}


port=

while getopts p: o
do
	case $o in
		p)
			port="$OPTARG"
			;;
		?)
			usage
			exit ${STATE_UNKNOWN}
			;;
	esac
done

if [ x$port = x ]; then
	usage
	exit ${STATE_UNKNOWN}
fi

$ENV{PATH}=$ENV{PATH}:/usr/local/nagios/libexec/
NETSTAT=`which netstat`

if [ ! -e $NETSTAT ]; then
	echo "CANNOT FIND NETSTAT!"
	exit ${STATE_UNKNOWN}
fi

result=`$NETSTAT -an | grep :$port`
num_conn=`echo $result | wc -l`

if [ `echo $result | egrep -c 'LISTEN|ESTABLISHED'` -gt 1 ]; then
	echo "OK: There are $num_conn established or listening connections on port $port"
	exit ${STATE_OK}
fi

echo "CRITICAL: There are NO established or listening connections on port $port"
exit ${STATE_CRITICAL}
Last edited by tmcdonald on Thu Mar 31, 2016 1:29 pm, edited 1 time in total.
Reason: Please use [code][/code] tags around long output
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Check_connections

Post by tmcdonald »

Try changing line 43 from

$ENV{PATH}=$ENV{PATH}:/usr/local/nagios/libexec/

to

PATH=$PATH:/usr/local/nagios/libexec/

then re-run it.
Former Nagios employee
Locked