Re: Showing custom statistics to userspace (/proc interface?)
site_archiver@lists.apple.com Delivered-To: darwin-kernel@lists.apple.com Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=bkMbpqMLSqlr3oo7LMb1g1EaJIOguUAM6GPBTTcaEGk=; b=pmwCJIdlUU0Y3AF1S+BaZClegR7wvq+yVns3KKiLWxJdtClorVV+36FRCOa8HypiiM sqyVZ6kajP7J9fS1upU9k0l/Xmo4dsmtU777dDFSiF5hMtDohlpdEsFyBOpWKwiEkw+5 tJPOkDmNQqbkUL2vxTOihlCCXmovSq5Q3pPsU= Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=fKfFnuDWh9upQvFXTXRDqwRbWOwxBzpZB4bDRw/zrUXN2x4zJOZG1V0Vfqs7i2nP27 VS+GKunuJ5LxQHGuP39OKimXzyD0TJ28SjyXZ2nfTgNP2jab+/Eb6Exc9LtiO/GG+Z3S CGfyaHMzlZKe9eLg4s4bztNPoFIr2yRW05hNA= Sorry I didn't read correctly, thought that you need to get already exposed values. Best, On Wed, Jun 24, 2009 at 10:35 AM, mm w<0xcafefeed@gmail.com> wrote:
Hello,
you can reach most of them using sysctl APIs, it depends what king of info you need, maybe if you say, we will be able to point the right place.
for instance:
/* BSD, BSD-LIKE Family*/ int getloadavg(double loads[], int nelem) { struct loadavg info; size_t len = sizeof(info); int idx = -1; nelem = MIN(nelem, sizeof(info.ldavg) / sizeof(fixpt_t)); if (0 == sysctlbyname("vm.loadavg", &info, &len, NULL, 0)) { do { loads[idx] = (double) info.ldavg[idx] / info.fscale; } while (++idx < nelem); } return idx; }
/* Linux stub on linux, the sysinfo struct is populated using /proc fs / read and parse */ struct sysinfo { #define LINUX_SYSINFO_LOADS_SCALE 65536 unsigned long loads[3]; };
int sysinfo(struct sysinfo *info) { if (info) { (*info).loads[0] = 8192UL; (*info).loads[1] = 4096UL; (*info).loads[2] = 2048UL; return 0; }
return -1; }
int getloadavg(double loads[], int nelem) { struct sysinfo info; int idx = -1; if (0 == sysinfo(&info)) { nelem = MIN(nelem, sizeof(info.loads) / sizeof(unsigned long)); do { loads[idx] = (double) info.loads[idx] / LINUX_SYSINFO_LOADS_SCALE; } while (++idx < nelem); } return idx; } /* Linux stub */
On Wed, Jun 24, 2009 at 9:45 AM, Abhijit Bhopatkar<abhijit.bhopatkar@calsoftinc.com> wrote:
In the filesystem that i am writing, i have various statistics being gathered over time in a central data structure. On linux we expose this structure to userspace through a /proc entry. Is there an equivalent of /proc interface in xnu that can be use to expose arbitrary statistics?
Thanks, Abhijit _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/0xcafefeed%40gmail.com
This email sent to 0xcafefeed@gmail.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.a... This email sent to site_archiver@lists.apple.com
participants (1)
-
mm w