1

I am trying to build the collectd system performance monitoring package (version 5.4.1; building collectd on Fedora v20 VM) and want to use the write_mongodb plug-in.

I run ./configure in the folder collectd-5.4.1 where I have download the package source files but cannot get write_mongodb support due to the following error (as seen in config.log file of collectd folder):

/home/user01/Documents/libs/collectd-5.4.1/conftest.c:181: undefined reference to 'mongo_run_command'

I am trying to link to mongo-c-driver library, which I previously compiled to generate libmongoc-1.0.so.0.0.0 (version 0.96.4).

I made following modifications in the script configure to link to libmongoc:

LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I/usr/local/include/libmongoc-1.0/ -I/usr/local/include/libbson-1.0/" 
LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L/usr/local/lib/ -L/usr/local/lib/"

and copied the file mongoc.h into the folder as /usr/local/include/libmongoc-1.0/mongo.h

Following is snippet from output of configure script config.log in collectd folder that has the error relating to mongo_run_command.

configure:21551: libmongoc CPPFLAGS:  -I/usr/local/include/libmongoc-1.0/ -I/usr/local/include/libbson-1.0/
configure:21556: checking for mongo.h
configure:21556: gcc -c -g -O2   -I/usr/local/include/libmongoc-1.0/ -I/usr/local/include/libbson-1.0/ conftest.c >&5
configure:21556: $? = 0
configure:21556: result: yes
configure:21579: libmongoc LDFLAGS:  -L/usr/local/lib/ -L/usr/local/lib/
configure:21582: checking for mongo_run_command in -lmongoc
configure:21607: gcc -o conftest -g -O2   -I/usr/local/include/libmongoc-1.0/ -I/usr/local/include/libbson-1.0/   -L/usr/local/lib/ -L/usr/local/lib/ conftest.c -lmongoc  -ldl  >&5
/tmp/ccyc9VGB.o: In function 'main':
/home/user01/Documents/libs/collectd-5.4.1/conftest.c:181: undefined reference to 'mongo_run_command'
collect2: error: ld returned 1 exit status
configure:21607: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "collectd"
| #define PACKAGE_TARNAME "collectd"
| #define PACKAGE_VERSION "5.4.1"
| #define PACKAGE_STRING "collectd 5.4.1"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DLFCN_H 1
| #define LT_OBJDIR ".libs/"
| #define LT_MODULE_EXT ".so"
| #define LT_MODULE_PATH_VAR "LD_LIBRARY_PATH"
| #define LT_DLSEARCH_PATH "/lib:/usr/lib:/usr/lib64/dyninst:/usr/lib64/iscsi:/usr/lib64/llvm:/usr/local/lib/usr/lib64/tracker-0.16:/usr/lib64/xulrunner:/usr/local/lib"
| #define HAVE_LIBDL 1
| #define HAVE_DLERROR 1
| #define HAVE_LIBDLLOADER 1
| #define HAVE_ARGZ_H 1
| #define HAVE_ERROR_T 1
| #define HAVE_ARGZ_ADD 1
| #define HAVE_ARGZ_APPEND 1
| #define HAVE_ARGZ_COUNT 1
| #define HAVE_ARGZ_CREATE_SEP 1
| #define HAVE_ARGZ_INSERT 1
| #define HAVE_ARGZ_NEXT 1
| #define HAVE_ARGZ_STRINGIFY 1
| #define HAVE_WORKING_ARGZ 1
| #define HAVE_PRELOADED_SYMBOLS 1
| #define HAVE_UNISTD_H 1
| #define HAVE_DIRENT_H 1
| #define HAVE_CLOSEDIR 1
| #define HAVE_OPENDIR 1
| #define HAVE_READDIR 1
| #define LT_LIBEXT "a"
| #define LT_LIBPREFIX "lib"
| #define LIBTOOL_VERSION 2
| #define PACKAGE "collectd"
| #define VERSION "5.4.1"
| #define KERNEL_LINUX 1
| #define STDC_HEADERS 1
| #define HAVE_SYS_WAIT_H 1
| #define HAVE_DIRENT_H 1
| #define HAVE__BOOL 1
| #define HAVE_STDBOOL_H 1
| #define HAVE_STDIO_H 1
| #define HAVE_ERRNO_H 1
| #define HAVE_MATH_H 1
| #define HAVE_STDARG_H 1
| #define HAVE_SYSLOG_H 1
| #define HAVE_FCNTL_H 1
| #define HAVE_SIGNAL_H 1
| #define HAVE_ASSERT_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_SOCKET_H 1
| #define HAVE_SYS_SELECT_H 1
| #define HAVE_POLL_H 1
| #define HAVE_NETDB_H 1
| #define HAVE_ARPA_INET_H 1
| #define HAVE_SYS_RESOURCE_H 1
| #define HAVE_SYS_PARAM_H 1
| #define HAVE_REGEX_H 1
| #define HAVE_SYS_IOCTL_H 1
| #define HAVE_ENDIAN_H 1
| #define HAVE_FNMATCH_H 1
| #define HAVE_LIBGEN_H 1
| #define HAVE_NETINET_IN_SYSTM_H 1
| #define HAVE_NETINET_IN_H 1
| #define HAVE_NETINET_IP_H 1
| #define HAVE_NETINET_IP_ICMP_H 1
| #define HAVE_NETINET_IP6_H 1
| #define HAVE_NETINET_ICMP6_H 1
| #define HAVE_NETINET_TCP_H 1
| #define HAVE_NETINET_UDP_H 1
| #define HAVE_SYS_SYSCTL_H 1
| #define HAVE_LINUX_MAJOR_H 1
| #define HAVE_LINUX_RAID_MD_U_H 1
| #define HAVE_LINUX_WIRELESS_H 1
| #define HAVE_SYS_SWAP_H 1
| #define HAVE_UTMP_H 1
| #define HAVE_UTMPX_H 1
| #define HAVE_IFADDRS_H 1
| #define HAVE_NET_IF_H 1
| #define HAVE_LINUX_IF_H 1
| #define HAVE_LINUX_NETDEVICE_H 1
| #define HAVE_LINUX_SOCKIOS_H 1
| #define HAVE_LINUX_ETHTOOL_H 1
| #define HAVE_LINUX_IP_VS_H 1
| #define HAVE_SYS_MOUNT_H 1
| #define HAVE_LINUX_UN_H 1
| #define HAVE_PWD_H 1
| #define HAVE_GRP_H 1
| #define HAVE_SYS_UN_H 1
| #define HAVE_CTYPE_H 1
| #define HAVE_LIMITS_H 1
| #define HAVE_PATHS_H 1
| #define HAVE_MNTENT_H 1
| #define HAVE_SYS_STATFS_H 1
| #define HAVE_SYS_STATVFS_H 1
| #define HAVE_SYS_VFS_H 1
| #define HAVE_WORDEXP_H 1
| #define HAVE_ARPA_NAMESER_H 1
| #define HAVE_ARPA_NAMESER_COMPAT_H 1
| #define HAVE_NET_IF_ARP_H 1
| #define HAVE_NET_PPP_DEFS_H 1
| #define HAVE_NET_IF_PPP_H 1
| #define HAVE_NETINET_IF_ETHER_H 1
| #define HAVE_TERMIOS_H 1
| #define TIME_WITH_SYS_TIME 1
| #define HAVE_GETTIMEOFDAY 1
| #define HAVE_SELECT 1
| #define HAVE_STRDUP 1
| #define HAVE_STRTOL 1
| #define HAVE_GETADDRINFO 1
| #define HAVE_GETNAMEINFO 1
| #define HAVE_STRCHR 1
| #define HAVE_MEMCPY 1
| #define HAVE_STRSTR 1
| #define HAVE_STRCMP 1
| #define HAVE_STRNCMP 1
| #define HAVE_STRNCPY 1
| #define HAVE_STRLEN 1
| #define HAVE_STRNCASECMP 1
| #define HAVE_STRCASECMP 1
| #define HAVE_OPENLOG 1
| #define HAVE_CLOSELOG 1
| #define HAVE_SYSCONF 1
| #define HAVE_SETENV 1
| #define HAVE_IF_INDEXTONAME 1
| #define HAVE_DECL_STRERROR_R 1
| #define HAVE_STRERROR_R 1
| #define HAVE_GETPWNAM_R 1
| #define HAVE_GETGRNAM_R 1
| #define HAVE_SETGROUPS 1
| #define HAVE_REGCOMP 1
| #define HAVE_REGERROR 1
| #define HAVE_REGEXEC 1
| #define HAVE_REGFREE 1
| #define HAVE_SOCKET 1
| #define HAVE_CLOCK_GETTIME 1
| #define HAVE_CLOCK_GETTIME 1
| #define HAVE_NANOSLEEP 1
| #define HAVE_SYSCTL 1
| #define HAVE_STATFS 1
| #define HAVE_STATVFS 1
| #define HAVE_GETIFADDRS 1
| #define HAVE_GETLOADAVG 1
| #define HAVE_SYSLOG 1
| #define HAVE_GETUTENT 1
| #define HAVE_GETUTXENT 1
| #define HAVE_STRPTIME 1
| #define STRPTIME_NEEDS_STANDARDS 1
| #define NAN_STATIC_DEFAULT 1
| #define FP_LAYOUT_NEED_NOTHING 1
| #define HAVE_GETMNTENT 1
| #define HAVE_ONE_GETMNTENT 1
| #define HAVE_STRUCT_IP_MREQN_IMR_IFINDEX 1
| #define HAVE_STRUCT_UDPHDR_UH_DPORT 1
| #define HAVE_STRUCT_UDPHDR_UH_SPORT 1
| #define COLLECT_LIBESMTP 0
| #define HAVE_MONGO_H 1
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char mongo_run_command ();
| int
| main ()
| {
| return mongo_run_command ();
|   ;
|   return 0;
| }
configure:21616: result: no

I did not find the function mongo_run_command anywhere in files in the folder mongo-c-driver-0.96.4

mongo-c-driver-0.96.4/src/mongoc/.*
mongo-c-driver-0.96.4/src/libmongoc.symbols

Thanks.

mc110
  • 2,825
  • 5
  • 20
  • 21
Sid Thakur
  • 798
  • 1
  • 7
  • 10

1 Answers1

1

Following steps fixed problems encountered while building Write MongoDB plugin support for the collectd system performance monitoring package.

Compiling Mongo-C-Driver and Collectd

Following steps and code updates are needed to build and use the write_mongodb plugin in collectd to send system performance data directly to MongoDB database.

  • Download collectd-5.4.1 to, say,

    • COLLECTD_DIR=/home/user01/libs/collectd-5.4.1

    Don’t compile/build collectd, yet.

  • Download mongo-c-driver version 0.8.1 from GitHub. Latest version of mongo-c-driver is not compatible with the collectd version 5.4.1

  • Built Mongo 0.8.1 to the folder: MONGOC_DIR=/home/user01/libs/mongo-c-driver-0.8.1

  • Copy the libraries libbson.so and libmongoc.so from MONGOC_DIR to /usr/local/lib and /usr/local/lib64

  • Copy the libmongoc.so library to following locations: sudo cp /usr/local/lib/libmongoc.so /lib64/libmongoc.so.0.8 sudo cp /usr/local/lib/libmongoc.so /lib/libmongoc.so.0.8

  • Copy .h header files from folder MONGOC_DIR/src to /usr/local/include

  • Go to COLLECTD_DIR and make following changes to the configure script

    // Comment the lines with -I$withval/include and -I$withval/lib and replace them with following // Before > LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I$withval/include" LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L$withval/lib" // After > LIBMONGOC_CPPFLAGS="$LIBMONGOC_CPPFLAGS -I/usr/local/include/" LIBMONGOC_LDFLAGS="$LIBMONGOC_LDFLAGS -L/usr/local/lib/"

  • Run the script ./configure

  • Make following changes to file COLLECTD_DIR/src/write_mongodb.c; the changes are mentioned in this issue.
    • change bson_create to bson_alloc
    • change bson_dispose to bson_dealloc
  • Compile collectd: run sudo make clean and then sudo make to compile collectd afresh.
  • Install collected by running sudo make install

Running Collectd and Testing With MongoDB

  • Start MongoDB server
  • Run collected: /opt/collectd/sbin/collectd
  • Start mongo server
  • Run following commands in mongo session to check connection with collectd show dbs use collectd db.getCollectionNames() db.load.find().sort({x:1}).limit(3).pretty()
Sid Thakur
  • 798
  • 1
  • 7
  • 10