Merge pull request #2199 from jaroug/support_attributes_kairosdb
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sun, 26 Mar 2017 13:36:09 +0000 (15:36 +0200)
committerGitHub <noreply@github.com>
Sun, 26 Mar 2017 13:36:09 +0000 (15:36 +0200)
Add support for 'Attribute' option on KAIROSDB output format

12 files changed:
configure.ac
contrib/redhat/collectd.spec
docs/BUILD.dpdkstat.md
src/collectd.conf.in
src/collectd.conf.pod
src/dpdkstat.c
src/intel_rdt.c
src/ovs_events.c
src/ovs_stats.c
src/utils_cmd_flush.c
src/utils_ovs.c
src/virt.c

index 63cfca7..b6a47dc 100644 (file)
@@ -592,6 +592,14 @@ if test "x$ac_system" = "xLinux"; then
   fi
 
   if test "x$have_capability" = "xyes"; then
+    AC_CHECK_DECL([CAP_IS_SUPPORTED],
+      [have_capability="yes"],
+      [have_capability="no (CAP_IS_SUPPORTED not found)"],
+      [[#include <sys/capability.h>]]
+    )
+  fi
+
+  if test "x$have_capability" = "xyes"; then
     AC_DEFINE([HAVE_CAPABILITY], [1], [Define to 1 if you have cap_get_proc() (-lcap).])
   fi
 
@@ -5997,6 +6005,11 @@ if test "x$ac_system" = "xLinux"; then
   if test "x$c_cv_have_clock_boottime_monotonic" = "xyes"; then
     plugin_cpusleep="yes"
   fi
+
+  if test "x$with_libyajl" = "xyes" && test "x$with_libyajl2" = "xyes"; then
+    plugin_ovs_events="yes"
+    plugin_ovs_stats="yes"
+  fi
 fi
 
 if test "x$ac_system" = "xOpenBSD"; then
@@ -6173,11 +6186,6 @@ if test "x$with_libyajl" = "xyes"; then
   plugin_log_logstash="yes"
 fi
 
-if test "x$with_libyajl" = "xyes" && test "x$with_libyajl2" = "xyes"; then
-  plugin_ovs_events="yes"
-  plugin_ovs_stats="yes"
-fi
-
 if test "x$with_libperl" = "xyes" && test "x$c_cv_have_perl_ithreads" = "xyes"; then
   plugin_perl="yes"
 fi
index 451589d..bceaaf8 100644 (file)
 %define with_openldap 0%{!?_without_openldap:1}
 %define with_openvpn 0%{!?_without_openvpn:1}
 %define with_ovs_events 0%{!?_without_ovs_events:1}
+%define with_ovs_stats 0%{!?_without_ovs_stats:1}
 %define with_perl 0%{!?_without_perl:1}
 %define with_pinba 0%{!?_without_pinba:1}
 %define with_ping 0%{!?_without_ping:1}
 %define with_aquaero 0%{!?_without_aquaero:0}
 # plugin barometer disabled, requires a libi2c
 %define with_barometer 0%{!?_without_barometer:0}
-# plugin grpc disabled, requires protobuf-compiler >= 3.0
-%define with_grpc 0%{!?_without_grpc:0}
+# plugin dpdkevents disabled, requires libdpdk
+%define with_dpdkevents 0%{!?_without_dpdkevents:0}
 # plugin dpdkstat disabled, requires libdpdk
 %define with_dpdkstat 0%{!?_without_dpdkstat:0}
+# plugin grpc disabled, requires protobuf-compiler >= 3.0
+%define with_grpc 0%{!?_without_grpc:0}
 # plugin lpar disabled, requires AIX
 %define with_lpar 0%{!?_without_lpar:0}
 # plugin intel_rdt disabled, requires intel-cmt-cat
 %define with_gps 0
 %define with_mqtt 0
 %define with_ovs_events 0
+%define with_ovs_stats 0
 %define with_redis 0
 %define with_rrdcached 0
 %define with_write_redis 0
 Summary:       Statistics collection and monitoring daemon
 Name:          collectd
 Version:       5.7.1
-Release:       2%{?dist}
+Release:       6%{?dist}
 URL:           https://collectd.org
 Source:                https://collectd.org/files/%{name}-%{version}.tar.bz2
 License:       GPLv2
 Group:         System Environment/Daemons
 BuildRoot:     %{_tmppath}/%{name}-%{version}-root
-BuildRequires: libgcrypt-devel, kernel-headers, libcap-devel, which, xfsprogs-devel
+BuildRequires: libgcrypt-devel, kernel-headers, libcap-devel, which
 Vendor:                collectd development team <collectd@verplant.org>
 
 %if 0%{?fedora} || 0%{?rhel} >= 7
+BuildRequires:         xfsprogs-devel
 %{?systemd_requires}
 BuildRequires:         systemd
 %else
@@ -679,6 +684,17 @@ interfaces, dispatches the values to collectd and sends notifications
 whenever a link state change occurs in the OVS database.
 %endif
 
+%if %{with_ovs_stats}
+%package ovs_stats
+Summary:       Open vSwitch statistics plugin for collectd
+Group:         System Environment/Daemons
+Requires:      %{name}%{?_isa} = %{version}-%{release}
+BuildRequires: yajl-devel
+%description ovs_stats
+This plugin collects statictics of OVS connected bridges and
+interfaces.
+%endif
+
 %if %{with_perl}
 %package perl
 Summary:       Perl plugin for collectd
@@ -1125,6 +1141,12 @@ Collectd utilities
 %define _with_drbd --disable-drbd
 %endif
 
+%if %{with_dpdkevents}
+%define _with_dpdkevents --enable-dpdkevents
+%else
+%define _with_dpdkevents --disable-dpdkevents
+%endif
+
 %if %{with_dpdkstat}
 %define _with_dpdkstat --enable-dpdkstat
 %else
@@ -1467,6 +1489,12 @@ Collectd utilities
 %define _with_ovs_events --disable-ovs_events
 %endif
 
+%if %{with_ovs_stats}
+%define _with_ovs_stats --enable-ovs_stats
+%else
+%define _with_ovs_stats --disable-ovs_stats
+%endif
+
 %if %{with_perl}
 %define _with_perl --enable-perl --with-perl-bindings="INSTALLDIRS=vendor"
 %else
@@ -1843,6 +1871,7 @@ Collectd utilities
        %{?_with_disk} \
        %{?_with_dns} \
        %{?_with_drbd} \
+       %{?_with_dpdkevents} \
        %{?_with_dpdkstat} \
        %{?_with_email} \
        %{?_with_entropy} \
@@ -1899,6 +1928,7 @@ Collectd utilities
        %{?_with_openvpn} \
        %{?_with_oracle} \
        %{?_with_ovs_events} \
+       %{?_with_ovs_stats} \
        %{?_with_perl} \
        %{?_with_pf} \
        %{?_with_pinba} \
@@ -2125,9 +2155,6 @@ fi
 %if %{with_drbd}
 %{_libdir}/%{name}/drbd.so
 %endif
-%if %{with_dpdkstat}
-%{_libdir}/%{name}/dpdkstat.so
-%endif
 %if %{with_ethstat}
 %{_libdir}/%{name}/ethstat.so
 %endif
@@ -2209,9 +2236,6 @@ fi
 %if %{with_olsrd}
 %{_libdir}/%{name}/olsrd.so
 %endif
-%if %{with_ovs_events}
-%{_libdir}/%{name}/ovs_events.so
-%endif
 %if %{with_powerdns}
 %{_libdir}/%{name}/powerdns.so
 %endif
@@ -2389,6 +2413,16 @@ fi
 %{_libdir}/%{name}/dbi.so
 %endif
 
+%if %{with_dpdkevents}
+%files dpdkevents
+%{_libdir}/%{name}/dpdkevents.so
+%endif
+
+%if %{with_dpdkstat}
+%files dpdkstat
+%{_libdir}/%{name}/dpdkstat.so
+%endif
+
 %if %{with_email}
 %files email
 %{_libdir}/%{name}/email.so
@@ -2513,6 +2547,16 @@ fi
 %{_libdir}/%{name}/openldap.so
 %endif
 
+%if %{with_ovs_events}
+%files ovs_events
+%{_libdir}/%{name}/ovs_events.so
+%endif
+
+%if %{with_ovs_stats}
+%files ovs_stats
+%{_libdir}/%{name}/ovs_stats.so
+%endif
+
 %if %{with_perl}
 %files perl
 %{perl_vendorlib}/Collectd.pm
@@ -2632,6 +2676,18 @@ fi
 %doc contrib/
 
 %changelog
+* Sun Mar 05 2017 Ruben Kerkhof <ruben@rubenkerkhof.com> - 5.7.1-6
+- Move recently added plugins to subpackages
+
+* Sun Mar 05 2017 Ruben Kerkhof <ruben@rubenkerkhof.com> - 5.7.1-5
+- Add new ovs_stats plugin
+
+* Sun Mar 05 2017 Ruben Kerkhof <ruben@rubenkerkhof.com> - 5.7.1-4
+- Don't enable XFS support on RHEL6, it is missing for i386
+
+* Sun Mar 05 2017 Ruben Kerkhof <ruben@rubenkerkhof.com> - 5.7.1-3
+- Add dpdkevents plugin, disabled by default
+
 * Wed Feb 22 2017 Ruben Kerkhof <ruben@rubenkerkhof.com> - 5.7.1-2
 - Enable XFS support in df plugin
 - Fix bogus date in changelog
index fe9f0e6..96f1eb9 100644 (file)
@@ -208,6 +208,12 @@ See also: http://dpdk.org/doc/guides/prog_guide/multi_proc_support.html
  *  The same PCI device configuration should be passed to the primary process as
     the secondary process uses the same port indexes as the primary.
  *  A blacklist / whitelist of NICs isn't supported yet.
+ *  Plugin initialization time depends on read interval. It requires 5 read
+    cycles to set up internal buffers and states. During that time no statistics
+    are submitted.
+ *  If number of DPDK ports is increased while plugin is running, internal
+    buffers are resized. That requires 3 read cycles and no port statistics
+    are submitted in that time.
 
 ## License
 
index ff83d18..9508338 100644 (file)
 #  Address "127.0.0.1"
 #  Socket "/var/run/openvswitch/db.sock"
 #  Interfaces "br0" "veth0"
-#  SendNotification false
-#  DispatchValues true
+#  SendNotification true
+#  DispatchValues false
 #</Plugin>
 
 #<Plugin ovs_stats>
index 7dc4e97..c18f8ef 100644 (file)
@@ -5637,8 +5637,8 @@ B<Synopsis:>
    Address "127.0.0.1"
    Socket "/var/run/openvswitch/db.sock"
    Interfaces "br0" "veth0"
-   SendNotification false
-   DispatchValues true
+   SendNotification true
+   DispatchValues false
  </Plugin>
 
 The plugin provides the following configuration options:
@@ -5676,12 +5676,12 @@ Default: empty (all interfaces on all bridges are monitored)
 =item B<SendNotification> I<true|false>
 
 If set to true, OVS link notifications (interface status and OVS DB connection
-terminate) are sent to collectd. Default value is false.
+terminate) are sent to collectd. Default value is true.
 
 =item B<DispatchValues> I<true|false>
 
 Dispatch the OVS DB interface link status value with configured plugin interval.
-Defaults to true. Please note, if B<SendNotification> and B<DispatchValues>
+Defaults to false. Please note, if B<SendNotification> and B<DispatchValues>
 options are false, no OVS information will be provided by the plugin.
 
 =back
index 6b057f2..cfe993c 100644 (file)
@@ -103,6 +103,8 @@ static void dpdk_stats_default_config(void) {
   for (int i = 0; i < RTE_MAX_ETHPORTS; i++) {
     ec->config.port_name[i][0] = 0;
   }
+  /* Enable all ports by default */
+  ec->config.enabled_port_mask = ~0;
 }
 
 static int dpdk_stats_preinit(void) {
index e2e2e39..fc2a5f1 100644 (file)
@@ -252,14 +252,13 @@ static int cgroup_set(rdt_core_group_t *cg, char *desc, uint64_t *cores,
  *   `item'        Config option containing core groups.
  *   `groups'      Table of core groups to set values in.
  *   `max_groups'  Maximum number of core groups allowed.
- *   `max_core'    Maximum allowed core value.
  *
  * RETURN VALUE
  *   On success, the number of core groups set up. On error, appropriate
  *   negative error value.
  */
 static int oconfig_to_cgroups(oconfig_item_t *item, rdt_core_group_t *groups,
-                              size_t max_groups, uint64_t max_core) {
+                              size_t max_groups) {
   int index = 0;
 
   assert(groups != NULL);
@@ -285,14 +284,6 @@ static int oconfig_to_cgroups(oconfig_item_t *item, rdt_core_group_t *groups,
       return (-EINVAL);
     }
 
-    for (int i = 0; i < n; i++) {
-      if (cores[i] > max_core) {
-        ERROR(RDT_PLUGIN ": Core group (%s) contains invalid core id (%d)",
-              item->values[j].value.string, (int)cores[i]);
-        return (-EINVAL);
-      }
-    }
-
     /* set core group info */
     ret = cgroup_set(&groups[index], item->values[j].value.string, cores, n);
     if (ret < 0)
@@ -395,6 +386,15 @@ static int rdt_default_cgroups(void) {
   return g_rdt->pqos_cpu->num_cores;
 }
 
+static int rdt_is_core_id_valid(int core_id) {
+
+  for (int i = 0; i < g_rdt->pqos_cpu->num_cores; i++)
+    if (core_id == g_rdt->pqos_cpu->cores[i].lcore)
+      return 1;
+
+  return 0;
+}
+
 static int rdt_config_cgroups(oconfig_item_t *item) {
   int n = 0;
   enum pqos_mon_event events = 0;
@@ -413,14 +413,27 @@ static int rdt_config_cgroups(oconfig_item_t *item) {
     DEBUG(RDT_PLUGIN ":  [%d]: %s", j, item->values[j].value.string);
   }
 
-  n = oconfig_to_cgroups(item, g_rdt->cgroups, RDT_MAX_CORES,
-                         g_rdt->pqos_cpu->num_cores - 1);
+  n = oconfig_to_cgroups(item, g_rdt->cgroups, g_rdt->pqos_cpu->num_cores);
   if (n < 0) {
     rdt_free_cgroups();
     ERROR(RDT_PLUGIN ": Error parsing core groups configuration.");
     return (-EINVAL);
   }
 
+  /* validate configured core id values */
+  for (int group_idx = 0; group_idx < n; group_idx++) {
+    for (int core_idx = 0; core_idx < g_rdt->cgroups[group_idx].num_cores;
+         core_idx++) {
+      if (!rdt_is_core_id_valid(g_rdt->cgroups[group_idx].cores[core_idx])) {
+        ERROR(RDT_PLUGIN ": Core group '%s' contains invalid core id '%d'",
+                g_rdt->cgroups[group_idx].desc,
+                (int)g_rdt->cgroups[group_idx].cores[core_idx]);
+        rdt_free_cgroups();
+        return (-EINVAL);
+      }
+    }
+  }
+
   if (n == 0) {
     /* create default core groups if "Cores" config option is empty */
     n = rdt_default_cgroups();
index 8c2cd12..d372b87 100644 (file)
@@ -86,7 +86,8 @@ typedef struct ovs_events_ctx_s ovs_events_ctx_t;
  */
 static ovs_events_ctx_t ovs_events_ctx = {
     .mutex = PTHREAD_MUTEX_INITIALIZER,
-    .config = {.ovs_db_node = "localhost", /* use default OVS DB node */
+    .config = {.send_notification = 1,     /* send notification by default */
+               .ovs_db_node = "localhost", /* use default OVS DB node */
                .ovs_db_serv = "6640"}      /* use default OVS DB service */
 };
 
@@ -227,7 +228,7 @@ static int ovs_events_config_get_interfaces(const oconfig_item_t *ci) {
  * in allocated memory. Returns negative value in case of error.
  */
 static int ovs_events_plugin_config(oconfig_item_t *ci) {
-  _Bool dispatch_values = 1;
+  _Bool dispatch_values = 0;
   for (int i = 0; i < ci->children_num; i++) {
     oconfig_item_t *child = ci->children + i;
     if (strcasecmp("SendNotification", child->key) == 0) {
index 77dc1f2..23b7533 100644 (file)
@@ -155,7 +155,7 @@ static ovs_stats_config_t ovs_stats_cfg = {
     .ovs_db_serv = "6640",      /* use default OVS DB service */
 };
 
-static const iface_counter ovs_stats_counter_name_to_type(const char *counter) {
+static iface_counter ovs_stats_counter_name_to_type(const char *counter) {
   iface_counter index = not_supported;
 
   if (counter == NULL)
@@ -349,13 +349,15 @@ static int ovs_stats_update_bridge(yajl_val bridge) {
       if (br_ports && YAJL_IS_ARRAY(br_ports)) {
         char *tmp = YAJL_GET_STRING(br_ports->u.array.values[0]);
         if (tmp != NULL && strcmp("set", tmp) == 0) {
-          yajl_val *ports_arr =
-              YAJL_GET_ARRAY(br_ports->u.array.values[1])->values;
-          size_t ports_num = YAJL_GET_ARRAY(br_ports->u.array.values[1])->len;
-
-          for (int i = 0; i < ports_num; i++)
-            ovs_stats_new_port(
-                br, YAJL_GET_STRING(ports_arr[i]->u.array.values[1]));
+          yajl_val *array = YAJL_GET_ARRAY(br_ports)->values;
+          size_t array_len = YAJL_GET_ARRAY(br_ports)->len;
+          if (array != NULL && array_len > 0 && YAJL_IS_ARRAY(array[1])) {
+            yajl_val *ports_arr = YAJL_GET_ARRAY(array[1])->values;
+            size_t ports_num = YAJL_GET_ARRAY(array[1])->len;
+            for (size_t i = 0; i < ports_num && ports_arr != NULL; i++)
+              ovs_stats_new_port(
+                  br, YAJL_GET_STRING(ports_arr[i]->u.array.values[1]));
+          }
         } else
           ovs_stats_new_port(br, YAJL_GET_STRING(br_ports->u.array.values[1]));
       }
@@ -398,7 +400,7 @@ static void ovs_stats_bridge_table_change_cb(yajl_val jupdates) {
   yajl_val bridges = yajl_tree_get(jupdates, path, yajl_t_object);
 
   if (bridges && YAJL_IS_OBJECT(bridges)) {
-    for (int i = 0; i < YAJL_GET_OBJECT(bridges)->len; i++) {
+    for (size_t i = 0; i < YAJL_GET_OBJECT(bridges)->len; i++) {
       yajl_val bridge = YAJL_GET_OBJECT(bridges)->values[i];
       ovs_stats_update_bridge(bridge);
     }
@@ -412,7 +414,7 @@ static void ovs_stats_bridge_table_delete_cb(yajl_val jupdates) {
   yajl_val bridge;
   if (bridges && YAJL_IS_OBJECT(bridges)) {
     pthread_mutex_lock(&g_stats_lock);
-    for (int i = 0; i < YAJL_GET_OBJECT(bridges)->len; i++) {
+    for (size_t i = 0; i < YAJL_GET_OBJECT(bridges)->len; i++) {
       bridge = YAJL_GET_OBJECT(bridges)->values[i];
       ovs_stats_del_bridge(bridge);
     }
@@ -498,7 +500,7 @@ static void ovs_stats_port_table_change_cb(yajl_val jupdates) {
   yajl_val ports = yajl_tree_get(jupdates, path, yajl_t_object);
   yajl_val port;
   if (ports && YAJL_IS_OBJECT(ports)) {
-    for (int i = 0; i < YAJL_GET_OBJECT(ports)->len; i++) {
+    for (size_t i = 0; i < YAJL_GET_OBJECT(ports)->len; i++) {
       port = YAJL_GET_OBJECT(ports)->values[i];
       ovs_stats_update_port(YAJL_GET_OBJECT(ports)->keys[i], port);
     }
@@ -521,7 +523,7 @@ static void ovs_stats_port_table_delete_cb(yajl_val jupdates) {
   yajl_val ports = yajl_tree_get(jupdates, path, yajl_t_object);
   pthread_mutex_lock(&g_stats_lock);
   if (ports && YAJL_IS_OBJECT(ports))
-    for (int i = 0; i < YAJL_GET_OBJECT(ports)->len; i++) {
+    for (size_t i = 0; i < YAJL_GET_OBJECT(ports)->len; i++) {
       ovs_stats_del_port(YAJL_GET_OBJECT(ports)->keys[i]);
     }
   pthread_mutex_unlock(&g_stats_lock);
@@ -535,8 +537,10 @@ static int ovs_stats_update_iface_stats(port_list_t *port, yajl_val stats) {
   char *counter_name = NULL;
   int64_t counter_value = 0;
   if (stats && YAJL_IS_ARRAY(stats))
-    for (int i = 0; i < YAJL_GET_ARRAY(stats)->len; i++) {
+    for (size_t i = 0; i < YAJL_GET_ARRAY(stats)->len; i++) {
       stat = YAJL_GET_ARRAY(stats)->values[i];
+      if (!YAJL_IS_ARRAY(stat))
+        return (-1);
       counter_name = YAJL_GET_STRING(YAJL_GET_ARRAY(stat)->values[0]);
       counter_index = ovs_stats_counter_name_to_type(counter_name);
       counter_value = YAJL_GET_INTEGER(YAJL_GET_ARRAY(stat)->values[1]);
@@ -555,8 +559,10 @@ static int ovs_stats_update_iface_ext_ids(port_list_t *port, yajl_val ext_ids) {
   char *value;
 
   if (ext_ids && YAJL_IS_ARRAY(ext_ids))
-    for (int i = 0; i < YAJL_GET_ARRAY(ext_ids)->len; i++) {
+    for (size_t i = 0; i < YAJL_GET_ARRAY(ext_ids)->len; i++) {
       ext_id = YAJL_GET_ARRAY(ext_ids)->values[i];
+      if (!YAJL_IS_ARRAY(ext_id))
+        return (-1);
       key = YAJL_GET_STRING(YAJL_GET_ARRAY(ext_id)->values[0]);
       value = YAJL_GET_STRING(YAJL_GET_ARRAY(ext_id)->values[1]);
       if (key && value) {
@@ -681,7 +687,7 @@ static void ovs_stats_interface_table_change_cb(yajl_val jupdates) {
   yajl_val ports = yajl_tree_get(jupdates, path, yajl_t_object);
   pthread_mutex_lock(&g_stats_lock);
   if (ports && YAJL_IS_OBJECT(ports))
-    for (int i = 0; i < YAJL_GET_OBJECT(ports)->len; i++)
+    for (size_t i = 0; i < YAJL_GET_OBJECT(ports)->len; i++)
       ovs_stats_update_iface(YAJL_GET_OBJECT(ports)->values[i]);
   pthread_mutex_unlock(&g_stats_lock);
   return;
@@ -875,7 +881,7 @@ static int ovs_stats_plugin_init(void) {
 static int ovs_stats_plugin_read(__attribute__((unused)) user_data_t *ud) {
   bridge_list_t *bridge;
   port_list_t *port;
-  char devname[PORT_NAME_SIZE_MAX];
+  char devname[PORT_NAME_SIZE_MAX * 2];
 
   pthread_mutex_lock(&g_stats_lock);
   for (bridge = g_bridge_list_head; bridge != NULL; bridge = bridge->next) {
index 9e8950b..25a5512 100644 (file)
@@ -136,23 +136,21 @@ cmd_status_t cmd_handle_flush(FILE *fh, char *buffer) {
 
     for (size_t j = 0; (j == 0) || (j < cmd.cmd.flush.identifiers_num); j++) {
       char *identifier = NULL;
-      char buffer[1024];
-      int status;
+      char buf[1024];
 
       if (cmd.cmd.flush.identifiers_num != 0) {
         identifier_t *id = cmd.cmd.flush.identifiers + j;
-        if (format_name(buffer, sizeof(buffer), id->host, id->plugin,
+        if (format_name(buf, sizeof(buf), id->host, id->plugin,
                         id->plugin_instance, id->type,
                         id->type_instance) != 0) {
           error++;
           continue;
         }
-        identifier = buffer;
+        identifier = buf;
       }
 
-      status = plugin_flush(plugin, DOUBLE_TO_CDTIME_T(cmd.cmd.flush.timeout),
-                            identifier);
-      if (status == 0)
+      if (plugin_flush(plugin, DOUBLE_TO_CDTIME_T(cmd.cmd.flush.timeout),
+                       identifier) == 0)
         success++;
       else
         error++;
index 57da628..65e6679 100644 (file)
@@ -330,6 +330,9 @@ static yajl_gen_status ovs_yajl_gen_val(yajl_gen jgen, yajl_val jval) {
   size_t obj_len = 0;
   yajl_gen_status yajl_gen_ret = yajl_gen_status_ok;
 
+  if (jval == NULL)
+    return yajl_gen_generation_complete;
+
   if (YAJL_IS_STRING(jval))
     OVS_YAJL_CALL(ovs_yajl_gen_tstring, jgen, YAJL_GET_STRING(jval));
   else if (YAJL_IS_DOUBLE(jval))
@@ -566,7 +569,11 @@ static int ovs_db_json_data_process(ovs_db_t *pdb, const char *data,
 
   /* get method name */
   if ((jval = yajl_tree_get(jnode, method_path, yajl_t_string)) != NULL) {
-    method = YAJL_GET_STRING(jval);
+    if ((method = YAJL_GET_STRING(jval)) == NULL) {
+      yajl_tree_free(jnode);
+      sfree(sjson);
+      return (-1);
+    }
     if (strcmp("echo", method) == 0) {
       /* echo request from the server */
       if (ovs_db_table_echo_cb(pdb, jnode) < 0)
index 692088c..e95a31b 100644 (file)
@@ -414,7 +414,7 @@ static void memory_stats_submit(gauge_t value, virDomainPtr dom,
                                "minor_fault",    "unused",   "available",
                                "actual_balloon", "rss"};
 
-  if ((tag_index < 0) || (tag_index >= STATIC_ARRAY_SIZE(tags))) {
+  if ((tag_index < 0) || (tag_index >= (int)STATIC_ARRAY_SIZE(tags))) {
     ERROR("virt plugin: Array index out of bounds: tag_index = %d", tag_index);
     return;
   }