Good Practices: Virtual metrics – Part 1

This post is also available in: French

Today, you use Centreon to monitor the reliability of your IT and to alert you during a break in service. But how to predict future alerts of services or indicators?
It would be nice to provide that in a month, the disk will be full or in two weeks, the maximum number of users on your web server may be reached, etc.

Note that it is possible to create curves forecast on the use of disk space, memory and CPU usage, etc. These curves allow you to make forecasts on specific indicators, but not only!

Indeed if you want to configure the ninety-fifth percentile, you can do this with the virtual metric.
In this article we will see how to use virtual metrics to create forecast curves in Centreon.

To create virtual metrics in Centreon, you must go into the menu of virtual metric in Views> Graphs> Metrics.

To create forecast curves, we will use RPN (Reverse Polish Notation) from RRDtool.
The idea behind RPN is that you have a stack (or LIFO: Last In, First Out) and you can “push” your data on the stack.
“Push” is done implicitly, whenever you specify a number or a variable, it is automatically pushed onto the stack.

At the end of the calculation, there should be one and only one value left on the stack. This is the result of the function and this is what is put into the virtual name.
For instructions CDEF, the stack is processed for each data point on the graph.
VDEF instructions work on a set of data at one time.

Example: VDEF: maximum = mydata, MAXIMUM
This will set the variable “maximum” you can now use the rest of your script RRD.
Example: CDEF: mydatabits = mydata, 8, *
This means: push variable mydata, “push” 8, run the * operator. The operator needs two elements and uses those that return a value. This value is then stored in mydatabits. As you might have guessed, this statement means nothing more than mydatabits = mydata * 8. For expressions such as a = b + 3 * 5, you must multiply 3 to 5 before adding b. However, with brackets, you can change this order: a = (b + 3) * 5.
In RPN mode, you would be a = b, 3 +, 5 *, without the need for parentheses.

DEF: refers to a set of “raw” data as it is stored in the RRA;
CDEF: Applies a function to each data point it refers;
VDEF: applies a function to a set of data points;
There are a multitude of operators that can be used with RPN. Here are the most used: +, -, *, /, %, IF, A, isinf, LIMIT, MIN, MAX, LSLSLOPE: PERCENT, PERCENTNAN: PREDICT, PREDICTSIGMA, etc.

Examples :



This article is only the first part of the virtual metric, so stay tuned!
In the next article, we are going to practice with concrete examples to set the metrics in Centreon on specific indicators.

Incoming search terms:

  • centreon virtual metrics

Leave a Reply