Re: Showing custom statistics to userspace (/proc interface?)
Re: Showing custom statistics to userspace (/proc interface?)
- Subject: Re: Showing custom statistics to userspace (/proc interface?)
- From: mm w <email@hidden>
- Date: Wed, 24 Jun 2009 10:35:39 -0700
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<email@hidden> 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 (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden