Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

check-swap-percent.rb fails on FreeBSD #43

Open
inferiorhumanorgans opened this issue Aug 21, 2016 · 17 comments
Open

check-swap-percent.rb fails on FreeBSD #43

inferiorhumanorgans opened this issue Aug 21, 2016 · 17 comments

Comments

@inferiorhumanorgans
Copy link

/opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-memory-checks-1.0.2/bin/check-swap-percent.rb:6:in `exec': No such file or directory - /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-memory-checks-1.0.2/bin/check-swap-percent.sh (Errno::ENOENT)
    from /opt/sensu/embedded/lib/ruby/gems/2.3.0/gems/sensu-plugins-memory-checks-1.0.2/bin/check-swap-percent.rb:6:in `<main>'
@majormoses
Copy link
Member

@inferiorhumanorgans I see that we rewrote that check anyways, can you test it against master?

@majormoses
Copy link
Member

might be fixed with just a release which has been requested in #54

@eheydrick
Copy link
Contributor

2.0.0 has the rewritten swap check. Can you try that and feel free to reopen if still a problem.

@inferiorhumanorgans
Copy link
Author

Well free(1) is Linux only, so I can't imagine it works.

@majormoses
Copy link
Member

@inferiorhumanorgans correct sorry I didnt look inside to see that it was simply shelling out for free to get that, we should look into a cross platform way to do this.

@majormoses
Copy link
Member

@eheydrick please repopen

@eheydrick eheydrick reopened this Jan 19, 2017
@inferiorhumanorgans
Copy link
Author

This might be a good way to go:

https://github.com/threez/ruby-vmstat

@majormoses
Copy link
Member

@inferiorhumanorgans I used that one for cross platform ram checking, looks like there was some stuff just merged using /proc/meminfo assuming you have that on your *nix system if I get some time next week to take a look at it I will.

@inferiorhumanorgans
Copy link
Author

procfs is pretty much always guaranteed to be platform dependent.

majormoses added a commit to majormoses/sensu-plugins-memory-checks that referenced this issue Mar 10, 2017
- switches `free` to read from `/proc/swaps` which is more platform agnostic
majormoses added a commit to majormoses/sensu-plugins-memory-checks that referenced this issue Mar 10, 2017
- switches `free` to read from `/proc/swaps` which is more platform agnostic
@majormoses majormoses mentioned this issue Mar 10, 2017
8 tasks
@majormoses
Copy link
Member

@inferiorhumanorgans can you check out #57 and see if that works for you? Its certainly rough around the edges but wanted to see if I could just get something working for you.

@inferiorhumanorgans
Copy link
Author

inferiorhumanorgans commented Mar 10, 2017

$ uname -sr
FreeBSD 10.3-RELEASE-p11
$ file /proc/swaps
/proc/swaps: cannot open `/proc/swaps' (No such file or directory)
$ uname -sr
Darwin 13.4.0
$ file /proc/swaps
/proc/swaps: cannot open `/proc/swaps' (No such file or directory)

I'd suggest using an existing abstraction layer. Procfs is inherently operating system dependent and rarely (if ever) considered cross-platform. ruby-vmstat that I linked to above is MIT licensed and claims explicit support for:

  • FreeBSD
  • MacOS X
  • Linux (>= 2.6)
  • OpenBSD
  • NetBSD
  • Solaris/SmartOS

@majormoses
Copy link
Member

@inferiorhumanorgans sorry I misread your initial comment. Agreed, however I checked and the vmstat did not look like it had swap support unless I am missing something.

@inferiorhumanorgans
Copy link
Author

Ah, true. However, the same problems apply to the other memory checks in this repo as it looks like they rely on free(1).

@majormoses
Copy link
Member

I did find this: https://github.com/djberg96/sys-filesystem that does work except that it does not detect swap so if we can detect all the swap paths/devices then we could use that. I will dig more when I have some more free time.

@majormoses
Copy link
Member

@inferiorhumanorgans check-ram uses vmstat gem and does not rely on free but yes I totally agree and would love to invest time when I have it if I can find a reasonable path.

@inferiorhumanorgans
Copy link
Author

Yeah, I'd go for some/more coverage especially as the vmstat gem is already being used here and checking swap info is well within scope per their readme.

@majormoses
Copy link
Member

yup it looks like its on the todo list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants