Could not execute /usr/bin/snmpnetstat

Hi everyone,

I don't know if I am on the right spot but here is my issue:

I am trying to launch a Perl script check_netstat.pl, I have installed all the dependencies but it still gives me an error code:
Code:
UNKNOWN ERROR - could not execute /usr/bin/snmpnetstat

./check_netstat.pl -N 5.4 -H 192.168.32.218 -C public -2 -P 161 -N 2c -t 20 -r TCP -p 3470 -w 3 -c 12

The script can be retrieved here :
http://exchange.nagios.org/director.../check_netstat--2F-check_snmp_netstat/details

Thank you in advance.
 
All right I found it, I had to change the path to snmpnetstat to /usr/local/bin/snmpnetstat and the path to Nagios libraries, but now I have another problem:

Code:
UNKNOWN ERROR - did not receive any results from /usr/local/bin/snmpnetstat 192.168.32.218 -t 20 -n -P tcp -v 2c -p 161

Could someone please help, thanks in advance.
 
Looks like the script is expecting something like Linux where all binaries, base or third party, are thrown into one big mess in /usr/bin. On FreeBSD the SNMP commands will be in /usr/local/bin. Seems you've already sorted this during my post.

I would try running that snmpnetstat command directly to see whether it works. Interestingly, on my FreeBSD system snmpnetstat does not like having the host specified before the options as in your output above. It's possible Linux is more forgiving with this (it may also be shell dependent). If you just get a usage error like I did, you may have to actually modify the part of check_netstat.pl that builds the above command line, making it put the IP address on the end.
 
I haven't tested this in the slightest and it isn't ideal but if you are getting a usage error, you could try the following change to the Perl script:

Around line ~590
Code:
-    $shell_command = $snmpnetstat . " $o_host -t $o_timeout";
+    $shell_command = $snmpnetstat . " -t $o_timeout";

line ~595
Code:
-    $shell_command_auth= "-c $o_community ";
+    $shell_command_auth= "-c $o_community $o_host";
 
Thanks for you answer, by changing the code and arguments like this:
Code:
./check_netstat.pl -H 192.168.1.250 -Cpublic -p138 -w3 -c12

I obtain this:
Code:
ERROR: Alarm signal (Nagios time-out)

Can someone please help?
 
Does it work under Nagios (retrieve data from a remote Windows host)? Because I want to test this checks against a remote Windows host and display the data onto Nagios.
 
It's SNMP either way. So if the Windows host responds to SNMP the Perl module will work too.
 
Is this an existing script? I thought you were writing something yourself.
 
No, it is an existing script I took from Nagios Exchange, I am not experienced with Perl at all.
 
Did you fix the issue?

You can try:
Code:
Change timeout on menu "Configuration -> Nagios -> nagios.cfg -> <you nagios>", tab "Logs Options" for:
- Service Check Timeout (120s)
- Host Check Timeout (120s)

And please check the script's file for included notes. It is meant to work with Linux out of the box, so you might need to do some changes in order for it to work on FreeBSD.
# =============================== SETUP NOTES ================================
#
# 1. Make sure to check and if necessary adjust the the path to utils.pm
# 2. Make sure you have snmpnetstat in /usr/bin or adjust the path below
# 3. Syntax of snmpnetstat is different depending on which NET-SNMP package
# you have installed. Please specify your version of NET-SNMP package
# as '-N 5.0" or '-N 5.4' if you're unsure use '-v' and see what was
# autodetermined.
# 4. Beware that all service port names are ALWAYS retrieved from system
# running plugin and in case of SNMP check this might not be the same
# as what is set on remote system.
#
# TCP Port names are specified with '-p' or '-a' option for checking number
# of connections based on specified warning and critical values and with '-A'
# for those ports which you want in perfomance output. Each TCP port name
# (or number) should be prefixed with either '>' or '<' to specify if you
# want to check incoming connections to the specified port ('<') or outgoing
# connections ('>') to the specified port on remote system. For example
# using '--ports >smtp' means you want to check on number of outgoing SMTP
# (port 25) connections.
#
# The values retrieved are compared to specified warning and critical levels.
# Warning and critical levels are specified with '-w' and '-c' and each one
# must have exact same number of values (separated by ',') as number of
# attribute (tcp port names) specified with '-p'. Any values you dont want
# to compare you specify as ~. There are also number of other one-letter
# modifiers that can be used before actual data value to direct how data is
# to be checked. These are as follows:
# > : issue alert if data is above this value (default)
# < : issue alert if data is below this value
# = : issue alert if data is equal to this value
# ! : issue alert if data is NOT equal to this value
# A special modifier '^' can also be used to disable checking that warn values
# are less than (or greater than) critical values (it is rarely needed).
#
# Additionally if you want performance output then use '-f' option to get all
# the ports specified with '-p' or specify particular list of of ports for
# performance data with '-A' (this list can include names not found in '-p').
# Note that when reporting for in perfomance data instead of saying ">smtp'
# or "<smtp" the plugin will report it as 'smtp_out=' or 'smtp_in='.
#
# ============================= SETUP EXAMPLES ===============================
#
# The first example is for your server to check SMTP connections - warnings
# would be sent here fore more then 15 incoming connections or more then 10
# outgoing and critical alerts for more than 40 incoming or 20 outgoing
# ----
# define command {
# command_name check_smtp_connections
# command_line $USER1$/check_netstat.pl -L "SMTP Load" -H $HOSTADDRESS$ -C $ARG1$ -N 5.3 -2 -p "<smtp,>smtp" -w $ARG2$ -c $ARG3$ -f -A "@"
# }
#
# define service{
# use std-service
# service_description SMTP Load
# hostgroups mailserv
# check_command check_smtp_connections!public!">15,>10"!">40,>20"
# }
#
# ----
# The second example is for a webserver to check HTTP connections. In
# this case the server is always little loaded (i.e. you have busy website)
# so not only is their upper bound of 30 for warning and 100 for critical
# but also a bound to send alert if there are < 5 connections (and to
# specify this http name is repeated twice at '-p'; the result is a
# little strange though as it will report "http in connections" twice -
# its on my "todo list" to get this taken care of and only report same
# port/direction information once).
#
# define command {
# command_name check_http_connections
# command_line $USER1$/check_netstat.pl -L "HTTP Load" -H $HOSTADDRESS$ -C $ARG1$ -2 -p "http,http" -w $ARG2$ -c $ARG3$ -A "http,@"
# }
#
# define service{
# use std-service
# service_description HTTP Load
# hostgroups webserv
# check_command check_http_connections!public!"<5,>30"!"~,100"
# }
#
# Note: those who want to minimize load on nagios server and number of extra
# lookups should really combine above into one command if your server
# is doing both HTTP and SMTP (but of course then it might not look
# as nice in the services list)
 
Back
Top