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=KPYJyEcalyyxwDwevICPE3koqlJFM5GYUcPlaAK7uH0=; b=QM8fn91/g3xVq5x02YsZ91stL+URzBNPyfK2bubj7Y5ykx8gP7Z6YZzUHKM9GeRkf+ mRZQZjxT+PgFErDPJry0pxeVzCOvqcRptVmq6ro0Zk/vp4pC/9UwzfvlOyr9fkrI9pJV 2/AreLQdcYob4USu4R+v13WNbGVRYuKhP2P3o= 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=P0TobsVmf8Iunrg9izhfc7r2in+Mhb6zMXwqJUFmPQfrFH6r8X9/gT2iSza27OEULM xlh9Wv+nJu86mZ+sAn41jGOg/Gzz9pAH7vOvFuYPVx4j865f118WgXZNWh8HutVvd1BB KihqBqSkiVLTzkWCjrMC9wQFylePA1bAjB7dQ= 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