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

remove "bc" as dependency in check-swap-percent.sh #50

Closed losisin closed 7 years ago

losisin commented 7 years ago

It should be done as it is in check-memory-percent.sh. bc command is not installed by default on some systems. I've already rewritten it for my installation of Sensu and I can create pull requests.

majormoses commented 7 years ago

Agreed, there are many checks in this repo that are very linux specific (and specific to the version). I am kinda tempted to say we should rewrite in pure ruby (using vmstat).

I feel like it would not take much effort to write this up here is an example of the data:

irb(main):004:0> Vmstat.snapshot.disks
=> [#<struct Vmstat::LinuxDisk type=:ext4, origin="/", mount="/", block_size=4096, free_blocks=31773335, available_blocks=28769227, total_blocks=59025600>]
losisin commented 7 years ago

@majormoses : ruby-vmstat way would be replacing one dependency with 2 more (ruby-vmstat + vmstat) and even then swap is not yet supported. But I totally agree that it should be rewritten in ruby to avoid different shell environments. I already changed check-swap-percent.sh and you can see it here: https://gist.github.com/losisin/188c958132bb12b51fe097098df5abce I'm not ruby expert, but I did rewrite it in pure ruby also: https://github.com/losisin/sensu-plugins-memory-checks/blob/master/bin/check-swap-percent.rb I did run rubocop on it and I don't see anything out of the ordinary. Swap usage was tested using stress command. Let me know which one you prefer, so that I can create PR.

majormoses commented 7 years ago

@losisin makes sense, I do prefer the second one as it is in ruby and only relies for a single shell out to get the information.