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

the MemAvailable information incorrect ( linux kernel < 3.14) #633

Closed
1 task done
mikezsin opened this issue Jan 23, 2019 · 2 comments
Closed
1 task done

the MemAvailable information incorrect ( linux kernel < 3.14) #633

mikezsin opened this issue Jan 23, 2019 · 2 comments

Comments

@mikezsin
Copy link

mikezsin commented Jan 23, 2019

Describe the bug
if !memavail {
ret.Available = ret.Free + ret.Buffers + ret.Cached
}
it is wrong way to calculate MemAvailable

To Reproduce

for example, postgres shared_buffers may be reported under "Cached"

Expected behavior
bash version

LOW_WATERMARK=$(awk '$1 == "low" {LOW_WATERMARK += $2} END {print LOW_WATERMARK * 4096}' /proc/zoneinfo)

MEMINFO=$(</proc/meminfo)

MEMINFO_MEMFREE=$(echo "${MEMINFO}" | awk '$1 == "MemFree:" {print $2 * 1024}')
MEMINFO_FILE=$(echo "${MEMINFO}" | awk '{MEMINFO[$1]=$2} END {print (MEMINFO["Active(file):"] + MEMINFO["Inactive(file):"]) * 1024}')
MEMINFO_SRECLAIMABLE=$(echo "${MEMINFO}" | awk '$1 == "SReclaimable:" {print $2 * 1024}')

MEMINFO_MEMAVAILABLE=$((
  MEMINFO_MEMFREE - LOW_WATERMARK
  + MEMINFO_FILE - ((MEMINFO_FILE/2) < LOW_WATERMARK ? (MEMINFO_FILE/2) : LOW_WATERMARK)
  + MEMINFO_SRECLAIMABLE - ((MEMINFO_SRECLAIMABLE/2) < LOW_WATERMARK ? (MEMINFO_SRECLAIMABLE/2) : LOW_WATERMARK)
))

if [[ "${MEMINFO_MEMAVAILABLE}" -le 0 ]]
then
  MEMINFO_MEMAVAILABLE=0
fi

Environment (please complete the following information):

  • Linux: [< 3.14]
@Lomanic
Copy link
Collaborator

Lomanic commented Jan 24, 2019

This will be fixed when #626 is merged.

@Lomanic
Copy link
Collaborator

Lomanic commented Mar 4, 2019

PR was merged.

@Lomanic Lomanic closed this as completed Mar 4, 2019
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

2 participants