-
Notifications
You must be signed in to change notification settings - Fork 50
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-memory-percent.sh not returning correct values for Linux systems #82
Comments
Even that isn't really correct. A while back the kernel developers got tired of people calculating free memory with calculations like these, and so they added info into I'm not sure why that wasn't done when the metrics were changed in #68. @jpoizat @majormoses can you comment? |
(If the reason is just "because we didn't", btw, then I might find some time to port this over since it's something that's bugging me.) |
I have not had a time to fully review the code but I suspect some of this is because any time we try to manually parse output from a tool which does not historically cared about maintaining the consistency of the output from version to version.
on 18.04:
Here we see the string that we are searching for is different, data in a row moved to a column, when no swap is present the line is omitted, etc making it difficult to handle all of the various versions. On top of this the OS (kernel) changes how it reports memory, this is something that we see also with I am all for improving the existing check and if there is a bug we should fix it. We just need to fix it so that it does not break systems where it is properly reporting correctly. It's easy to say its broken for me so it must be broken for everyone but let's remember to take a step back and check if its working for other systems/platforms before deciding that the code is fundamentally flawed. There is certainly more work that could be done to handle all those differences in platform, kernel, version of |
@xiongchiamiov I can't speak to why it was not done for the check script and only the metric script as I was not the submitter but I can assume he did not use this check. I did ask if he wanted to roll out similar functionality but got no response. I am more than happy to accept another contribution to get that updated but I would not turn away a perfectly good contribution just because I want to keep each of the x number of check/metric scripts for memory in sync. In fact I would argue the fact that we have multiple checks means that different people have different preferences and needs. I personally use https://github.com/sensu-plugins/sensu-plugins-memory-checks/blob/master/bin/check-ram.rb as it uses some lower level hooks than simply parsing a file or stdout/stderr but requires a compiler as it leverages a c extension for the heavy lifting and provides the best xplatform compatibility I have seen. That being said requiring a compiler on a production system is a non starter for some orgs and they prefer to do the parsing at a file/command layer despite that it is more prone to errors and incorrect information. If I change the output of the If someone wants to tackle switching from |
@xiongchiamiov it looks like someone attempted to try it but then did not respond to my feedback about them breaking systems where it was not needed: #60 If you are willing to work with me I am more than happy to get it over the line. |
Thanks for all the info. I'm going to poke at using |
FWIW, I am using both Ubuntu 16/18 and CentOS 7 systems.
So near as I can tell this issues is caused by an incorrect parsing of the values returned by the free -m command as well as not calculating the free memory correctly.
Using the following output from the free -m command as an example,
The following code does not make much sense:
The first issue is where the code attempts to set the value for FreeMem.
This command:
However, this is also an issue as is it not the full picture of the free memory on the system.
FreeMem should be defined as:
Free Memory = Free + Buffers + Cached
So, using the the example data above we would have
Free Memory = Free (224 MB) + Buffers & Cache (812) = 1,036 MB.
A possible solution might look something like this:
Thank you for your effort on this project,
-Thomas
EDIT BY @majormoses: used triple backticks to form code blocks so its easier to read
The text was updated successfully, but these errors were encountered: