sensu-plugins / sensu-plugins-disk-checks

This plugin provides native disk instrumentation for monitoring and metrics collection, including: health, usage, and various metrics.
http://sensu-plugins.io
MIT License
27 stars 63 forks source link

Calculation of adaptive thresholds wrong? #125

Open corro opened 5 years ago

corro commented 5 years ago

In #14, adaptive thresholds were introduced, which modify the actual warning and critical thresholds according to a "magic factor". This is very useful, but I think the calculation in the code is wrong.

There is a formula in the description:

y = 100 - (100-P)*(N^(1-m))/(x^(1-m))

According to this formula, a threshold of 75% for a disk of 400GB (normalization factor 50 and magic number 0.8) should be raised to ~83.5%:

y = 100 - (100-75)*(50^(1-0.8))/(400^(1-0.8)) = ~83.50

But actually it is raised to ~95.9%, which is way too high.

My suspicion is, that there is a confusion of units in the following line: https://github.com/sensu-plugins/sensu-plugins-disk-checks/blob/master/bin/check-disk-usage.rb#L144 The disk size in bytes passed to adj_percent is converted to mebibytes instead of gibibytes. I think it should be divided by 1024**3 instead.

I stumbled upon this because we were alerted of a shortage in disk space later than we expected. Can anyone confirm this issue?

mlachal commented 3 years ago

Hi, we have the same issue and used -n 20480 as a workaround.