Regular Expressions for Monitoring Plugin Configuration

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.


--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

What are Regular Expressions?

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.

Regex for Nagios Plugins

The regex-syntax has thousands of different metacharacters. Following the most important if you are going to configure your monitoring system with our plugins.

Monitoring-Plugin’s most important regex notations

Dots (. 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.

Dot Examples

Checks volumes, which are on vserver vserv1 (but not on eg. vserv10 or vserv199).
Matching volume-names would be:
--include=^vsrv1. (without the backslash in front of the dot)
Checks volumes, which are on vserver vserv1 but also the ones whose vserver-name starts with vserv1 eg. vserv10 or vserv199.

Matching volume-names would be:


Anchors - begin and end of string (^ 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.

Anchoring Examples

Checks volumes, which have vserv1 somewhere in their name.
Matching volume-names would be:

The above example, without any anchor, is most likely not useful in practice. It is mainly an example of how not to do it.

We know this example already from the explanation on how to match a literal dot. This is a good example on how to successfully check instances on a single vserver only.
Checks any volume as long as they do not end with .temp.

Ignore Case

To match a string while ignoring the case of its letters, prefix (?i) to the pattern.

Example for ignoring the case

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).

Useful Web-Sources about Regular Expressions

Wikipedia: Regex-Syntax (quiet basic)

Regular Expressions Tutorial und References

Go Regular Expressions Syntax