5

I am using custom Nagios plugins for the first time and am running into this error when I create a service for the plugin.

(No output on stdout) stderr: execvp(/usr/local/nagios/libexec/check_load.py, ...) failed. errno is 2: No such file or directory

The plugin works when I run it on the command line, however does not work when it runs within Nagios.

I followed these steps to get the plugin into Nagios https://assets.nagios.com/downloads/nagiosxi/docs/Managing-Plugins-in-Nagios-XI.pdf

Here is what it looks like in the Nagios UI

The plugin is in the correct path: /usr/local/nagios/libexec and the resource.cfg file has the same path within it.

I tried two separate plugins, both which work on the command line, and the result is the same error.

The error indicates the file location is incorrect, however the plugin is in the specified directory and runs with no errors within that directory.

I am totally stumped and appreciate any help.

Matt Hahn
  • 394
  • 1
  • 4
  • 13

2 Answers2

5

For anyone reading this, I solved the problem.

The first time I added the plugin, I forgot to add the python extension. When I updated the already created plugin, Nagios still threw the error.

Once I completely deleted the plugin and re-created it the 'file not found', error went away.

Matt Hahn
  • 394
  • 1
  • 4
  • 13
0

I faced a similar issue when I was trying to add a custom plugin ( I had custom plugins in ruby and python ).

The issue was the missing shebang line at the start of the script (which determines the script's ability to be executed like a standalone executable).

For example, if you have a python plugin custom-plugin.py then make sure this script has shebang at the start of script #!/usr/bin/env python3. Also if you have other scripts (ruby, bash etc.) make sure to add the appropriate path at the start of your scripts.

Also, check the path for plugins Nagios version. For my setup path was /usr/local/nagios/libexec/ and make sure your custom plugin is executable and has correct ownership permissions.

Sample custom template I used :

define command {
  command_name  check_switch_health
  command_line /usr/local/nagios/libexec/check_snmp.rb --host $HOSTADDRESS$  --model "$ARG1$" --community "$ARG2$"
}

The above workaround worked for me.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Akhilesh Joshi
  • 288
  • 3
  • 13