Move shared memory accounting from "cached" to "used" dimension (#10183)
* Move shared memory accounting from "cached" to "used" dimension Co-authored-by: Ilya Mashchenko <ilya@netdata.cloud>
Markos Fountoulakis committed
Nov 6, 2020 at 14:43 UTC
a9d02495c799b560289ccb14d036a44edca7dacc
1 file changed
+4
-5
collectors/proc.plugin/proc_meminfo.c
+4
-5
@@ -35,7 +35,7 @@ int do_proc_meminfo(int update_every, usec_t dt) {
35
Writeback = 0,
36
//AnonPages = 0,
37
//Mapped = 0,
38
- //Shmem = 0,
38
+ Shmem = 0,
39
Slab = 0,
40
SReclaimable = 0,
41
SUnreclaim = 0,
@@ -92,7 +92,7 @@ int do_proc_meminfo(int update_every, usec_t dt) {
92
arl_expect(arl_base, "Writeback", &Writeback);
93
//arl_expect(arl_base, "AnonPages", &AnonPages);
94
//arl_expect(arl_base, "Mapped", &Mapped);
95
- //arl_expect(arl_base, "Shmem", &Shmem);
95
+ arl_expect(arl_base, "Shmem", &Shmem);
96
arl_expect(arl_base, "Slab", &Slab);
97
arl_expect(arl_base, "SReclaimable", &SReclaimable);
98
arl_expect(arl_base, "SUnreclaim", &SUnreclaim);
@@ -145,8 +145,8 @@ int do_proc_meminfo(int update_every, usec_t dt) {
145
146
// --------------------------------------------------------------------
147
148
- // http://stackoverflow.com/questions/3019748/how-to-reliably-measure-available-memory-in-linux
149
- unsigned long long MemCached = Cached + SReclaimable;
148
+ // http://calimeroteknik.free.fr/blag/?article20/really-used-memory-on-gnu-linux
149
+ unsigned long long MemCached = Cached + SReclaimable - Shmem;
150
unsigned long long MemUsed = MemTotal - MemFree - MemCached - Buffers;
151
152
if(do_ram) {
@@ -526,4 +526,3 @@ int do_proc_meminfo(int update_every, usec_t dt) {
526
527
return 0;
528
}
529
-