hi all
I need a hint, help or whatever:
i have to check the number of open socket on 502* (5020,5021,5022, ecc every 502X ports) with a number of connections by 500 (warning alert) at 1000 (critical alert) connections.
i'm tring to use this command:
netstat -nao | grep ":502" | wc –l
by defining a new command in nagios cfg, but seems somethig gone wrong
Can someone give me a hint ?
how to check open sockets on port 502*
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: how to check open sockets on port 502*
Hello, @Zagon007. Does running this command from the command line give you the desired output?
https://nagios-plugins.org/doc/guidelines.html
Also, running the netstat command as the nagios user may or may not give you the desired output. So you'll need to give the sudoers priveledges to the plugin(by adding the path to the sudoers file).
If so you need to put the command in a shell script, put the script in the /usr/local/nagios/etc/libexec folder, create a new check command and assign it to a service check.netstat -nao | grep ":502" | wc –l
https://assets.nagios.com/downloads/nag ... ios-XI.pdf$USER1$/your_check
https://nagios-plugins.org/doc/guidelines.html
Also, running the netstat command as the nagios user may or may not give you the desired output. So you'll need to give the sudoers priveledges to the plugin(by adding the path to the sudoers file).
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Re: how to check open sockets on port 502*
npolovenko wrote:Hello, @Zagon007. Does running this command from the command line give you the desired output?netstat -nao | grep ":502" | wc –l
yes it does.
It counts the open sockets:
[nagios@server libexec]$ ./open_socket_test.sh
669
previously i've add the script file in the nrpe configuration:
command[open_socket]=/usr/lib/nagios/plugins/open_socket.sh -w 1000 -c 2000
Amd added the command to the nagios checks:
define service {
use generic-service
host_name i-XXXXXXXXXXX
service_description Custom memory checker In Bash
check_command open_socket
}
and restarted the service nagios on the server.
I've also added the path to the sudoes users
if i launch the script on the client it works, if i try one launch, remotely, it fails with a time out connection response.
-
npolovenko
- Support Tech
- Posts: 3457
- Joined: Mon May 15, 2017 5:00 pm
Re: how to check open sockets on port 502*
@Zagon007, So you added this nrpe command to the nrpe.cfg file on the remote server, right? Not on the Nagios XI server.
This command utilizes the service on the local machine:command[open_socket]=/usr/lib/nagios/plugins/open_socket.sh -w 1000 -c 2000
To use the nrpe agent the command should look like this:define service {
use generic-service
host_name i-XXXXXXXXXXX
service_description Custom memory checker In Bash
check_command open_socket
}
Also, before you start working on the definitions I suggest running the nrpe command from the command line on the Nagios server:define service {
use generic-service
host_name i-XXXXXXXXXXX
service_description Custom memory checker In Bash
check_command check_nrpe!open_socket! -a ' -w 1000 -c 2000'
}
*Please show me the output./usr/local/nagios/libexec/check_nrpe -H remote_server_ip -c open_socket -a ' -w 1000 -c 2000'
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.