summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d6590a3)
raw | patch | inline | side by side (parent: d6590a3)
author | Doug MacEachern <dougm@hyperic.com> | |
Thu, 22 Oct 2009 22:52:22 +0000 (15:52 -0700) | ||
committer | Doug MacEachern <dougm@hyperic.com> | |
Thu, 22 Oct 2009 22:52:22 +0000 (15:52 -0700) |
src/cpu.c | patch | blob | history |
diff --git a/src/cpu.c b/src/cpu.c
index c4bd1a6d8459d7e3acb8c622734deadf784270f7..b92b0e2f0b7e74d4f89800e97d29e0434b5abe83 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
#elif defined(HAVE_SYSCTLBYNAME)
static int numcpu;
+# ifdef HAVE_SYSCTL_KERN_CP_TIMES
+static int maxcpu;
+# endif /* HAVE_SYSCTL_KERN_CP_TIMES */
/* #endif HAVE_SYSCTLBYNAME */
#elif defined(HAVE_LIBSTATGRAB)
if (sysctlbyname ("hw.ncpu", &numcpu, &numcpu_size, NULL, 0) < 0)
{
char errbuf[1024];
- WARNING ("cpu plugin: sysctlbyname: %s",
+ WARNING ("cpu plugin: sysctlbyname(hw.ncpu): %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
-#ifndef HAVE_SYSCTL_KERN_CP_TIMES
+#ifdef HAVE_SYSCTL_KERN_CP_TIMES
+ numcpu_size = sizeof (maxcpu);
+
+ if (sysctlbyname("kern.smp.maxcpus", &maxcpu, &numcpu_size, NULL, 0) < 0)
+ {
+ char errbuf[1024];
+ WARNING ("cpu plugin: sysctlbyname(kern.smp.maxcpus): %s",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ return (-1);
+ }
+#else
if (numcpu != 1)
NOTICE ("cpu: Only one processor supported when using `sysctlbyname' (found %i)", numcpu);
#endif
}
/* #endif CAN_USE_SYSCTL */
#elif defined(HAVE_SYSCTLBYNAME) && defined(HAVE_SYSCTL_KERN_CP_TIMES)
- long cpuinfo[numcpu][CPUSTATES];
+ long cpuinfo[maxcpu][CPUSTATES];
size_t cpuinfo_size;
int i;