Zabbix service.discovery multiple templates for distinct items and triggers

discoverymonitoringtemplatezabbix

service.discovery in Zabbix returns a JSON array of all current running services (based on filters) for each host.

I would like to create a template hierarchy where i have a parent template that contains the service.discovery LLD service, and than add this template to child templates that will extract the respective data that they need for their particular role, Skype, MySQL, Antivirus and so on.

My parent template finds all services with a state of automatic or automatic delayed through a global regular expression ^(automatic|automatic delayed)$ [Result is TRUE] and activated under the discovery rule (filters) as {#SERVICE.STARTUPNAME} through a template macro.

But in creating my child templates i hit a brick wall when trying to create items and triggers for, for example Skype.

I have experimented with macros, pre-processing (under item) and anything else i can think of, reading extensively through the Zabbix documentation with no solution.

Question
My child template sees the service.discovery rule from the parent template as expected, how can i extract all services for Skype from the JSON object and create discovery items?

Problem
In zabbix it's not possible to have more than one active service.discovery LLD per host configured at a time.

Best Answer

  1. Create a template that contains the service.discovery
  2. Create one or more global regex for services you want to find

2.1 ^(Service1|Service2|Service3) [Result is TRUE]

2.2 ^(automatic|automatic delayed)$ [Result is TRUE]

  1. Add these as filter expressions under the service.discovery rule

3.1 Type of calculation = 'And' and 'matches' for the expression.

  1. Create a discovery item prototype

4.1 Name: {#SERVICE.DISPLAYNAME} ({#SERVICE.NAME}) is {#SERVICE.STATENAME}

4.2 Key: service.info[{#SERVICE.NAME},state]

4.3 Show value: Windows service state

  1. Create a new template eg, Skype and link the first template to the Skype template. This makes the second template inherite the service.discovery rule
  2. In the Skype template make a new macro {$SKYPE} = ^Skype
  3. Type of valculation = 'And/Or' and 'Matches' for the expression
  4. Activate the skype template for the host

Zabbix 4.0