[nagiosplug] Bug fix for ncpus if hyperthreading turned off in ...
Nagios Plugin Development
nagios-plugins at users.sourceforge.net
Mon Aug 19 22:50:17 CEST 2013
Module: nagiosplug
Branch: master
Commit: f12edfd07384be4060d5c724ac38ee212adc9028
Author: Booker C. Bense <bbense at gmail.com>
Date: Mon Aug 19 11:14:05 2013 -0700
URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=f12edfd
Bug fix for ncpus if hyperthreading turned off in linux
---
configure.in | 14 +++++++++++---
plugins/common.h | 10 +++++++---
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/configure.in b/configure.in
index 43fe4ad..2be2a1c 100644
--- a/configure.in
+++ b/configure.in
@@ -1270,12 +1270,20 @@ fi
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
index c0dc2f4..858329f 100644
--- 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
-#define GET_NUMBER_OF_CPUS() 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
More information about the Commits
mailing list