Many of our monitoring-checks have parameters that accept either a string or a regular expression (regex or regexp for short) as a value. This possibility, especially in combination with a naming convention, is a very flexible and powerful instrument to control what the monitoring plugins should check.
~
), everything after the tilde is interpreted as a regex.--include=aggr1
(exact match, check only the aggregate aggr1)
--include=~aggr1
(check only those aggregates, whose name contains the string aggr1)
--include=~^aggr1
(check only those aggregates, whose name starts with aggr1)
--exclude=~bak$
(do not check volumes, whose name ends with bak)
--include=~^\Qaggr1.tmp\E$
(check only the aggregates which start and end with aggr1.tmp
, effectively this is the same as --include=aggr1.tmp
)
More information about our monitoring plugin products can be found on our main page monitoring-plugins.pro/products.
A regular expression is a special text string for describing a search pattern. You are probably familiar with wildcard notations such as *.txt
to find all text files in a file manager. The regex equivalent is .*\.txt$
The following graphic explains each of this expressions components.
The regex syntax offers thousands of different metacharacters. Below are the most important ones if you want to configure your monitoring system with our plugins.
.
vs \.
)The .
(dot) is a wildcard. It matches any character. The most important thing is that you know how to write a normal, literal dot instead of the wildcard-dot.
The \.
matches a literal dot only. This gets important, if an instance’s name uses dots to separate parts.
--include=~^vsrv1\.
vsrv1.vol0
vsrv1.vol1
vsrv1.vol22
vsrv1.our-great-volume
vsrv1.someothervolume
--include=~^vsrv1.
(without the backslash in front of the dot)Matching volume-names would be:
vsrv1.vol0
vsrv11.vol1
vsrv15.vol22
vsrv100.vol0
vsrv199.someothervolume
...
^
and $
)You may have noticed the ^
in the examples above. They tell the regex-engine to match the following pattern only if the string starts with this pattern.
--include=~vsrv1
vsrv1.vol0
myvsrv1.vol1
other-vsrv1.vol22
vserv9.vol-vserv19bak
...
The above example, without any anchor, is most likely not useful in practice. It is mainly an example of how not to do it.
--include=~^vsrv1\.
--exclude=~\.temp$
.temp
.To match a string while ignoring the case of its letters, prefix (?i)
to the pattern.
The regex pattern h?llo
would match to the strings hello
or hallo
(and also h1llo
, hhllo
, …) but not Hello
.
The regex pattern (?i)h?llo
would match hello
or hallo
as well as Hello
or Hallo
(and many more like heLLo
or HELLO
).
--include=~/^someaff300\.\*\.mycorp\.
This pattern will match any certificate name for the host someaff300
in any subdomain or any domain of mycorp
. The trick here is that the asterisk (*
) in the certificate name is already a wildcard, so you have to use it literally in the regex by escaping it with a backslash. The same goes for the dots in the certificate name.
Examples of matching strings (certificate names):
someaff300.*.mycorp.com_884C38B8836B84827A84EDE41D5234.someaff300
someaff300.*.mycorp.com_1234567890.someaff300
someaff300.*.mycorp.at_884C38B8836B84827A84EDE41D5234.someaff300
Wikipedia: Regex-Syntax (quiet basic)