Many of our monitoring-checks have parameters that expect 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.
Examples:
--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)
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 the expressions components.
The regex-syntax has thousands of different metacharacters. Following the most important if you are going 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
).
Wikipedia: Regex-Syntax (quiet basic)