Regular Expressions

Nagstamon allows the use of regular expressions for filtering hosts and services for status popup and actions. Detailed information can be found at https://docs.python.org/howto/regex.html.

Regexp filter settings can be found in filters tab and in actions:

regexps-1

1. Example: Host filter

If the default list of hosts looks like this…

regexps-2

…and you for whatever reason have to filter out a certain group of hosts, for example all hosts with centos in its name, you add this filter…

regexps-3

…and the list of host gets shorter…

regexps-4

2. Example: Reverse host filter

If you need to see only the hosts of a certain type, for example only hosts with “www” in its name, just add the “reverse” option…

regexps-5

and monitor only the hosts you are interested in:

regexps-6

3. Example: Multiple Service filters

Surprisingly filters for services work in a similar way. To raise the level of complexity a little bit in this example there should be only shown Sendmail or DNS services. Multiple items get concatenated with “|”, so the filter looks like this:

regexps-7

The resulting list is shorter:

regexps-8

4. Example: More regular expressionism

The above examples are pretty simple. If you need more sophisticated filters here are some more rules:

  • ^ marks the beginning of an expression
  • $ marks the end
  • . is any character
  • .* is any number of any character
  • | adds several expressions with logical OR

For further information please see https://docs.python.org/howto/regex.html.