(SIGAR-188) implement mem actual free/used on Solaris

This commit is contained in:
Doug MacEachern 2010-04-05 15:51:47 -07:00
parent 6a0cd93cf5
commit 1ba3abd3ab
1 changed files with 23 additions and 2 deletions

View File

@ -187,6 +187,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
{ {
kstat_ctl_t *kc = sigar->kc; kstat_ctl_t *kc = sigar->kc;
kstat_t *ksp; kstat_t *ksp;
sigar_uint64_t kern = 0;
SIGAR_ZERO(mem); SIGAR_ZERO(mem);
@ -211,8 +212,28 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem)
sigar_koffsets_init_mempages(sigar, ksp); sigar_koffsets_init_mempages(sigar, ksp);
} }
mem->actual_free = mem->free; /* XXX mdb ::memstat cachelist/freelist not available to kstat, see: */
mem->actual_used = mem->used; /* http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6821980 */
/* ZFS ARC cache. see: http://opensolaris.org/jive/thread.jspa?messageID=393695 */
if ((ksp = kstat_lookup(sigar->kc, "zfs", 0, "arcstats")) &&
(kstat_read(sigar->kc, ksp, NULL) != -1))
{
kstat_named_t *kn;
if ((kn = (kstat_named_t *)kstat_data_lookup(ksp, "size"))) {
kern = kn->value.i64;
}
if ((kn = (kstat_named_t *)kstat_data_lookup(ksp, "c_min"))) {
/* c_min cannot be reclaimed they say */
if (kern > kn->value.i64) {
kern -= kn->value.i64;
}
}
}
mem->actual_free = mem->free + kern;
mem->actual_used = mem->used - kern;
sigar_mem_calc_ram(sigar, mem); sigar_mem_calc_ram(sigar, mem);