centreon / centreon-plugins

Collection of standard plugins to discover and gather cloud-to-edge metrics and status across your whole IT infrastructure.
https://www.centreon.com
Apache License 2.0
310 stars 274 forks source link

Interfaces mode in different plugins. Empty values with no maximum threshold #2780

Closed Aleksey-Maksimov closed 3 years ago

Aleksey-Maksimov commented 3 years ago

Hello,

Yesterday I updated the centreon-plugins from the last commit and found one strange thing. The interfaces mode in different plugins began to behave differently than before. When polling the interfaces of the switches, I found that zero values of the incoming and outgoing traffic for the interfaces fall into the perfdata. At the same time, for zero values, the data on the maximum threshold (interface bandwidth) is empty.

Here is an example for any such plugin

# ./centreon_plugins.pl --plugin=network::zyxel::snmp::plugin --mode=interfaces 
--add-traffic --warning-in-traffic=98 --warning-out-traffic=98 --units-traffic='%' 
--add-errors --warning-in-error=1 --warning-out-error=1 
--filter-uom='%' --snmp-version=2 --snmp-community='public' --hostname='SW051'

OK: All interfaces are ok | 

'traffic_in_GigabitEthernet1'=47917.78;0:980000000;;0;1000000000 
'traffic_out_GigabitEthernet1'=11336.00;0:980000000;;0;1000000000 
'packets_discard_in_GigabitEthernet1'=0.00%;;;0;100 
'packets_error_in_GigabitEthernet1'=0.00%;0:1;;0;100 
'packets_discard_out_GigabitEthernet1'=0.00%;;;0;100 
'packets_error_out_GigabitEthernet1'=0.00%;0:1;;0;100 
'traffic_in_GigabitEthernet10'=0.00;;;0; 
'traffic_out_GigabitEthernet10'=0.00;;;0; 
'packets_discard_in_GigabitEthernet10'=0.00%;;;0;100 
'packets_error_in_GigabitEthernet10'=0.00%;0:1;;0;100 
'packets_discard_out_GigabitEthernet10'=0.00%;;;0;100 
'packets_error_out_GigabitEthernet10'=0.00%;0:1;;0;100
...

As far as I remember, earlier if the indicators had a zero value, then they did not fall into the perfdata. And in my opinion, it was so right. Now, a lot of zero garbage is written to the perfdata, and this is probably not good anymore.

Moreover, zero values with an empty maximum threshold value cause all Grafana graphs to stop working for displaying interface utilization, where a function like asPercent(traffic_*.value,traffic_*.max) is used.

Please tell me how to do that with zero values do not fall into perfdata?

garnier-quentin commented 3 years ago

I think we should display a value if it's 0. But i can add an options to skipped counters with 0. It will be ok for you ?

garnier-quentin commented 3 years ago

I can do better. I can add a global option like --filter-perfdata-advanced: can filter perfdata if max value is empty and value is 0.

What do you think about it?

Aleksey-Maksimov commented 3 years ago

I think we should display a value if it's 0

In my opinion, this is a controversial opinion. It doesn't always make sense to store zeros. For example, in our monitoring system, after updating the plugins, the amount of stored data for each large switch increased 2.5 - 3 times. At the same time, the load on Carbon has greatly increased. Previously, when zero values did not get into the perfdata (they skipped by default), we did not experience any problems. So I can’t think of a reason why we need to store many zero values.

If possible, make it possible to skip zero values as it was before. If it is a separate option, then so be it.

Aleksey-Maksimov commented 3 years ago

Hello Quentin. Do you need any more information from me?

garnier-quentin commented 3 years ago

Not it's ok. I wil add that option soon ;)

garnier-quentin commented 3 years ago

It's done ;) You can use: --filter-perfdata-adv='not (%(value) == 0 and %(max) eq "")'

Aleksey-Maksimov commented 3 years ago

Thanks, I'll try. There is another question. Can I use the new "--use-new-perfdata" option to configure all interface monitoring services? Or is this an experimental option and may be removed in the future?

garnier-quentin commented 3 years ago

you can use it. But some modes still need to be updated for new perfdata

Aleksey-Maksimov commented 3 years ago

It's okay now. I could exclude all zero perfdata values with --filter-perfdata-adv = 'not (% (value) == 0)'. Thanks Quentin!

Aleksey-Maksimov commented 3 years ago

Quentin, I'm sorry. There are two more questions. 1) Can the --filter-perfdata-adv option be used multiple times? 2) Please tell me how to build a filter using a specific example: I need to exclude all metrics for which the metric name matches the mask with *.traffic.* and at the same time with the max value is empty (or equal to zero)

garnier-quentin commented 3 years ago
  1. Only one. But you can use OR/AND in that option.
  2. --filter-perfdata-adv='%(label) =~ /\.traffic\./ and (%(max) eq "" or %(max) == 0)'
Aleksey-Maksimov commented 3 years ago

Cool. Thanks, Quentin.

We found that some interfaces on Mikrotik routers and access points have the wrong bandwidth. And this is not regulated in any way on the device. Therefore, we have to filter out such interfaces. We also filter out all metrics that have zero values. The filter ended up being long, but it works.

--use-new-perfdata --filter-perfdata='.*[.](traffic|error|discard)[.].*' --filter-perfdata-adv='(%(label) =~ /\.traffic\./ and not (%(value) == 0 or %(max) eq "" or %(max) == 0)) or (%(label) !~ /\.traffic\./ and not (%(value) == 0 ))'

Hooray!