Custom plugin works on terminal but not from Web site
Hello,
I am developing a plugin to retrieve the information provided by openitCockpit. I started with a plugin allowing me to retrieve the load percentage of each processor. From the command line, it works correctly but from the web interface, I get an error (Execute command failed). When I copy the command from the interface to the terminal, it works, so the command is good. I added the plugin path (/usr/lib/nagios/plugins/centreon-plugins/src) to the white list in the file /etc/centreon-gorgone/config.d/whitelist.conf.d/custom.yaml as follows: - ^/usr/lib/nagios/plugins/centreon-plugins/src/.*$
I can't find anything in the logs and I don't know what else to do to make it work.
Centreon is running on a Debian Bullseye and is on version 24.04.4
Page 1 / 1
Hello,
Did you try to execute your plugin as centreon-engine user? It can be a permission issue
Centreon execute all it’s plugins with this user
Hope it helps
When in doubt, I did: chown centreon-engine:centreon-engine /usr/lib/nagios/plugins but that didn't change anything.
Anyway, other plugins work without it. I don't remember the password I entered for the centreon-engine user and I'm afraid if I reset it it won't work anymore.
As root, you can connect as centreon-engine without the user password with this command
su centreon-engine
The command works with the centreon-engine user.
It doesn't only work from the web interface. I don't know where to look anymore.
Hi @sebastienp,
If the problem was the whitelist, the message should be clear about it, so I don’t think we need to look further that way.
Usually such message means that the plugin is not present or not executable. Are you completely sure you deployed and tested it on the same poller where the monitoring of your resource is done?
Hi @omercier,
Everything is on the same VM. It is the centreon_plugins.pl file which is called to execute the plugin which is placed in src/apps/opencockpit/api/plugin.pm
Can you show the command that is launched? Maybe it will help me understand what’s wrong.
this command works on terminal but return “(Execute command failed)” on Web interface : /usr/lib/nagios/plugins/centreon-plugins/src/centreon_plugins.pl --plugin=apps::openitcockpit::api::plugin --hostname=192.168.234.100 --mode=app-cpus --warning=80 --critical=90 --proto=http --port=3333
Is it possible that an exit state is missing? I output either OK, Warning, or Critical, with a message depending on the status.
In return for the REST request http://centreon.nautech-group.com/centreon/api/latest/monitoring/resources/hosts/27/services/459 I have the answer with status UNKNOW but the answer in terminal is “OK: Tous les processeurs sont OK.”:
On terminal : /usr/lib/nagios/plugins/centreon-plugins/src/centreon_plugins.pl --plugin=apps::openitcockpit::api::plugin --hostname=192.168.234.100 --mode=memory --warning=80 --critical=90 --proto=http --port=3333 OK: La mémoire est OK. - Mémoire utilisée à 76.95% (96802880Ko/125793552Ko)
But same result on Web interface : (Execute command failed)
What is the result of this command?
ls -l /usr/lib/nagios/plugins/centreon-plugins/src/
I tried other plugins provided with the package but I got the same error.
There’s a problem with the execution of all plugins.
hello
I looked at this post just now, but I don’t see the command you have setup in your “check command” web ui, maybe you used a wrong option/syntax there (I know you can have issue sometimes with some quotes and what is displayed on the service and what is really executed, you need to use single quotes around the macros, and other things to be aware of)
could you provide what you have entered there, or a screenshot of the configuration?
and I did some plugin dev also, but I used the centreon plugin folder to make a new folder where I cloned the git and dev from here, I had no issue by putting the code there
/usr/lib/centreon/plugins/mynewplugin
(I usually git clone somewhere /tmp, then move the folder with a new name in that plugin folder)
could you try to move or copy your plugin folder there?
and to get the selinux status it is “getenforce”
if is “Enforcing” try “setenforce 0” which will temporarily allow more things to run. (you would need to reboot or “setenforce 1” to reactivate it in enforcing mode
Thanks @christophe.niel-ACT for your reply.
I try to add simple quotes on the macros but it doesn’t work.
As I said above, the problem is broader than the simple plugin I am developing because no other plugin from Git works, they all return the same error message.
I put the Git folder in /usr/lib/centreon/plugins/ and the full path is /usr/lib/centreon/plugins/apps/openitcockpit/api/mode
When I type the command "setenforce 0", I get the response "Command not found".
And for the configuration, it’s like this :
Is the directory part of your resources?
“Configuration > Pollers > Resources”
does it match your command?
“Configuration > Commands > Checks”
is it in a different poller? do you have the directory there?
All is on the same VM, I tried different configurations but it doesn't change anything.