[OmniOS-discuss] kstat zone memory

qutic development mailinglists at qutic.com
Sun May 8 09:17:23 UTC 2016


Trying to get free [1] command working [2] inside of a OmniOS zone. free implementation is using kstat internally.

pagesize = getpagesize();
pages = sysconf(_SC_PHYS_PAGES);
total = pagesize * pages;

zoneid_t zid = getzoneid();
if (zid > 0) {
	/* local zone */
	 ks = kstat_lookup(kc, "memory_cap", zid, NULL);
	 kstat_read(kc, ks, 0);
	 knp = kstat_data_lookup(ks, "rss");
	 if (knp == NULL) {
		(void) kstat_close(kc);
	 	 return (-1);
	}
	used = (unsigned long long)knp->value.ui64;
	freemem = total - used;
}

It seems that memory_cap is SmartOS only.

Any idea what can be used instead on OmniOS?

Best regards
Stefan Husch

[1] https://github.com/wiedi/free
[2] https://github.com/wiedi/free/commit/3de9c3c7336ed958097f62818a4feb5142f00010


More information about the OmniOS-discuss mailing list