sensu-plugins / sensu-plugins-memory-checks

This plugin provides native memory instrumentation for monitoring and metrics collection, including: memory usage via `free` and `vmstat`, including metrics. Note that this plugin may have cross-platform issues.
http://sensu-plugins.io
MIT License
15 stars 50 forks source link

Fix memory calculation when < 1% of memory is free #24

Closed brandt closed 8 years ago

brandt commented 8 years ago

When memory dipped below 1% free, check-memory-percent.sh returned "MEM UNKNOWN" instead of "CRITICAL".

The reason is because bc returns floating point values without a leading zero by default.

Example:

[brandt@absinthe ~]# echo "scale=3; 1 / 1000 * 100" | bc -l| cut -d "." -f1

[brandt@absinthe ~]#

To fix this, I've substituted bc for awk.

This also makes the check work out-of-the-box on CentOS Minimal (bc is not included by default, but awk is).

brandt commented 8 years ago

The tests appear to have failed for reasons unrelated to these changes.

analytically commented 8 years ago

Can you rebase?

brandt commented 8 years ago

@analytically sure. It will be a non-ff change because of the conflicting modification of CHANGELOG.md, so I'll open a new PR.