How do I install my plugin?

Having issues? Post them here, and help other users.
Post Reply
Graeme
Junior Member
Posts: 2
Joined: Thu Apr 29, 2021 5:25 am

How do I install my plugin?

Post by Graeme »

RPi 4B 2GB
NEMS Linux 1.5.2

I'm working on a check_ script in PHP to get health info from my UniFi controller. It uses the PHP class documented at

https://github.com/Art-of-WiFi/UniFi-API-client

to talk to the UniFi web API. It's written with reference to J. Hoerter's work on a generic use of this,

https://www.jhoerter.com/download/check_unifi-php.html

my usage is very specific, though. I have it working to my satisfaction invoked from the command line in my account on the NEMS server.

My problem now is how to install it as a plugin. These are the files involved:

check_unifi_health.php - my script
requires check_settings.php - my settings
requires check_unifi.php - the API client class installed vi PHP Composer in a Vendor subdir

I've figured out that /usr/local/nagios/libexec is the location of the built-in nagios scripts but putting my files here does not lead to their appearance in the drop-down list of check_ commands in the NEMS configurator. So, something else needs to be done - but what?

Can you help, please?
Graeme
Junior Member
Posts: 2
Joined: Thu Apr 29, 2021 5:25 am

Re: How do I install my plugin?

Post by Graeme »

In case it's of use to anyone - Responding to my own question here after finding the answer.

The NConf Import Guide explains what needs to be done:

https://www.nconf.org/wordpress/wp-cont ... -guide.pdf

Essentially, the new check command script, as well as being placed in the plugins directory also has to be registered via add_items_from_nagios.pl in the NConf database. First create a new check command definition in a file e.g. checkcommand-unifi_health.cfg

Code: Select all

define command {
                command_name                          check_unifi_health
                command_line                          $USER1$/check_unifi_health $ARG1$
}
Then verify expected action using the -s (simulate option)

Code: Select all

sudo /var/www/nconf/bin/add_items_from_nagios.pl -c checkcommand -f ~graeme/check_unifi/checkcommand-health.cfg -s
Look for errors in the output before removing the -s from the command to do it for real.
Post Reply