Skip to main content
Question

Custom plugin works on terminal but not from Web site

  • August 1, 2024
  • 19 replies
  • 443 views

Forum|alt.badge.img+3

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

19 replies

vcoum
Centreon Lord Commander
Forum|alt.badge.img+13
  • Centreon Lord Commander
  • August 2, 2024

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


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 2, 2024

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.


vcoum
Centreon Lord Commander
Forum|alt.badge.img+13
  • Centreon Lord Commander
  • August 2, 2024

As root, you can connect as centreon-engine without the user password with this command

su centreon-engine

 


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 2, 2024

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.


omercier
Centreonian
Forum|alt.badge.img+13
  • Centreonian
  • August 2, 2024

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?

 


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 2, 2024

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


omercier
Centreonian
Forum|alt.badge.img+13
  • Centreonian
  • August 2, 2024

Can you show the command that is launched? Maybe it will help me understand what’s wrong.


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 6, 2024

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.”:

{
    "uuid": "h27-s459",
    "id": 459,
    "name": "OpenCockpitCpus",
    "type": "service",
    "short_type": "s",
    "status": {
        "name": "UNKNOWN",
        "code": 3,
        "severity_code": 3,
        "type": 1
    },
    "in_downtime": false,
    "acknowledged": false,
    "flapping": false,
    "performance_data": "",
    "information": "(Execute command failed)\n",
    "command_line": "/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",
    "notification_number": 1374,
    "latency": 0.224,
    "percent_state_change": 0,
    "passive_checks": true,
    "execution_time": 0.001704,
    "active_checks": true,
    "icon": {
        "id": null,
        "name": "",
        "url": ""
    },
    "groups": [],
    "parent": {
        "type": "host",
        "id": 27,
        "name": "Hyper-V_Nautech",
        "status": {
            "name": "UP",
            "code": 0,
            "severity_code": 5,
            "type": 1
        },
        "monitoring_server_name": "Central"
    },
    "monitoring_server_name": "Central",
    "categories": [],
    "severity": null,
    "acknowledgement": null,
    "downtimes": [],
    "duration": "4d 18h",
    "next_check": "2024-08-06T09:23:19+02:00",
    "last_check": "2024-08-06T09:18:19+02:00",
    "last_time_with_no_issue": null,
    "last_status_change": "2024-08-01T15:01:10+02:00",
    "last_notification": null,
    "tries": "3/3(H)",
    "links": {
        "endpoints": {
            "notification_policy": "/centreon/api/latest/configuration/hosts/27/services/459/notification-policy",
            "timeline": "/centreon/api/latest/monitoring/hosts/27/services/459/timeline",
            "timeline_download": "/centreon/api/latest/monitoring/hosts/27/services/459/timeline/download",
            "status_graph": "/centreon/api/latest/monitoring/hosts/27/services/459/metrics/status",
            "performance_graph": null,
            "details": "/centreon/api/latest/monitoring/resources/hosts/27/services/459",
            "metrics": "/centreon/api/latest/monitoring/hosts/27/services/459/metrics"
        },
        "uris": {
            "configuration": "/centreon/main.php?p=60201&o=c&service_id=459",
            "logs": "/centreon/main.php?p=20301&svc=27_459",
            "reporting": "/centreon/main.php?p=30702&period=yesterday&start=&end=&host_id=27&item=459"
        }
    }
}


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 6, 2024

I make another service for my plugin.

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)


omercier
Centreonian
Forum|alt.badge.img+13
  • Centreonian
  • August 6, 2024

What is the result of this command?

ls -l /usr/lib/nagios/plugins/centreon-plugins/src/

 


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 6, 2024


total 56
drwxrwxrwx 85 centreon-engine centreon-engine 4096 31 juil. 11:21 apps
drwxrwxrwx  4 centreon-engine centreon-engine 4096 31 juil. 11:21 blockchain
drwxrwxrwx  4 centreon-engine centreon-engine 4096 31 juil. 11:21 centreon
-rwxrwxrwx  1 centreon-engine centreon-engine  989 31 juil. 11:22 centreon_plugins.pl
drwxrwxrwx 18 centreon-engine centreon-engine 4096 31 juil. 11:22 cloud
drwxrwxrwx  4 centreon-engine centreon-engine 4096 31 juil. 11:22 contrib
drwxrwxrwx 19 centreon-engine centreon-engine 4096 31 juil. 11:22 database
drwxrwxrwx  4 centreon-engine centreon-engine 4096 31 juil. 11:22 example
drwxrwxrwx 11 centreon-engine centreon-engine 4096 31 juil. 11:22 hardware
drwxrwxrwx 94 centreon-engine centreon-engine 4096 31 juil. 11:22 network
drwxrwxrwx 13 centreon-engine centreon-engine 4096 31 juil. 11:22 notification
drwxrwxrwx 11 centreon-engine centreon-engine 4096 31 juil. 11:22 os
drwxrwxrwx  3 centreon-engine centreon-engine 4096 31 juil. 11:22 snmp_standard
drwxrwxrwx 31 centreon-engine centreon-engine 4096 31 juil. 11:22 storage
 


omercier
Centreonian
Forum|alt.badge.img+13
  • Centreonian
  • August 6, 2024

Is SELinux enabled, permissive or disabled?


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 6, 2024

It seems to be more than disabling.

sestatus
-bash: sestatus : commande introuvable
 


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 7, 2024

I tried other plugins provided with the package but I got the same error.

There’s a problem with the execution of all plugins.

 


Forum|alt.badge.img+17

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

 


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 16, 2024

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 :

 


ponchoh
Centreonian
Forum|alt.badge.img+14
  • Centreonian
  • August 16, 2024

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?

 

 


Forum|alt.badge.img+3
  • Author
  • Steward *
  • August 20, 2024

All is on the same VM, I tried different configurations but it doesn't change anything.

 

 


dagabard
Forum|alt.badge.img+5
  • Steward *
  • November 25, 2024

can you post engine.log ? 

as usual, the log of this command are here 

the command is landed by centengine user, there is no reason that’s is doen’t work.
 

test your command after su - centengine (to charge the environnement variable)

and not with su centengine.
and show us the display