NCPA - cannot execute custom plugin script

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User Name
Posts: 8
Joined: Wed Mar 23, 2016 8:17 am

NCPA - cannot execute custom plugin script

Post by User Name »

We are trying to restart a Linux service using a custom script in the NCPA 'plugins/' directory. The intention is to use it for restarting services.
I used the (somewhat limited) documentation.

1. create a restartservice.sh script in the plugins/ directory with execute permissions
2. call check_ncpa.py, as follows from the Nagios server:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H <host> -P 5693 -t 'token' -M plugins/restartservice.sh "-u 'ntpd'" -v
The output is:

Code: Select all

Connecting to: https://<host>:5693/api/plugins/restartservice.sh/?units=+%27ntpd%27&token=token&check=1
File returned contained:
{
  "value": {
    "returncode": 3, 
    "stdout": "Unable to run check on non-child node. Revise your query."
  }
}
Unable to run check on non-child node. Revise your query.
We have tried with various settings but the error remains. For example:
-M plugins/restartservice.sh
-M /restartservice.sh
-M restartservice.sh

but we cannot execute the plugin script. Are we missing something obvious?

The NCPA is running fine: we get the performance dashboard web page and we are also able to retrieve performance data form the API tree, using check_ncpa.py. Just not able to execute a custom script.

Running with:

Nagios XI 5.2.0 on RHEL 6
check_ncpa.py version 1.0
NCPA agent 1.8.1 on RHEL 6

/usr/local/ncpa/etc/ncpa.cfg:

Code: Select all

[listener]
uid = nagios
certificate = adhoc
loglevel = info
ip = 0.0.0.0
gid = nagcmd
logfile = var/ncpa_listener.log
port = 5693
pidfile = var/ncpa_listener.pid
# Available versions: PROTOCOL SSLv2, SSLv3, TLSv1
ssl_version = TLSv1

[passive]
uid = nagios
handlers = nrds,nrdp
loglevel = info
gid = nagcmd
sleep = 300
logfile = var/ncpa_passive.log
pidfile = var/ncpa_passive.pid

[nrdp]
token = yourtoken
hostname = yourhostname
parent = yourparent

[nrds]
URL = None
CONFIG_VERSION = None
TOKEN = None
CONFIG_NAME = None
CONFIG_OS = None

[api]
community_string = x8uL5WSEbhBbsiWNVl2qXz

[plugin directives]
plugin_path = plugins/
.sh = /bin/sh $plugin_name $plugin_args
.ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_args
.vbs = cscript $plugin_name $plugin_args //NoLogo

[passive checks]
%HOSTNAME%|cpu usage = /cpu/percent --warning 20 --critical 30
%HOSTNAME%|swap usage = /memory/swap/percent --warning 40 --critical 80
%HOSTNAME%|memory usage = /memory/virtual/percent --warning 60 --critical 80
--
Martijn
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA - cannot execute custom plugin script

Post by lmiltchev »

Can you try the following?

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H <host> -P 5693 -t 'token' -M agent/plugin/restartservice.sh -a "-u 'ntpd'"
Note: According to the NCPA documentation, you are suppose to use the following format:

Code: Select all

./check_ncpa.py -H ncpaserver -t yourtoken agent/plugin/test.sh -a "-u 'one argument' -p 'another argument'"
Be sure to check out our Knowledgebase for helpful articles and solutions!
User Name
Posts: 8
Joined: Wed Mar 23, 2016 8:17 am

Re: NCPA - cannot execute custom plugin script

Post by User Name »

Thank you very much. The following did it:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H <host> -t '<token>' -P 5693 -M agent/plugin/restartservice.sh -a 'ntpd'
What confused me is that the value to the -M argument (agent/plugin/) is not related to the plugin_path directive in the ncpa.cfg.
--
Martijn
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: NCPA - cannot execute custom plugin script

Post by mcapra »

Is it alright if we lock this thread and mark the issue as resolved?
Former Nagios employee
https://www.mcapra.com/
Locked