Syntax Command Check_netstat_conn

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

Syntax Command Check_netstat_conn

Post by ednaldojta »

Good morning friends!
I'm working on Nagios XI now! I'm new to the platform. I wanted to know how to implement the command syntax "check_netstat_conn" file "commands.cfg" the NagiosXI.
I need to check the number of connections in a HAproxy webservice per port. It's possible?
If another plugin, accept ideas from colleagues!
Thanks for listening! :D :D
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Syntax Command Check_netstat_conn

Post by rkennedy »

Here's a quick script to accomplish your check. You'll need to execute it remotely using SSH or a remote agent client. You will need to modify this to your needs -

Code: Select all

#!/bin/bash
#this plugin will check netstat (netstat -an|grep :80|wc -l)  for a number and alert accordingly
#to the if statements below.
#OK is <80
#WARNING is 80-90
#CRITICAL is >90

#define file
count=$(/bin/netstat -an | grep :80 | wc -l)

#check $count value
if [ $count -lt 80 ]
then
        state="OK"
elif [ $count -ge 80 ] && [ $count -lt 90 ]
then
        state="WARNING"
elif [ $count -ge 90 ]
then
        state="CRITICAL"
else
        state="UNKNOWN"
fi
echo "$state: $count|count=$count"
Here's a sample -

Code: Select all

[root@suse11 libexec]# netstat -an|grep :80|wc -l
56
[root@suse11 libexec]# ./count.sh
OK: 56|count=56
Former Nagios Employee
ednaldojta
Posts: 103
Joined: Tue Apr 07, 2015 7:52 am

Re: Syntax Command Check_netstat_conn

Post by ednaldojta »

rkennedy!
Thanks for the answer. But I need to know how to implement iso. I need to insert some syntax in commands.cgf file? Or can Execultar this script with SSH Proxy Service NagiosXI own?

Please find attached the image of the service provided by Nagios XI.
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: Syntax Command Check_netstat_conn

Post by rkennedy »

You will need to create a nagios user on the HA proxy machine and setup SSH keys for it to use for authentication. See this document - https://assets.nagios.com/downloads/nag ... ng_SSH.pdf

Then, create a bash script of the contents I wrote for you above, and in the wizard have it execute that script.

To help demonstrate how this will work -
XI will SSH on to your HA Proxy machine and run check_netstat_conn.sh for example, and then the output will be sent back to Nagios XI for your service check.
Former Nagios Employee
ednaldojta
Posts: 103
Joined: Tue Apr 07, 2015 7:52 am

Re: Syntax Command Check_netstat_conn

Post by ednaldojta »

Rkennedy,
Good Morning,
realized step-by-step instructions that you gave me, I managed to connect to the remote server through the NagiosXI with nagios User. But when I check through command nagios, it's me the following message.

Also I had problem when the copy of the key with the command:

ssh-copy-id ~ / nagios nagios @ /name_of_keyfile.ssh.pub remoteip.

I made a copy via scp same. Is there any problem?
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: Syntax Command Check_netstat_conn

Post by rkennedy »

It looks like you still need to enter your password to SSH (which is what we want to eliminate). Can you check the permissions of the file that you copied over? It should be fine to copy it over using SCP.
Former Nagios Employee
ednaldojta
Posts: 103
Joined: Tue Apr 07, 2015 7:52 am

Re: Syntax Command Check_netstat_conn

Post by ednaldojta »

The file that you say is the key or the script that will run on the remote?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Syntax Command Check_netstat_conn

Post by rkennedy »

Both actually, they should be owned by nagios.
Former Nagios Employee
ednaldojta
Posts: 103
Joined: Tue Apr 07, 2015 7:52 am

Re: Syntax Command Check_netstat_conn

Post by ednaldojta »

I could not perform operations with root User?
For the tutorial he calls for the creation of a Nagios user, is that right would create a root user?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Syntax Command Check_netstat_conn

Post by rkennedy »

You need to create a nagios user, as that is who the check by ssh will authenticate as.
Former Nagios Employee
Locked