Check_swap calculates percent utilization weird

We use check_swap to monitor the swap utilization of servers. I noticed that the utilization swaps between 0% and 1% although the absolute value does not change.

SWAP CRITICAL - 1% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047
SWAP CRITICAL - 1% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047
SWAP CRITICAL - 1% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047
SWAP CRITICAL - 1% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047
SWAP CRITICAL - 0% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047
SWAP CRITICAL - 0% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047
SWAP CRITICAL - 0% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047
SWAP CRITICAL - 0% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047

Yes, the 0 MB are real, the memory management of that server is definitely improvable. I’m just wondering, why check_swap calculates the percent utilization differently, although the absolute value does not change. This is the check_swap from nagios-plugins 2.3.3.

I’d assume the absolute value is sometimes not exactly 0. The percentage become 1% while MB value is rounded down to 0 MB.

OK, correct.

Thu Feb 16 09:55:06 CET 2023
              total        used        free      shared  buff/cache   available
Mem:      528109092   495944940     6610492     9102660    25553660    19699080
Swap:       2097148     2097084          64
SWAP CRITICAL - 1% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047
Fri Feb 17 05:36:36 CET 2023
              total        used        free      shared  buff/cache   available
Mem:      528109092   493527148     2527060     9102656    32054884    22082488
Swap:       2097148     2097148           0
SWAP OK - 0% free (0 MB out of 2047 MB) |swap=0MB;204;102;0;2047

It says 0MB free, b/c it can’t express the 64Kb free in MBytes. 64KB out of 2097148KB are not really 1% free, I’d expect that is still says 0% free, which would lead to less confusion…