and a Loadbalancer with the same name, but no number. email.example.com
We use this naming-schema for multiple services (LDAP, WEB, …) and I wanted to create rules with parameters. The aggregation is a very flat tree:
Service $service="email"$ is available (Worst status of all children)
|--> Loadbalancer $service="email"$ (Worst)
|--> Cluster nodes $service="email"$\d (Worst, but limited to WARNING)
So I tried to set up a rule and set the Child Node Generator to Create Nodes based on a host search to capture the numbered cluster-hosts but it wants a regex, which seems to be incompatible with $parameters$ due to the dollar sign.
Is that correct or is there a trick to use parameters in regexes?
I was unable to find any reference and surfing the cmk code is too hard for me.
I hope it goes through in full resolution. Otherwise I’ll think of something and edit this post.
I just wonder how a dollar-sign, which means “end-of-line” in regular expressions, can be used here without some magic.
Aha. Thank you Christian. That put me on the right track.
I’ve been playing around and seen some funny things.
So these are my experiment-notes. First line is the Hostname Regex, second line is Nodes to create and third line is the result. To start my fun result without a parameter:
* "all hosts"
+ email\d.*
= 156 (!) nodes, 52x email1-3 - one for each of the 52 hostnames in the database.
* .* (which is effectively "all hosts")
+ email\d.
= 3 correct nodes
-> "all hosts" is not the same as "regex .*"
Now with the parameter. I’ll start with the correct answer and then add all my failures.
Now for some other fun: The same thing, but for services!
So far, I’ve been able to produce hosts with “Create nodes based on a service search”:
Create Nodes based on a service search
+ regex for host name
+ nodes to create host - empty is not allowed
service regex is empty with the non-parameterized rules.
non-parameterized rules have "regex for host name" and "nodes to create host" the same value
+ $service$([0-9]).example.de
+ $HOSTNAME$
= added 3 host nodes. not a single service.
+ $service$([0-9]).example.de
+ same
= nothing
+ $service$[0-9].example.de
+ same
= nothing
+ $service$([0-9]).example.de
+ $1$
= nothing,
+ $service$.*
+ .*
= 52 different host entries. each server in the database.
+ $service$.*
+ same
= nothing
I would like to prefer to call a rule to detect the needed services for the host from host serach. If you want more than one service you can use a pipe like “CPU.*|Memory.*” and so on.