I use the status() function with Boolean operators to control the status of my Sensor Factory sensor. Can you help me understand when the Sensor Factory sensor changes to the down status and why?
Can you help me understand when the Sensor Factory sensor changes to the down status and why?
Votes:
0
1 Reply
Votes:
2
This article applies as of PRTG 22
TRUE and FALSE in the Sensor Factory status() function
With the help of the Sensor Factory sensor, you can build your very own custom sensor that determines its status by using the states of any source sensor(s) in your network (except other Sensor Factory sensors).
To define your custom Sensor Factory channels, use one of the numerous channel functions that PRTG offers.
To define when you want your Sensor Factory sensor to show the down or up status, and, consequently, when notifications are triggered, use the status() function.
To set your status definitions for the Sensor Factory sensor, follow these steps:
- Open the Settings of your Sensor Factory sensor.
- In the Status Handling section, select Use Custom Formula.
- In the Status Definition field, enter the status() function according to your needs.
Note: When using the sensor status() function, you can decide on the up and down status, but not on the warning status. The warning status is not available by design.
A note on down condition and up condition in PRTG
Sensors in PRTG can have different states that are displayed with different colors, like up (green), warning (yellow), and down (red). (See all PRTG sensor states in the PRTG User Manual.)
Because highly flexible do-it-yourself sensors like the Sensor Factory sensor or the Business Process sensor refer to other sensors, there needs to be a basis for the calculation of the overall sensor status.
Therefore, the sensor states of the source sensors have to be resolved to the up or down condition first. This happens on a kind of meta level that consolidates all possible sensor states to either up or down.
Example:
sensor states | condition | truth | Sensor Factory status | |
---|---|---|---|---|
up, warning, unusual | resolve to | up | FALSE | up |
down, down (acknowledged), paused | resolve to | down | TRUE | down |
The overall up or down condition of a sensor that summarizes other sensor states is then resolved to an overall sensor status to be displayed with different colors in the PRTG user interfaces, following the sensor logic.
Find all Up and Down Conditions in the PRTG Manual.
The status() function of the Sensor Factory sensor
This section guides you through the boolean logic behind the status() function and provides some examples.
How TRUE and FALSE correlate to DOWN and UP
The status() function checks if conditions are met to set the Sensor Factory sensor to down.
If the status() function of the sensor resolves to TRUE, the sensor shows the down status. If the status() function resolves to FALSE, the sensor shows the up status.
If you have only one sensor as source in your Sensor Factory sensor and if this source sensor is in the down status, the Sensor Factory sensor is in the down status, too. Because the down condition is TRUE. Likewise, a single sensor in up condition corresponds to FALSE and the Sensor Factory sensor shows the up status.
Of course, you will most probably want to use the advantage of the formulas of the Sensor Factory sensor and combine several source sensors.
Boolean operators in the status() function
If you have more sensors as source sensors for the Sensor Factory sensor and so more arguments for the status() function, PRTG needs to calculate the overall status result for the down or up status.
The overall result of the status() function depends on the logical operators that you use. The arguments are your source sensors. These are the boolean operators you can use:
- AND (conjunction)
- OR (disjunction)
- NOT (negation)
Truth table for AND considering 2 arguments:
Arguments combined with AND | Result |
---|---|
TRUE AND TRUE | TRUE |
TRUE AND FALSE | FALSE |
FALSE AND TRUE | FALSE |
FALSE AND FALSE | FALSE |
Truth table for OR considering 2 arguments:
Arguments combined with OR | Result |
---|---|
TRUE OR TRUE | TRUE |
TRUE OR FALSE | TRUE |
FALSE OR TRUE | TRUE |
FALSE OR FALSE | FALSE |
Truth table for NOT:
Arguments combined with NOT | Result |
---|---|
NOT TRUE | FALSE |
NOT FALSE | TRUE |
There are two possibilities to use NOT:
- Use AND NOT or OR NOT to combine a NOT-expression with other status() functions, for example
status(1) AND NOT status(2)
- Use NOT as a prefix, for example
NOT status(1) OR status(2)
In any case, when calculating the overall status, resolve the NOT part first. For example:
true AND NOT true = true AND (NOT true) = true AND false = false |
Illustration
To illustrate how the status() function works, we will use the values of a humidity sensor and a temperature sensor combined as source sensors in a Sensor Factory sensor that monitors, for example, the environment of your server room.
These are the source sensors:
This is the Sensor Factory sensor:
This is its channel definition:
Basic examples
1. “I want the Sensor Factory sensor to show the DOWN status only if ALL source sensors are in the DOWN status.”
To achieve this, you could use the following status() function:
status(sensorID1) AND status(sensorID2)
Example 1: source sensors
Example 1: status() function with 2 arguments combined with AND
Sensor | “Temperature” (source) | “Humidity” (source) | “Server Room Environment” (Sensor Factory) |
---|---|---|---|
Status | down | down | down |
Condition | down | down | down |
Truth | TRUE | TRUE | TRUE |
Example 1: Sensor Factory sensor
2. “I want the Sensor Factory sensor to show the UP status if at least ONE source sensor is in the UP status”.
To achieve this, you could use the following status() function:
status(sensorID1) AND status(sensorID2)
Example 2: source sensors
Example 2: status() function with 2 arguments combined with AND
Sensor | “Temperature” (source) | “Humidity” (source) | “Server Room Environment” (Sensor Factory) |
---|---|---|---|
Status | down | warning | up |
Condition | down | up | up |
Truth | TRUE | FALSE | FALSE |
Example 2: Sensor Factory sensor
3. “I want the Sensor Factory sensor to show the DOWN status only if ALL source sensors are in the UP status.”
To achieve this, you could use the following status() function:
NOT status(sensorID1) AND NOT status(sensorID2)
Example 3: source sensors
Example 3: status() function with 2 negated arguments combined with AND
Sensor | “Temperature” (source) | “Humidity” (source) | “Server Room Environment” (Sensor Factory) |
---|---|---|---|
Status | up | up | down |
Condition | up | up | down |
Truth | TRUE (NOTFALSE) | TRUE (NOT FALSE) | TRUE |
Example 3: Sensor Factory sensor
With this boolean syntax you can change your Sensor Factory sensor to the down status even if all source sensors are in the up status. Whether this behavior is desirable for you or not depends on what you monitor and how you define up and down. For example, you might have two servers and you define the write access as up. You want only one of your servers to have write access. With the status() function in example 3, PRTG alarms you when both servers get write access.
Combine boolean operators
You can further customize the status calculation of your Sensor Factory sensor by combining different Boolean operators in one status() function.
Use brackets to group your calculation steps. For example:
status(sensorID1) OR (status(sensorID2) AND status(sensorID3))
Before actually setting up this kind of monitoring, have your boolean matrix ready first ;-)
Wrap up
The Sensor Factory sensor status() function follows the boolean logic, that is, it operates with the conditions TRUE and FALSE.
The down condition of a source sensor corresponds to TRUE. The up condition of a source sensor corresponds to FALSE.
You can combine more arguments with the boolean operators AND, OR, and/or NOT.
The overall status of the Sensor Factory sensor is calculated depending on the conditions of your source sensors and on the boolean operators that you use.
Other
Do not forget to set the notifications, so PRTG alarms you when you need to be alarmed.
More
Created on May 14, 2018 5:26:33 PM by
Martina Wittmann [Paessler Support]
Last change on Dec 29, 2022 1:21:06 PM by
Brandy Greger [Paessler Support]
Add comment