Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory Tree

Check Number Of Connections

Rating
1 vote
Favoured:
0
Hits
121658
Files:
FileDescription
check_connections.plcheck_connections.pl
Nagios CSP

Meet The New Nagios Core Services Platform

Built on over 25 years of monitoring experience, the Nagios Core Services Platform provides insightful monitoring dashboards, time-saving monitoring wizards, and unmatched ease of use. Use it for free indefinitely.

Monitoring Made Magically Better

  • Nagios Core on Overdrive
  • Powerful Monitoring Dashboards
  • Time-Saving Configuration Wizards
  • Open Source Powered Monitoring On Steroids
  • And So Much More!
Perl script that checks the number of established network connections using lsof
You can check the number of established network connections of a specific user or the number of network connections of a given command. Those two options can be combined.

Note: This script uses lsof with sudo.
Make sure your /etc/sudoers is properly configured.
For example put the following line into /etc/sudoers

nagios ALL=NOPASSWD: /usr/sbin/lsof

Please refer to the manpages for further options.


Examples of usage:
/usr/local/nagios/libexec/check_connections.pl -w 200 -c 250 -C httpd
Will check the number of network connections for any command containig httpd. If the number of established connections is equal to or exceeds 200 a warning is reported, if it's more or equal to 250 the an error.

/usr/local/nagios/libexec/check_connections.pl -w 200 -c 250 -u apache
Same as above except not commands containing httpd will be checked but any commands owned by user apache. You can also use uids instead of login names.

/usr/local/nagios/libexec/check_connections.pl -w 200 -c 250 -u apache -C httpd
This checks only commands containing httpd owned by user apache.


Released under the LGPL, visit http://www.gnu.org/licenses/lgpl.html for details.

Tested on:
- Redhat Linux 7.3 (x86)
- Fedora Core 4 (x86)
- Gentoo Linux 2006.1 (x86)
- Solaris 10 (sparc)
Reviews (1)
bysardar, January 15, 2015
It works perfectly fine but facing problem by using check_connection.pl script with NRPE. It returns zero connection count.
./check_nrpe -H host-name -c command-name
gives...
OK - Established connections: 0

help would be appreciated, THANKS