[nagiosplug] Clean up check for _SC_NPROCESSORS_ONLN

Nagios Plugin Development nagios-plugins at users.sourceforge.net
Mon Aug 19 22:50:19 CEST 2013


 Module: nagiosplug
 Branch: master
 Commit: 5f79e3e9f62ca5487d9881973149136ba1d19d3e
 Author: Holger Weiss <holger at zedat.fu-berlin.de>
   Date: Mon Aug 19 22:47:36 2013 +0200
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=5f79e3e

Clean up check for _SC_NPROCESSORS_ONLN

Closes #62.

---

 configure.in     |   16 ++++++++--------
 plugins/common.h |   12 +++++-------
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/configure.in b/configure.in
index 2be2a1c..bbcbb71 100644
--- a/configure.in
+++ b/configure.in
@@ -1268,21 +1268,21 @@ if test -n "$ac_cv_nslookup_command"; then
 	AC_DEFINE_UNQUOTED(NSLOOKUP_COMMAND,"$ac_cv_nslookup_command", [path and args for nslookup])
 fi
 
-AC_MSG_CHECKING([for number of cpus])
+AC_MSG_CHECKING([for number of online cpus])
 AC_TRY_COMPILE([#include <unistd.h>],
 	[sysconf(_SC_NPROCESSORS_ONLN) > 0;],
-	AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_ONLN,1,[Define if sysconf returns number of cpus])
+	AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_ONLN,1,[Define if sysconf returns number of online cpus])
 	AC_MSG_RESULT([sysconf(_SC_NPROCESSORS_ONLN)]),
 	AC_MSG_RESULT([cannot calculate])
 	)
 
+AC_MSG_CHECKING([for number of available 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)]),
-        AC_MSG_RESULT([cannot calculate])
-        )
-
+	[sysconf(_SC_NPROCESSORS_CONF) > 0;],
+	AC_DEFINE(HAVE_SYSCONF__SC_NPROCESSORS_CONF,1,[Define if sysconf returns number of available 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,
diff --git a/plugins/common.h b/plugins/common.h
index 858329f..8f05c15 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -82,14 +82,12 @@
    getting that data
    Will return -1 if cannot get data
 */
-#ifdef HAVE_SYSCONF__SC_NPROCESSORS_ONLN
-#define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_ONLN)
+#if defined(HAVE_SYSCONF__SC_NPROCESSORS_ONLN)
+# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_ONLN)
+#elif defined (HAVE_SYSCONF__SC_NPROCESSORS_CONF)
+# define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF)
 #else
-# ifdef HAVE_SYSCONF__SC_NPROCESSORS_CONF
-#  define GET_NUMBER_OF_CPUS() sysconf(_SC_NPROCESSORS_CONF)
-# else
-#  define GET_NUMBER_OF_CPUS() -1
-# endif
+# define GET_NUMBER_OF_CPUS() -1
 #endif
 
 #ifdef TIME_WITH_SYS_TIME





More information about the Commits mailing list