Page 1 of 1

NCPA: Custom Plugin Error [SOLVED]

Posted: Tue Jan 12, 2021 5:14 pm
by altsysrq
I have a custom plugin that checks to see if Puppet is working on our servers. It fails with the error below. All other builtin NCPA plugins are working. I tried creating a /home/nagios directory with nagios permissions but then the script errors with other errors (/usr/local/ncpa/plugins/check_puppet_agent: line 259: + : syntax error: operand expected (error token is "+ ").

Error

Code: Select all

[[email protected] ~]$ /usr/local/nagios/libexec/check_ncpa.py -H phpipam.mydomain.com -t 'my_token' -P 5693 -M 'plugins/check_puppet_agent'
[1;31mError: Could not initialize global default settings: Permission denied @ dir_s_mkdir - /home/nagios?[0m
UNKNOWN: Internal error: Puppet version unknown from ?[1;31mError: Could not initialize global default settings: Permission denied @ dir_s_mkdir - /home/nagios?[0m
Ubuntu Focal, using Eoan repositories for now until Focal release is available
Builtin NCPA Plugins work and are reporting correctly
Plugin script works as a normal user CLI on the client node and using NRPE

Is this a compatibility issue with Focal or do I have a configuration issue on my hands? Any thoughts on this?

Re: NCPA: Custom Plugin Error [SOLVED]

Posted: Thu Jan 14, 2021 4:51 pm
by altsysrq
I was able to fix this issue with the following methods:

Permissions
sudo permissions were not setup correctly to allow Nagios access to the script or executables the script wanted to call. There is more here, but basically, I did not verify that it was exactly the same as our NRPE plugin was setup.

Persistence
I should have been able to find this issue by more aggressively testing with the Nagios user (as mentioned many times in these threads). It took a support case with Nagios to help me realize that I had not adequately tested this.

Syntax
Once those above issues were dealt with I was able to get it to work in the UI for Nagios XI. My mistake here was using a single quote where a double should have been used and a double quote where a single quote should have been used.

For reference, the puppet check script I was using is here: https://github.com/aswen/nagios-plugins ... ppet_agent

My resulting argument is this:

Code: Select all

-t 'token' -P 5693 -M 'plugins/check_puppet_agent' -a '-k "/tmp/last_run_print.txt" -r "/tmp/last_run_report.yaml" -s "/tmp/last_run_summary.yaml" -w "3600" -c "7200"'
I hope this helps someone else. Thank you to support for your nudge.