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

bin/check-ram.rb: Modify script to use /proc/meminfo not "free" #7

Closed andyshoe closed 9 years ago

andyshoe commented 9 years ago

Its more efficient to access memory information via /proc/meminfo rather than calling the "free" command via a shell. Note that MemAvailable is a more accurate indicator of free memory, but older Linux kernels don't support this. For older kernels the traditional free+buffers+cache approach is taken.

Also, the format of the "free" command output has changed between certain linux versions (notably CentOS 6 and 7). So the original method using "free" is broken in that regard as well.

This runs in my tests, but please note that I am not a ruby developer and this is literally the first piece of ruby code I have written. Enjoy!

sge-babrams commented 9 years ago

@andyshoe I have a PR open which among several things removes the shell call out to free command replacing it with the vmstat gem which allows it to work on more *nix platforms. Any feedback on improvement would be valuable: https://github.com/sensu-plugins/sensu-plugins-memory-checks/pull/6

mattyjones commented 9 years ago

Closing this, using proc is not platform agnostic. If we are going to get rid of free I would like to find a way to also include windows not jus *nix. Absent that vmstat is the way to go.