#565 check_nt incorrectly calculates percentage values leading to

open
nobody
None
5
2012-07-31
2012-07-31
Cálestyo
No

Hi.

This is from the old / soon to be disabled again Nagios Plugins bug tracker that used to be at Nagios itself.
I've just copied this bug over. I'm not the original reporter and have no idea about the thoughts about this bug.

This used to be: http://tracker.nagios.org/view.php?id=126
--------------------------------------------------------------------------------
mmelin:
--------------------------------------------------------------------------------
This problem was discovered and reproduced when using check_nt against a NSClient++ 0.3.7.493 2009-10-12 checking drive size with USEDDISKSPACE.

When given "-w 98% -c 99%" as WARNING/CRITICAL values, check_nt will not return CRITICAL when disk usage transitions from 98% usage to 99% usage.

This was reproduced and verifed by creating a RAM disk 8 MB in size, then filling it with garbage data to only have 64K bytes free.

At the time of testing, this was the drive statistics as reported by Windows Explorer:

8192512 bytes total size
65536 bytes free

65536 / 8192512 = 0.0079 = 7.9%

First, verification that the Nagios host sees the correct disk and values by using check_nrpe and this NRPE Handler:

USEDDISKSPACE=inject CheckDriveSize ShowAll=long Drive=E:\ MaxWarn=98% MaxCrit=99%

As expected the output is this:

root@support-mon-gbg:~# /opt/plugins/check_nrpe -H 172.16.141.179 -c USEDDISKSPACE
CRITICAL: E:\: Total: 7.81M - Used: 7.75M (99%) - Free: 64K (1%) > critical|'E:\'=99%;98;99;
root@support-mon-gbg:~# echo $?
2

Now for the fun part.

check_nt with 99% critical:

root@support-mon-gbg:~# /opt/plugins/check_nt -H 172.16.141.179 -p 1248 -v USEDDISKSPACE -l E -w 98% -c 99%
E:\ - total: 0.01 Gb - used: 0.01 Gb (99%) - free 0.00 Gb (1%) | 'E:\ Used Space'=0.01Gb;0.01;0.01;0.00;0.01
root@support-mon-gbg:~# echo $?
1

check_nt with 98.99% critical:

root@support-mon-gbg:~# /opt/plugins/check_nt -H 172.16.141.179 -p 1248 -v USEDDISKSPACE -l E -w 98% -c 98.99%
E:\ - total: 0.01 Gb - used: 0.01 Gb (99%) - free 0.00 Gb (1%) | 'E:\ Used Space'=0.01Gb;0.01;0.01;0.00;0.01
root@support-mon-gbg:~# echo $?
2

--

Workaround is to use check_nrpe with CheckDriveSize.

Discussion