# Could not execute /usr/bin/snmpnetstat



## abdelilah (Dec 2, 2013)

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:

```
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.


----------



## abdelilah (Dec 2, 2013)

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:


```
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.


----------



## usdmatt (Dec 2, 2013)

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.


----------



## abdelilah (Dec 2, 2013)

Thanks @usdmatt, but can you give an example? I'm a little bit lost in here.


----------



## usdmatt (Dec 2, 2013)

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

```
-    $shell_command = $snmpnetstat . " $o_host -t $o_timeout";
+    $shell_command = $snmpnetstat . " -t $o_timeout";
```

line ~595

```
-    $shell_command_auth= "-c $o_community ";
+    $shell_command_auth= "-c $o_community $o_host";
```


----------



## abdelilah (Dec 3, 2013)

Thanks for you answer, by changing the code and arguments like this:

```
./check_netstat.pl -H 192.168.1.250 -Cpublic -p138 -w3 -c12
```

I obtain this:

```
ERROR: Alarm signal (Nagios time-out)
```

Can someone please help?


----------



## SirDice (Dec 3, 2013)

Why don't you use something like net-mgmt/p5-SNMP-Simple?


----------



## abdelilah (Dec 3, 2013)

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.


----------



## SirDice (Dec 3, 2013)

It's SNMP either way. So if the Windows host responds to SNMP the Perl module will work too.


----------



## abdelilah (Dec 3, 2013)

How am I supposed to use it since I use the script?


----------



## SirDice (Dec 3, 2013)

Is this an existing script? I thought you were writing something yourself.


----------



## abdelilah (Dec 3, 2013)

No, it is an existing script I took from *N*agios *E*xchange, I am not experienced with *P*erl at all.


----------



## abdelilah (Dec 8, 2013)

Help, topic not solved.


----------



## youngunix (Dec 19, 2013)

Did you fix the issue?

You can try:

```
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
> ...


----------

