Added NetBSD code for procs hopefully
This commit is contained in:
parent
3be0cd6e32
commit
c80084a0cf
15
src/probe.c
15
src/probe.c
|
@ -23,6 +23,7 @@ struct sysinfo
|
||||||
{
|
{
|
||||||
long uptime;
|
long uptime;
|
||||||
unsigned long loads[3];
|
unsigned long loads[3];
|
||||||
|
unsigned short procs;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int sysinfo(struct sysinfo * info)
|
static int sysinfo(struct sysinfo * info)
|
||||||
|
@ -34,6 +35,7 @@ static int sysinfo(struct sysinfo * info)
|
||||||
int len;
|
int len;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
/* uptime */
|
||||||
mib[0] = CTL_KERN;
|
mib[0] = CTL_KERN;
|
||||||
mib[1] = KERN_BOOTTIME;
|
mib[1] = KERN_BOOTTIME;
|
||||||
len = sizeof(tv);
|
len = sizeof(tv);
|
||||||
|
@ -45,6 +47,8 @@ static int sysinfo(struct sysinfo * info)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
info->uptime = now.tv_sec - tv.tv_sec;
|
info->uptime = now.tv_sec - tv.tv_sec;
|
||||||
|
|
||||||
|
/* loads */
|
||||||
/* FIXME getloadavg() looks portable */
|
/* FIXME getloadavg() looks portable */
|
||||||
mib[0] = CTL_VM;
|
mib[0] = CTL_VM;
|
||||||
mib[1] = VM_LOADAVG;
|
mib[1] = VM_LOADAVG;
|
||||||
|
@ -60,6 +64,17 @@ static int sysinfo(struct sysinfo * info)
|
||||||
info->loads[1] = la.ldavg[1];
|
info->loads[1] = la.ldavg[1];
|
||||||
info->loads[2] = la.ldavg[2];
|
info->loads[2] = la.ldavg[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* procs */
|
||||||
|
mib[0] = CTL_KERN;
|
||||||
|
mib[1] = KERN_PROC;
|
||||||
|
if(sysctl(mib, 2, NULL, &len, NULL, 0) == -1)
|
||||||
|
{
|
||||||
|
info->procs = 0;
|
||||||
|
ret++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
info->procs = len;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user