Closed dimon222 closed 7 years ago
Interesting, it does look significantly different from my Debian output:
Perhaps, we should use OS dependent solution? Is there example for other platforms by any chance? I pretty much expect same behavior from Ubuntu (like I have), but not sure about the rest distributions.
Seems good solution to make it os dependant. Just need to check this on a few servers. Got a few opensuse servers too. Might take a week.
@dimon222 Ok, I found some time to further test this. It still wasn't ok for CentOS / Red Hat. Changed it to this now where I make the sum of buff/cache and used:
if [[ "$(jq -r ".Release.Value" $ExportFile)" =~ (^CentOS*|^Red*) ]] ; then
# CentOS based distributions
MemBuffCacheB="$(free | awk '/Mem:/ { print $6 }')"
MemFreeUsedB="$(free | awk '/Mem:/ { print $3 }')"
MemUsedB=$(echo "$MemBuffCacheB+$MemFreeUsedB" | bc)
MemFreeB="$(free | awk '/Mem:/ { print $4 }')"
else
# Debian based distributions and possibly others (?)
MemFreeB="$(free | grep buffers/cache | awk '{print $4}')"
MemUsedB="$(free | grep buffers/cache | awk '{print $3}')"
fi
If you create a new pr with the above I'll accept. Please also change the version number for me. Tx
No worries, I added your change and rebased code for cleaner merge of tree.
Actually, after small investigation I found out that its not system dependent but rather procps version related. The two-line format is fresh new notation that seem to come beginning version 3.3.10.
Source: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=798994
I updated my changes with check of /usr/bin/free version instead of check of OS distributive (which seem to be unrelated). Can you rerun test? My Debian is working with its 3.3.9 detection.
Nice find @dimon222 , and nice VersionComparison function. I'll double check asap.
Found condition bug, fixed + rebased again. Should be working correctly for you now.
Basically solution for #57