Skip to main content
Solved

Is it possible to change service inherit_contacts_from_host value with api ?

  • October 23, 2024
  • 6 replies
  • 67 views

Forum|alt.badge.img+4

Bonjour,

 

All is in the title:

 

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

 

Thanks,

Mathias

 

 

Best answer by vcoum

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'

 

 

6 replies

Forum|alt.badge.img+4
  • Author
  • Steward **
  • 17 replies
  • October 23, 2024

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?


Forum|alt.badge.img+6
  • Centreonian
  • 13 replies
  • October 24, 2024

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?


vcoum
Centreon Lord Commander
Forum|alt.badge.img+13
  • Centreon Lord Commander
  • 137 replies
  • Answer
  • October 24, 2024

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'

 

 


Forum|alt.badge.img+6
  • Centreonian
  • 13 replies
  • October 25, 2024

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 [centreon]> 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.


Forum|alt.badge.img+4
  • Author
  • Steward **
  • 17 replies
  • October 28, 2024

Great it works too with the REST API V1 .

 

Thanks!


Forum|alt.badge.img+4
  • Author
  • Steward **
  • 17 replies
  • November 6, 2024

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