Code

OVS events: Fix configure script to detect YAJL tree API
authorMytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
Mon, 3 Oct 2016 14:45:23 +0000 (15:45 +0100)
committerMytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
Mon, 26 Dec 2016 13:26:05 +0000 (13:26 +0000)
If old YAJL version is installed on a system (ver < 2.0), the OVS plugin
compilation will fail as it requires tree API to be supported in YAJL
library. For this reason, it was decided to change 'configure' script
to detect YAJL tree API also.

Clean-up according updated collectd style:
  https://github.com/collectd/collectd/pull/1931
  https://github.com/collectd/collectd/issues/1951

Change-Id: I90c82cdc9780ee8c0c9b794986662a39a5ab0011
Signed-off-by: Mytnyk, VolodymyrX <volodymyrx.mytnyk@intel.com>
configure.ac
src/ovs_events.c

index 998b9b3ac64eea0f436c64b9f771517096133318..0ab605ee38e7bfd0223038e4717d29125d83f569 100644 (file)
@@ -5341,6 +5341,11 @@ if test "x$with_libyajl" = "xyes"; then
     [with_libyajl="no (yajl/yajl_parse.h not found)"]
   )
 
+  AC_CHECK_HEADERS([yajl/yajl_tree.h],
+    [with_libyajl2="yes"],
+    [with_libyajl2="no (yajl/yajl_tree.h not found)"]
+  )
+
   AC_CHECK_HEADERS([yajl/yajl_version.h])
 
   CPPFLAGS="$SAVE_CPPFLAGS"
@@ -5355,6 +5360,11 @@ if test "x$with_libyajl" = "xyes"; then
     [with_libyajl="no (Symbol 'yajl_alloc' not found)"]
   )
 
+  AC_CHECK_LIB([yajl], [yajl_tree_parse],
+    [with_libyajl2="yes"],
+    [with_libyajl2="no (Symbol 'yajl_tree_parse' not found)"]
+  )
+
   LDFLAGS="$SAVE_LDFLAGS"
 fi
 
@@ -5882,6 +5892,7 @@ plugin_memory="no"
 plugin_multimeter="no"
 plugin_nfs="no"
 plugin_numa="no"
+plugin_ovs_events="no"
 plugin_perl="no"
 plugin_pinba="no"
 plugin_processes="no"
@@ -6070,6 +6081,12 @@ if test "x$have_sysctl" = "xyes"; then
     plugin_swap="yes"
   fi
 fi
+
+if test "x$with_libyajl" = "xyes" && test "x$with_libyajl2" = "xyes"
+then
+  plugin_ovs_events="yes"
+fi
+
 if test "x$have_sysctlbyname" = "xyes"; then
   plugin_contextswitch="yes"
   plugin_cpu="yes"
@@ -6314,7 +6331,7 @@ AC_PLUGIN([onewire],             [$with_libowcapi],         [OneWire sensor stat
 AC_PLUGIN([openldap],            [$with_libldap],           [OpenLDAP statistics])
 AC_PLUGIN([openvpn],             [yes],                     [OpenVPN client statistics])
 AC_PLUGIN([oracle],              [$with_oracle],            [Oracle plugin])
-AC_PLUGIN([ovs_events],          [$with_libyajl],           [OVS events plugin])
+AC_PLUGIN([ovs_events],          [$plugin_ovs_events],      [OVS events plugin])
 AC_PLUGIN([perl],                [$plugin_perl],            [Embed a Perl interpreter])
 AC_PLUGIN([pf],                  [$have_net_pfvar_h],       [BSD packet filter (PF) statistics])
 # FIXME: Check for libevent, too.
index dd42021d8f50071460dd1eaec0ae14c28b99744e..d9735913af77a8386b9945c58d5c7efcacf49d69 100644 (file)
@@ -302,7 +302,6 @@ ovs_events_dispatch_notification(const ovs_events_iface_info_t *ifinfo) {
 /* Dispatch OVS interface link status value to collectd */
 static void
 ovs_events_link_status_submit(const ovs_events_iface_info_t *ifinfo) {
-  value_t values[1];
   value_list_t vl = VALUE_LIST_INIT;
   meta_data_t *meta = NULL;
 
@@ -322,11 +321,9 @@ ovs_events_link_status_submit(const ovs_events_iface_info_t *ifinfo) {
   } else
     ERROR(OVS_EVENTS_PLUGIN ": create metadata failed");
 
-  values[0].gauge = (gauge_t)ifinfo->link_status;
   vl.time = cdtime();
-  vl.values = values;
-  vl.values_len = STATIC_ARRAY_SIZE(values);
-  sstrncpy(vl.host, hostname_g, sizeof(vl.host));
+  vl.values = &(value_t){.gauge = (gauge_t)ifinfo->link_status};
+  vl.values_len = 1;
   sstrncpy(vl.plugin, OVS_EVENTS_PLUGIN, sizeof(vl.plugin));
   sstrncpy(vl.plugin_instance, ifinfo->name, sizeof(vl.plugin_instance));
   sstrncpy(vl.type, "gauge", sizeof(vl.type));
@@ -540,8 +537,7 @@ static void ovs_events_conn_terminate() {
 }
 
 /* Read OVS DB interface link status callback */
-static int ovs_events_plugin_read(user_data_t *ud) {
-  (void)ud; /* unused argument */
+static int ovs_events_plugin_read(__attribute__((unused)) user_data_t *u) {
   _Bool is_connected = 0;
   OVS_EVENTS_CTX_LOCK { is_connected = ovs_events_ctx.is_db_available; }
   if (is_connected)