summaryrefslogtreecommitdiffstats
path: root/web/attachments/462789-nagios_plugin.patch
blob: 34990510114a00cd4dd17967b6a769ed71a8cf9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
diff --git a/configure.in b/configure.in
--- a/configure.in
+++ b/configure.in
@@ -1246,12 +1246,20 @@

 AC_MSG_CHECKING([for number of cpus])
 AC_TRY_COMPILE([#include <unistd.h>],
-	[sysconf(_SC_NPROCESSORS_CONF) > 0;],
-	AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
-	AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
+	[sysconf(_SC_NPROCESSORS_ONLN) > 0;],
+	AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_ONLN,1,[Define if sysconf returns number of cpus])
+	AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_ONLN)]),
 	AC_MSG_RESULT([cannot calculate])
 	)

+AC_TRY_COMPILE([#include <unistd.h>],
+        [sysconf(_SC_NPROCESSORS_CONF) > 0;],
+        AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of cpus])
+        AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_CONF)]),
+        AC_MSG_RESULT([cannot calculate])
+        )
+
+
 AC_PATH_PROG(PATH_TO_UPTIME,uptime)
 AC_ARG_WITH(uptime_command,
             ACX_HELP_STRING([--with-uptime-command=PATH],
diff --git a/plugins/common.h b/plugins/common.h
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -82,10 +82,14 @@
    getting that data
    Will return -1 if cannot get data
 */
-#ifdef HAVE_SYSCONF__SC_NPROCESSORS_CONF
+#ifdef HAVE_SYSCONF__SC_NPROCESSORS_ONLN
 #define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_ONLN)
 #else
-#define GET_NUMBER_OF_CPUS() -1
+# ifdef HAVE_SYSCONF__SC_NPROCESSORS_CONF
+#  define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF)
+# else
+#  define GET_NUMBER_OF_CPUS() -1
+# endif
 #endif

 #ifdef TIME_WITH_SYS_TIME