Expressions
Expressions are used for the filter, warning, critical and ok arguments.
Syntax
The basic syntax is <attribute> <operator> <value>. For a list and explanation
of allowed operators see the operator list.
The list of possible attributes is documented along with each check plugin.
For example:
filter="status = 'started'"
critical="count >= 1"
Logical Operators
To combine multiple expressions you can use logical operators and brackets.
| Operator | Alias | Description | Example |
|---|---|---|---|
and | && | Logical and operator | count = 0 and state != 1 |
or | || | Logical or operator | used > 5 or free < 20 |
For example:
filter="(status = 'started' or status = 'pending') and usage > 5%"
Operators
| Operator | Alias / Safe expression | Types | Case Sens. | Description |
|---|---|---|---|---|
= | ==, is, eq | Strings, Numbers | Yes | Matches on exact equality, e.g. status = 'started' |
!= | is not, ne | Strings, Numbers | Yes | Matches if value is not exactly equal. For example: 5 != 3 |
like | ilike | Strings | No | Matches if value contains the condition (case-insensitive substring match), e.g. status like "pend" |
unlike | not like, not ilike | Strings | No | Matches if value does not contain the case-insensitive substring, e.g. status unlike "stopped" |
slike | strictlike | Strings | Yes | Matches a case-sensitive substring, e.g. name slike "WMI" |
not slike | not strictlike | Strings | Yes | Matches if a case-sensitive substring cannot be found, e.g. name not slike "WMI" |
~ | regex, regexp | Strings | Yes | Performs a regular expression match, e.g. status ~ '^pend' |
!~ | not regex, not regexp | Strings | Yes | Performs an inverse regular expression match, e.g. status !~ 'stop' |
~~ | regexi, regexpi | Strings | No | Performs a case-insensitive regular expression match, e.g. status ~~ '^pend'. An alternative way is to use //i as in status ~ /^pend/i |
!~~ | not regexi, not regexpi | Strings | No | Performs an inverse case-insensitive regular expression match, e.g. status !~~ 'stop' |
< | lt | Numbers | - | Matches values less than the specified value, e.g. usage < 5% |
<= | le, lte | Numbers | - | Matches values less than or equal to the specified value, e.g. usage <= 5% |
> | gt | Numbers | - | Matches values greater than the specified value, e.g. usage > 5% |
>= | ge, gte | Numbers | - | Matches values greater than or equal to the specified value, e.g. usage >= 5% |
in | Strings | Yes | Matches if the value is in the list, e.g. status in ('start', 'pending') | |
not in | Strings | Yes | Matches if the value is not in the list, e.g. status not in ('stopped', 'starting') |
Other Operators
For backwards compatibility there are more operators available:
| Operator | Alias | Description | Example |
|---|---|---|---|
'' | str() | String constant | exe like str(winlogon.exe) |
Date Keywords
For attributes representing a date or timestamp, the following keywords can be used as values:
| Keyword | Description |
|---|---|
today | Start of the current day (00:00:00 local time) |
thisweek | Start of the current week (Monday 00:00:00 local time) |
thismonth | Start of the current month (1st, 00:00:00 local time) |
thisyear | Start of the current year (Jan 1st, 00:00:00 local time) |
Each keyword can be suffixed with :utc to use UTC time instead of local time, e.g., today:utc.