Closed PlqnK closed 4 years ago
Hi @PlqnK currently it is not possible to set as a value of a macro another macro.
Regards,
Hi!
Thank you for your quick response.
Hi @PlqnK currently it is not possible to set as a value of a macro another macro.
That's what your own documentation is asking though here https://docs.centreon.com/docs/centreon-engine/en/latest/user/configuration/advanced/monitoring_service_and_host_clusters.html#monitoring-service-clusters. It says that one need to create the following command:
define command{
command_name check_service_cluster
command_line /usr/lib/nagios/plugins/check_cluster --service -l $ARG1$ -w $ARG2$ -c $ARG3$ -d $ARG4$
}
And then a service like that:
define service{
...
check_command check_service_cluster!"DNS Cluster"!1!2!$SERVICESTATEID:host1:DNS Service$,$SERVICESTATEID:host2:DNS Service$,$SERVICESTATEID:host3:DNS Service$
...
}
Where the $ARG4
macro of the command is mapped to $SERVICESTATEID:host1:DNS Service$,$SERVICESTATEID:host2:DNS Service$,$SERVICESTATEID:host3:DNS Service$
in the service definition.
And even then, I tried to create a custom command with the on-demand macro directly inside it like so (/etc/centreon-engine/commands.cfg
):
define command {
command_name check_dummy_custom
command_line $USER1$/check_centreon_dummy -s $SERVICESTATEID:Centeon-central:Cpu$ -o $SERVICESTATEID:Centeon-central:Ping$
}
And udpate the "Dummy" service to directly use that custom command (/etc/centreon-engine/services.cfg
):
define service {
host_name Centeon-central
service_description Dummy
check_command check_dummy_custom
check_period 24x7
max_check_attempts 5
check_interval 3
retry_interval 1
register 1
_SERVICE_ID 533
}
But I get pretty much the same error message (/var/log/centreon-engine/centengine.debug
):
[1595337544] [3312] Checking service 'Dummy' on host 'Centeon-central'...
[1595337544] [3312] Raw Command Input: $USER1$/check_centreon_dummy -s $SERVICESTATEID:Centeon-central:Cpu$ -o $SERVICESTATEID:Centeon-central:Ping$
[1595337544] [3312] Expanded Command Output: $USER1$/check_centreon_dummy -s $SERVICESTATEID:Centeon-central:Cpu$ -o $SERVICESTATEID:Centeon-central:Ping$
[1595337544] [3312] **** BEGIN MACRO PROCESSING ***********
[1595337544] [3312] Processing: '$USER1$/check_centreon_dummy -s $SERVICESTATEID:Centeon-central:Cpu$ -o $SERVICESTATEID:Centeon-central:Ping$'
[1595337544] [3312] Processed 'USER1', To '/usr/lib64/nagios/plugins', Clean Options: 0, Free: 0
[1595337544] [3312] Processed 'USER1', Clean Options: 0, Free: 0
[1595337544] [3312] Cleaning options: global=0, local=0, effective=0
[1595337544] [3312] Uncleaned macro. Running output (25): '/usr/lib64/nagios/plugins'
[1595337544] [3312] Just finished macro. Running output (25): '/usr/lib64/nagios/plugins'
[1595337544] [3312] macros[5] (SERVICESTATEID) match.
[1595337544] [3312] Processed 'SERVICESTATEID:Centeon-central:Cpu', To '', Clean Options: 0, Free: 1
[1595337544] [3312] WARNING: An error occurred processing macro 'SERVICESTATEID:Centeon-central:Cpu'!
[1595337544] [3312] macros[5] (SERVICESTATEID) match.
[1595337544] [3312] Processed 'SERVICESTATEID:Centeon-central:Ping', To '', Clean Options: 0, Free: 1
[1595337544] [3312] WARNING: An error occurred processing macro 'SERVICESTATEID:Centeon-central:Ping'!
[1595337544] [3312] Done. Final output: '/usr/lib64/nagios/plugins/check_centreon_dummy -s -o '
[1595337544] [3312] **** END MACRO PROCESSING *************
All of this is happening on a fresh/clean Centreon 19.10.14 OVA appliance so I definitely think there's something wrong here :-/
Best regards,
Hi @PlqnK, Actually, we did witness a similar behavior about on-demand macros. It seems that we have to backport a fix on the 19.10.x serie of Engine project. In the meantime, you should not use them as it can cause segfaults on Engine.
Hi!
Alright, thanks for this information.
Do you know any other way of monitoring a cluster of service? I've tried to find some but was out of luck unfortunately.
I'm stuck with version 19.10 for the time being so any workaround would be greatly appreciated!
Hi @PlqnK, Yes I do :) You can either use Centreon BAM (commercial product) with the ratio calculation method that fits cluster monitoring needs (https://docs.centreon.com/current/en/service-mapping/ba-management.html#calculation-methods), or use the virtual-service centreon-plugins mode (https://github.com/centreon/centreon-plugins/blob/master/apps/centreon/sql/mode/virtualservice.pm) but it requires some explanations (maybe @Sims24 can provide some as I think a Plugin Packs now exists for it).
Hi @PlqnK can you test on your poller with this version of Centreon Engine and enable your service?
centreon-engine-19.10.14-1595593592.7d68d8d6.tar.gz
Regards,
Hi!
Thanks @cgagnaire for the workarounds!
Well @lpinsivy, that was quick! I tested with the version you uploaded and it solved the problem!
Here's the output of the $USER1$/check_centreon_dummy -s $SERVICESTATEID:Centeon-central:Cpu$ -o $SERVICESTATEID:Centeon-central:Ping$
custom command:
[1595596946] [1236] Checking service 'Dummy' on host 'Centeon-central'...
[1595596946] [1236] Raw Command Input: $USER1$/check_centreon_dummy -s $SERVICESTATEID:Centeon-central:Cpu$ -o $SERVICESTATEID:Centeon-central:Ping$
[1595596946] [1236] Expanded Command Output: $USER1$/check_centreon_dummy -s $SERVICESTATEID:Centeon-central:Cpu$ -o $SERVICESTATEID:Centeon-central:Ping$
[1595596946] [1236] **** BEGIN MACRO PROCESSING ***********
[1595596946] [1236] Processing: '$USER1$/check_centreon_dummy -s $SERVICESTATEID:Centeon-central:Cpu$ -o $SERVICESTATEID:Centeon-central:Ping$'
[1595596946] [1236] Processed 'USER1', To '/usr/lib64/nagios/plugins', Clean Options: 0, Free: 0
[1595596946] [1236] Processed 'USER1', Clean Options: 0, Free: 0
[1595596946] [1236] Cleaning options: global=0, local=0, effective=0
[1595596946] [1236] Uncleaned macro. Running output (25): '/usr/lib64/nagios/plugins'
[1595596946] [1236] Just finished macro. Running output (25): '/usr/lib64/nagios/plugins'
[1595596946] [1236] macros[5] (SERVICESTATEID) match.
[1595596946] [1236] Processed 'SERVICESTATEID:Centeon-central:Cpu', To '0', Clean Options: 0, Free: 1
[1595596946] [1236] Processed 'SERVICESTATEID:Centeon-central:Cpu', Clean Options: 0, Free: 1
[1595596946] [1236] Cleaning options: global=0, local=0, effective=0
[1595596946] [1236] Uncleaned macro. Running output (51): '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0'
[1595596946] [1236] Just finished macro. Running output (51): '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0'
[1595596946] [1236] macros[5] (SERVICESTATEID) match.
[1595596946] [1236] Processed 'SERVICESTATEID:Centeon-central:Ping', To '0', Clean Options: 0, Free: 1
[1595596946] [1236] Processed 'SERVICESTATEID:Centeon-central:Ping', Clean Options: 0, Free: 1
[1595596946] [1236] Cleaning options: global=0, local=0, effective=0
[1595596946] [1236] Uncleaned macro. Running output (56): '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0 -o 0'
[1595596946] [1236] Just finished macro. Running output (56): '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0 -o 0'
[1595596946] [1236] Done. Final output: '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0 -o 0'
[1595596946] [1236] **** END MACRO PROCESSING *************
I also confirm that it works with my original command where there's an on-demand macro "inside" another macro:
[1595597712] [1236] Checking service 'Dummy' on host 'Centeon-central'...
[1595597712] [1236] Raw Command Input: $USER1$/check_centreon_dummy -s $ARG1$ -o $ARG2$
[1595597712] [1236] **** BEGIN MACRO PROCESSING ***********
[1595597712] [1236] Processing: '$SERVICESTATEID:Centeon-central:Cpu$'
[1595597712] [1236] macros[5] (SERVICESTATEID) match.
[1595597712] [1236] Processed 'SERVICESTATEID:Centeon-central:Cpu', To '0', Clean Options: 0, Free: 1
[1595597712] [1236] Processed 'SERVICESTATEID:Centeon-central:Cpu', Clean Options: 0, Free: 1
[1595597712] [1236] Cleaning options: global=0, local=0, effective=0
[1595597712] [1236] Uncleaned macro. Running output (1): '0'
[1595597712] [1236] Just finished macro. Running output (1): '0'
[1595597712] [1236] Done. Final output: '0'
[1595597712] [1236] **** END MACRO PROCESSING *************
[1595597712] [1236] **** BEGIN MACRO PROCESSING ***********
[1595597712] [1236] Processing: '$SERVICESTATEID:Centeon-central:Ping$'
[1595597712] [1236] macros[5] (SERVICESTATEID) match.
[1595597712] [1236] Processed 'SERVICESTATEID:Centeon-central:Ping', To '0', Clean Options: 0, Free: 1
[1595597712] [1236] Processed 'SERVICESTATEID:Centeon-central:Ping', Clean Options: 0, Free: 1
[1595597712] [1236] Cleaning options: global=0, local=0, effective=0
[1595597712] [1236] Uncleaned macro. Running output (1): '0'
[1595597712] [1236] Just finished macro. Running output (1): '0'
[1595597712] [1236] Done. Final output: '0'
[1595597712] [1236] **** END MACRO PROCESSING *************
[1595597712] [1236] Expanded Command Output: $USER1$/check_centreon_dummy -s $ARG1$ -o $ARG2$
[1595597712] [1236] **** BEGIN MACRO PROCESSING ***********
[1595597712] [1236] Processing: '$USER1$/check_centreon_dummy -s $ARG1$ -o $ARG2$'
[1595597712] [1236] Processed 'USER1', To '/usr/lib64/nagios/plugins', Clean Options: 0, Free: 0
[1595597712] [1236] Processed 'USER1', Clean Options: 0, Free: 0
[1595597712] [1236] Cleaning options: global=0, local=0, effective=0
[1595597712] [1236] Uncleaned macro. Running output (25): '/usr/lib64/nagios/plugins'
[1595597712] [1236] Just finished macro. Running output (25): '/usr/lib64/nagios/plugins'
[1595597712] [1236] Processed 'ARG1', To '0', Clean Options: 0, Free: 0
[1595597712] [1236] Processed 'ARG1', Clean Options: 0, Free: 0
[1595597712] [1236] Cleaning options: global=0, local=0, effective=0
[1595597712] [1236] Uncleaned macro. Running output (51): '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0'
[1595597712] [1236] Just finished macro. Running output (51): '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0'
[1595597712] [1236] Processed 'ARG2', To '0', Clean Options: 0, Free: 0
[1595597712] [1236] Processed 'ARG2', Clean Options: 0, Free: 0
[1595597712] [1236] Cleaning options: global=0, local=0, effective=0
[1595597712] [1236] Uncleaned macro. Running output (56): '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0 -o 0'
[1595597712] [1236] Just finished macro. Running output (56): '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0 -o 0'
[1595597712] [1236] Done. Final output: '/usr/lib64/nagios/plugins/check_centreon_dummy -s 0 -o 0'
[1595597712] [1236] **** END MACRO PROCESSING *************
And finally it now also works on my services that use the check_cluster
command!
Do you have an idea of when the fix will make it into a release?
Thanks a lot for your work!
Good news! It will be in the 19.10.15 of Engine, surely in the next 3 to 4 weeks. Thanks you!
BUG REPORT INFORMATION
Prerequisites
Versions
Operating System
CentOS Linux release 7.8.2003 (Core)
Browser used
Version: 78.0.2
Additional environment details (AWS, VirtualBox, physical, etc.):
I'm using the 19.10 OVA, imported into VirtualBox 6.1.10 r138449 running on Windows 10 1809 17763.1282. I've updated Centreon to the latest available version using the instructions from the documentation.
Description
I'm trying to configure and use the
check_cluster
plugin according to the documentation here. In order to use it you must create a service which references an on-demand service macro.The problem I'm facing is that Centreon matches the on-demand macro but fails to process it.
To demonstrate it I've created a Dummy service using the
check_centreon_dummy
command attached to a host where$ARG1$
is set to$SERVICESTATEID:Centeon-central:Cpu$
(the typo on "Centeon" is expected, that's the default hostname in the 19.10 OVA) and$ARG2$
is set to$SERVICESTATEID:Centeon-central:Ping$
. Here's the resulting entry in/etc/centreon-engine/services.cfg
:The services
Cpu
andPing
exists and works fine on the hostCenteon-central
:Steps to Reproduce
Centeon-central
hostcheck_centreon_dummy
check command$SERVICESTATEID:Centeon-central:Cpu$
as$ARG1$
$SERVICESTATEID:Centeon-central:Ping$
as$ARG2$
-s
and-o
arguments be empty.Describe the received result
When Centreon checks the service and processes the macro it doesn't work and the resulting command line arguments of the
check_centreon_dummy
plugin are empty:Please see the centreon-engine debug log extract further down in the Logs section to see the exact error reported.
Describe the expected result
Centreon should process the macro and replace
$SERVICESTATEID:Centeon-central:Cpu$
with the state ID of theCpu
service of the hostCenteon-central
, in my case0
as well as$SERVICESTATEID:Centeon-central:Ping$
with the state ID of thePing
service of the hostCenteon-central
, in my case0
again.Logs
PHP error logs
centreon-engine debug logs
Additional relevant information (e.g. frequency, ...)
I've tried restarting the
cbd
,centengine
andcentcore
services but it didn't solve the problem. Restarting the VM also didn't solve the problem.In the documentation it's said that toggling
use_large_installation_tweaks
to1
disables the on-demand macro processing, but it's default is0
and even when forcing it to0
the problem persists.