Numeric Calculations in SNMP Monitors

Recently one of our customers asked how to do calculations in the expressions in an SNMP monitor. It’s not obvious, so we thought others might find this information useful.
For this example, let’s look at the CPU usage in a router. We want to ensure that the combined usage for User and System time is less than 80%. This is a simple example just using two variables but will be enough to show how to do much more complex calculations.
To monitor this condition, we need to collect the data for the two variables. We selected the variables using the Browse button and added them to the list. We are going to use the same two variables for the second probe, so by specifying no variables for the second probe, the software will use the same variables from the first probe.

The wizard pages for Target, Identify, Run As and Schedule are not important for this example, so we will skip over to the first Expression page.

The default expression is that the variables should equal their current values. That’s fine for state variables, but for performance metrics we need something different. But we need to remember that monitors always want an expression that evaluates to true or false. Let’s just delete the default expression. Click on the Delete button.
With no expression we need to add a new expression. The Add button gives us several choices, and in this case, we are going to select Simple Expression.

The dialog for a simple expression allows you to select a single variable, a relationship, and a value. We will get started by selecting one of the variables and the correct condition (< 80%).

When we click OK, we get the following:

This isn’t exactly what we need, but it’s a good start. We need to replace the variable with the sum of the two variables. So, let’s delete the variable:

Now, with Less than selected, click on Add, Numeric, and Addition:

That results in:

With Add selected, select Add, Numeric XPath Query, and select the first variable. Repeat for the second variable. When done, it should look like this:

And now we have the desired numeric expression for the monitor. Clicking Next will produce the inverse expression for the second expression. Then you can complete the wizard and your monitor is defined correctly.
Let us know if this helps or if you have any suggestions.