removing mem.{buffer,cached} fields.
replace with actual_{free,used} fields so we can portably adjust -/+ buffers/cache on linux and perhaps on other platforms w/ different semantics.
This commit is contained in:
parent
41c0ee4f7c
commit
fee5b18641
|
@ -143,8 +143,8 @@ namespace Hyperic.Sigar {
|
||||||
public readonly ulong Used;
|
public readonly ulong Used;
|
||||||
public readonly ulong Free;
|
public readonly ulong Free;
|
||||||
public readonly ulong Shared;
|
public readonly ulong Shared;
|
||||||
private readonly ulong NA_buffer;
|
public readonly ulong ActualFree;
|
||||||
private readonly ulong NA_cached;
|
public readonly ulong ActualUsed;
|
||||||
|
|
||||||
[DllImport(Sigar.LIBSIGAR)]
|
[DllImport(Sigar.LIBSIGAR)]
|
||||||
private static extern int
|
private static extern int
|
||||||
|
|
|
@ -33,8 +33,8 @@ int main(int argc, char *argv[]){
|
||||||
meminfo.buffer / 1024,
|
meminfo.buffer / 1024,
|
||||||
meminfo.cached / 1024);
|
meminfo.cached / 1024);
|
||||||
fprintf(stdout, "-/+ buffers/cache: %10ld %10d\n",
|
fprintf(stdout, "-/+ buffers/cache: %10ld %10d\n",
|
||||||
(meminfo.used - meminfo.buffer - meminfo.cached) / 1024,
|
meminfo.actual_used / 1024,
|
||||||
(meminfo.free + meminfo.buffer + meminfo.cached) / 1024);
|
meminfo.actual_free / 1024);
|
||||||
fprintf(stdout, "Swap: %10ld %10ld %10ld\n",
|
fprintf(stdout, "Swap: %10ld %10ld %10ld\n",
|
||||||
swapinfo.total / 1024,
|
swapinfo.total / 1024,
|
||||||
swapinfo.used / 1024,
|
swapinfo.used / 1024,
|
||||||
|
|
|
@ -75,8 +75,8 @@ typedef struct {
|
||||||
used,
|
used,
|
||||||
free,
|
free,
|
||||||
shared,
|
shared,
|
||||||
buffer,
|
actual_used,
|
||||||
cached;
|
actual_free;
|
||||||
} sigar_mem_t;
|
} sigar_mem_t;
|
||||||
|
|
||||||
SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem);
|
SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem);
|
||||||
|
|
|
@ -354,10 +354,10 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
mem->total = PAGESHIFT(vm.memsizepgs); /* lsattr -El sys0 -a realmem */
|
mem->total = PAGESHIFT(vm.memsizepgs); /* lsattr -El sys0 -a realmem */
|
||||||
mem->free = PAGESHIFT(vm.numfrb);
|
mem->free = PAGESHIFT(vm.numfrb);
|
||||||
mem->used = mem->total - mem->free;
|
mem->used = mem->total - mem->free;
|
||||||
|
mem->actual_used = mem->used;
|
||||||
|
mem->actual_free = mem->free;
|
||||||
|
|
||||||
mem->shared = -1;
|
mem->shared = -1;
|
||||||
mem->buffer = -1;
|
|
||||||
mem->cached = -1;
|
|
||||||
|
|
||||||
sigar_mem_calc_ram(sigar, mem);
|
sigar_mem_calc_ram(sigar, mem);
|
||||||
|
|
||||||
|
|
|
@ -124,8 +124,9 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
|
|
||||||
mem->used = mem->total - mem->free;
|
mem->used = mem->total - mem->free;
|
||||||
mem->shared = -1; /*XXX*/
|
mem->shared = -1; /*XXX*/
|
||||||
mem->buffer = -1;
|
|
||||||
mem->cached = -1;
|
mem->actual_free = mem->free;
|
||||||
|
mem->actual_used = mem->used;
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,10 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
mem->used = mem->total - mem->free;
|
mem->used = mem->total - mem->free;
|
||||||
|
|
||||||
/*XXX*/
|
/*XXX*/
|
||||||
mem->shared = mem->buffer = mem->cached = 0;
|
mem->shared = 0;
|
||||||
|
|
||||||
|
mem->actual_free = mem->free;
|
||||||
|
mem->actual_used = mem->used;
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,6 +233,7 @@ static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer,
|
||||||
|
|
||||||
int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
{
|
{
|
||||||
|
sigar_uint64_t buffer, cached;
|
||||||
char buffer[BUFSIZ];
|
char buffer[BUFSIZ];
|
||||||
|
|
||||||
int status = sigar_file2str(PROC_MEMINFO,
|
int status = sigar_file2str(PROC_MEMINFO,
|
||||||
|
@ -244,9 +245,14 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
|
|
||||||
mem->total = sigar_meminfo(buffer, MEMINFO_PARAM("MemTotal"));
|
mem->total = sigar_meminfo(buffer, MEMINFO_PARAM("MemTotal"));
|
||||||
mem->free = sigar_meminfo(buffer, MEMINFO_PARAM("MemFree"));
|
mem->free = sigar_meminfo(buffer, MEMINFO_PARAM("MemFree"));
|
||||||
mem->buffer = sigar_meminfo(buffer, MEMINFO_PARAM("Buffers"));
|
|
||||||
mem->cached = sigar_meminfo(buffer, MEMINFO_PARAM("Cached"));
|
|
||||||
mem->used = mem->total - mem->free;
|
mem->used = mem->total - mem->free;
|
||||||
|
|
||||||
|
buffer = sigar_meminfo(buffer, MEMINFO_PARAM("Buffers"));
|
||||||
|
cached = sigar_meminfo(buffer, MEMINFO_PARAM("Cached"));
|
||||||
|
|
||||||
|
mem->actual_free = mem->free;
|
||||||
|
mem->actual_used = mem->used;
|
||||||
|
|
||||||
mem->shared = 0; /* XXX where did this go in 2.6?? */
|
mem->shared = 0; /* XXX where did this go in 2.6?? */
|
||||||
|
|
||||||
if (get_ram(sigar, mem) != SIGAR_OK) {
|
if (get_ram(sigar, mem) != SIGAR_OK) {
|
||||||
|
|
|
@ -50,8 +50,9 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
sigar_mem_calc_ram(sigar, mem);
|
sigar_mem_calc_ram(sigar, mem);
|
||||||
|
|
||||||
mem->shared = -1;
|
mem->shared = -1;
|
||||||
mem->buffer = -1;
|
|
||||||
mem->cached = -1;
|
mem->actual_free = mem->free;
|
||||||
|
mem->actual_used = mem->used;
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,11 +180,12 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
|
|
||||||
mem->shared = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_EXEC));
|
mem->shared = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_EXEC));
|
||||||
|
|
||||||
mem->buffer = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_VNODE));
|
/*mem->buffer = KPAGE_SHIFT(kMEMPAGES(KSTAT_MEMPAGES_VNODE));*/
|
||||||
|
|
||||||
mem->cached = -1; /*XXX*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mem->actual_free = mem->free;
|
||||||
|
mem->actual_used = mem->used;
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,8 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
mem->used = -1;
|
mem->used = -1;
|
||||||
mem->free = -1;
|
mem->free = -1;
|
||||||
mem->shared = -1;
|
mem->shared = -1;
|
||||||
mem->buffer = -1;
|
mem->actual_free = mem->free;
|
||||||
mem->cached = -1;
|
mem->actual_used = mem->used;
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,9 +276,8 @@ SIGAR_DECLARE(int) sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
|
||||||
|
|
||||||
sigar_mem_calc_ram(sigar, mem);
|
sigar_mem_calc_ram(sigar, mem);
|
||||||
|
|
||||||
/*XXX*/
|
mem->actual_free = mem->free;
|
||||||
mem->buffer = 0;
|
mem->actual_used = mem->used;
|
||||||
mem->cached = 0;
|
|
||||||
|
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue