Skip to main content
Question

how genrate a list of active services (no templates) without contactgroup define? sql, api, api rest, .conf file?

  • November 27, 2025
  • 2 replies
  • 14 views

Forum|alt.badge.img+5

Hi everyone,

I’m looking for the most efficient way to generate a list of active services (excluding templates) that do not have any contactgroup defined—neither directly nor inherited from templates.

I’d like to explore different methods to achieve this, such as:

  • SQL queries (directly querying the Centreon database)
  • REST API (if applicable)
  • Parsing configuration files (e.g., .conf files in /var/lib/centreon-engine/central/config/)

If you’ve already tackled this issue or have any insights, I’d appreciate your input! Which method do you recommend for accuracy and simplicity?

Thanks in advance for your help!

2 replies

Forum|alt.badge.img+11

That’s a good question, as those data is using inheritences at multiple levels.

I suppose that to be able to see the “aggregated” configuration to be 100% sure that a service doesn’t have ANY contactgroup that the generated configuration is the most reliable, but i never tried.

Maybe the new REST APIV2 could do it, but i don’t think i saw the required data for this.
If you figure it out please share it, I’m curious.


Forum|alt.badge.img+5
  • Author
  • Steward **
  • December 15, 2025

with a AWK script to filter services  that have no contactgroup defined (including those inherited from templates). While Centreon’s SQL or CLAPI may not reflect aggregated contactgroups in the object configuration files, parsing the config files directly is the most reliable way to identify such services.

The script is still in testing/optimization phase, but it’s currently the best approach to find objects without any contactgroup or contacts defined.

awk '/^define service/ {inserv=1; hasreg=0; hascg=0; svc=""} /^\}/ {if(inserv && hasreg && !hascg) print svc; inserv=0; svc=""} inserv {svc=svc $0 "\n"; if($0~/register[[:space:]]+1/) hasreg=1; if($0~/contact_groups/) hascg=1}' /etc/centreon-engine/services.cfg