Skip to main content

Bonjour,

 

All is in the title:

 

Is it possible to change service inherit_contacts_from_host value with an api ?

 

Thanks,

Mathias

 

 

Is possibile to do something like this? :

 

alter table service alter service_inherit_contacts_from_host set default '1';
alter table service alter service_use_only_contacts_from_host set default '1';

 

Does it work?


Ciao!

With CLAPI? The following to parameters works.

https://docs.centreon.com/docs/api/clapi/#setparam-18

Parameter Description
contact_additive_inheritance Enables contact additive inheritance
cg_additive_inheritance Enables contactgroup additive inheritance

 

Example:

centreon -u admin -p 'VerySecterPassword' -o SERVICE -a SETPARAM -v 'test_ping;Ping;contact_additive_inheritance;1'

They are useful for you?


Hello,

It’s not documented but use_only_contacts_from_host also works (0 for no, 1 for yes)

 

centreon -u admin -p 'VerySecterPassword' -o SERVICE -a SETPARAM -v 'test_ping;Ping;use_only_contacts_from_host;1'

 

 


Hello,

It’s not documented but use_only_contacts_from_host also works (0 for no, 1 for yes)

 

centreon -u admin -p 'VerySecterPassword' -o SERVICE -a SETPARAM -v 'test_ping;Ping;use_only_contacts_from_host;1'

 

 

 

Nice!

Taken by curiosity I read the code of centreon-clapi/centreonService.class.php

Skip if you are not interested in the PHP code.

The function setparam have a big switch/case, and the default if to accept the third parameters, renaming it service_foobar.

After PHP code, and then magic! The update works because the service table have the field named service_foobar.

In this case:


MariaDB Mcentreon]> SHOW FIELDS FROM centreon.service WHERE Field LIKE 'service_use_only_contacts_from_host';
+-------------------------------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------------------------------+---------------+------+-----+---------+-------+
| service_use_only_contacts_from_host | enum('0','1') | YES | | 0 | |
+-------------------------------------+---------------+------+-----+---------+-------+
1 row in set (0.001 sec)


P.S. forgive me if I made too many simplification.


Great it works too with the REST API V1 .

 

Thanks!


Hi,

For information, there is 2 flags in centreon database, table service :

  • service_inherit_contacts_from_host  :

if no contact set in service, it could inherit contact from host. it s enabled by default

  • service_use_only_contacts_from_host :

host contact override service contact if enable. it s disable by default

 

hope it s will help.

Mathias

 

 


Reply