From: Mytnyk, VolodymyrX Date: Tue, 27 Sep 2016 13:36:26 +0000 (+0100) Subject: ovs_events: Fix plugin collectd config file X-Git-Tag: collectd-5.8.0~256^2~12 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=cb59d853d855d9ccbbd30819db3e1fb96f35482e ovs_events: Fix plugin collectd config file - Fix Ubuntu compilation warnings. Change-Id: I7bb72ec0ca732b00c4169e0174d64407d99a2751 Signed-off-by: Mytnyk, VolodymyrX --- diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 7396286c..ae4f6022 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -168,7 +168,7 @@ #@BUILD_PLUGIN_OPENLDAP_TRUE@LoadPlugin openldap #@BUILD_PLUGIN_OPENVPN_TRUE@LoadPlugin openvpn #@BUILD_PLUGIN_ORACLE_TRUE@LoadPlugin oracle -#@BUILD_PLUGIN_OVS_LINK_TRUE@LoadPlugin ovs_events +#@BUILD_PLUGIN_OVS_EVENTS_TRUE@LoadPlugin ovs_events #@BUILD_PLUGIN_PERL_TRUE@LoadPlugin perl #@BUILD_PLUGIN_PINBA_TRUE@LoadPlugin pinba #@BUILD_PLUGIN_PING_TRUE@LoadPlugin ping diff --git a/src/ovs_events.c b/src/ovs_events.c index f971d111..2eedf99d 100644 --- a/src/ovs_events.c +++ b/src/ovs_events.c @@ -276,27 +276,27 @@ ovs_events_dispatch_notification(const ovs_events_iface_info_t *ifinfo) n.severity = NOTIF_WARNING; break; default: - ERROR(OVS_EVENTS_PLUGIN, ": unknown interface link status"); + ERROR(OVS_EVENTS_PLUGIN ": unknown interface link status"); return; } /* add interface metadata to the notification */ if (plugin_notification_meta_add_string(&n, "uuid", ifinfo->uuid) < 0) { - ERROR(OVS_EVENTS_PLUGIN, ": add interface uuid meta data failed"); + ERROR(OVS_EVENTS_PLUGIN ": add interface uuid meta data failed"); return; } if (strlen(ifinfo->ext_vm_uuid) > 0) if (plugin_notification_meta_add_string (&n, "vm-uuid", ifinfo->ext_vm_uuid) < 0) { - ERROR(OVS_EVENTS_PLUGIN, ": add interface vm-uuid meta data failed"); + ERROR(OVS_EVENTS_PLUGIN ": add interface vm-uuid meta data failed"); return; } if (strlen(ifinfo->ext_iface_id) > 0) if (plugin_notification_meta_add_string (&n, "iface-id", ifinfo->ext_iface_id) < 0) { - ERROR(OVS_EVENTS_PLUGIN, ": add interface iface-id meta data failed"); + ERROR(OVS_EVENTS_PLUGIN ": add interface iface-id meta data failed"); return; } @@ -322,15 +322,15 @@ ovs_events_link_status_submit(const ovs_events_iface_info_t *ifinfo) /* add interface metadata to the submit value */ if ((meta = meta_data_create()) != NULL) { if (meta_data_add_string(meta, "uuid", ifinfo->uuid) < 0) - ERROR(OVS_EVENTS_PLUGIN, ": add interface uuid meta data failed"); + ERROR(OVS_EVENTS_PLUGIN ": add interface uuid meta data failed"); if (strlen(ifinfo->ext_vm_uuid) > 0) if (meta_data_add_string(meta, "vm-uuid", ifinfo->ext_vm_uuid) < 0) - ERROR(OVS_EVENTS_PLUGIN, ": add interface vm-uuid meta data failed"); + ERROR(OVS_EVENTS_PLUGIN ": add interface vm-uuid meta data failed"); if (strlen(ifinfo->ext_iface_id) > 0) if (meta_data_add_string(meta, "iface-id", ifinfo->ext_iface_id) < 0) - ERROR(OVS_EVENTS_PLUGIN, ": add interface iface-id meta data failed"); + ERROR(OVS_EVENTS_PLUGIN ": add interface iface-id meta data failed"); vl.meta = meta; } else ERROR(OVS_EVENTS_PLUGIN ": create metadata failed"); @@ -354,7 +354,7 @@ ovs_events_dispatch_terminate_notification(const char *msg) { notification_t n = {NOTIF_FAILURE, cdtime(), "", "", OVS_EVENTS_PLUGIN, "", "", "", NULL}; - ssnprintf(n.message, sizeof(n.message), msg); + sstrncpy(n.message, msg, sizeof(n.message)); sstrncpy(n.host, hostname_g, sizeof(n.host)); plugin_dispatch_notification(&n); } @@ -367,10 +367,11 @@ ovs_events_get_iface_info(yajl_val jobject, ovs_events_iface_info_t *ifinfo) yajl_val jexternal_ids = NULL; yajl_val jvalue = NULL; yajl_val juuid = NULL; + const char *state = NULL; /* check YAJL type */ if (!YAJL_IS_OBJECT(jobject)) - return NULL; + return (-1); /* try to find external_ids, name and link_state fields */ jexternal_ids = ovs_utils_get_value_by_key(jobject, "external_ids"); @@ -407,11 +408,11 @@ ovs_events_get_iface_info(yajl_val jobject, ovs_events_iface_info_t *ifinfo) /* get OVS DB interface link status */ jvalue = ovs_utils_get_value_by_key(jobject, "link_state"); - if (jvalue != NULL && YAJL_IS_STRING(jvalue)) { + if (jvalue != NULL && ((state = YAJL_GET_STRING(jvalue)) != NULL)) { /* convert OVS table link state to link status */ - if (strcmp(YAJL_GET_STRING(jvalue), "up") == 0) + if (strcmp(state, "up") == 0) ifinfo->link_status = UP; - else if (strcmp(YAJL_GET_STRING(jvalue), "down") == 0) + else if (strcmp(state, "down") == 0) ifinfo->link_status = DOWN; } return (0); diff --git a/src/utils_ovs.c b/src/utils_ovs.c index 983f249a..636a38d2 100644 --- a/src/utils_ovs.c +++ b/src/utils_ovs.c @@ -373,7 +373,7 @@ ovs_db_url_parse(const char *surl, ovs_conn_t *conn) return (0); failure: - OVS_ERROR("%s() : invalid OVS DB URL provided"); + OVS_ERROR("invalid OVS DB URL provided [url=%s]", surl); sfree(in_str); return (-1); } @@ -636,7 +636,7 @@ ovs_db_json_data_process(ovs_db_t *pdb, const char *data, size_t len) return (-1); sstrncpy(sjson, data, len + 1); - OVS_DEBUG("[len=%d] %s", len, sjson); + OVS_DEBUG("[len=%zu] %s", len, sjson); /* parse json data */ jnode = yajl_tree_parse(sjson, yajl_errbuf, sizeof(yajl_errbuf)); @@ -1309,6 +1309,7 @@ ovs_utils_get_map_value(yajl_val jval, const char *key) size_t array_len = 0; yajl_val *map_values = NULL; yajl_val *array_values = NULL; + const char *str_val = NULL; /* check YAJL array */ if (!YAJL_IS_ARRAY(jval) || (key == NULL)) @@ -1322,7 +1323,8 @@ ovs_utils_get_map_value(yajl_val jval, const char *key) return NULL; /* check first element of the array */ - if (strcmp("map", YAJL_GET_STRING(array_values[0])) != 0) + str_val = YAJL_GET_STRING(array_values[0]); + if (strcmp("map", str_val) != 0) return NULL; /* try to find map value by map key */ @@ -1341,7 +1343,8 @@ ovs_utils_get_map_value(yajl_val jval, const char *key) break; /* return map value if given key equals map key */ - if (strcmp(key, YAJL_GET_STRING(array_values[0])) == 0) + str_val = YAJL_GET_STRING(array_values[0]); + if (strcmp(key, str_val) == 0) return array_values[1]; } return NULL;