X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftarget_v5upgrade.c;h=49f09f083cc81540bd701dd34eb3ead06847aaaa;hb=e746ad785774de37a30302fef65f1c4aaf8698ab;hp=ea0157b3a7d5b6d33e65e63c66819f7f7bd5f688;hpb=2079ee1517e34de372f58e7e2267ad5c71a8a41f;p=collectd.git diff --git a/src/target_v5upgrade.c b/src/target_v5upgrade.c index ea0157b3..49f09f08 100644 --- a/src/target_v5upgrade.c +++ b/src/target_v5upgrade.c @@ -53,17 +53,16 @@ static void v5_swap_instances(value_list_t *vl) /* {{{ */ static int v5_df(const data_set_t *ds, value_list_t *vl) /* {{{ */ { value_list_t new_vl; - value_t new_value; /* Can't upgrade if both instances have been set. */ if ((vl->plugin_instance[0] != 0) && (vl->type_instance[0] != 0)) - return (FC_TARGET_CONTINUE); + return FC_TARGET_CONTINUE; /* Copy everything: Time, interval, host, ... */ memcpy(&new_vl, vl, sizeof(new_vl)); /* Reset data we can't simply copy */ - new_vl.values = &new_value; + new_vl.values = &(value_t){.gauge = NAN}; new_vl.values_len = 1; new_vl.meta = NULL; @@ -84,7 +83,7 @@ static int v5_df(const data_set_t *ds, value_list_t *vl) /* {{{ */ plugin_dispatch_values(&new_vl); /* Abort processing */ - return (FC_TARGET_STOP); + return FC_TARGET_STOP; } /* }}} int v5_df */ /* @@ -97,10 +96,10 @@ static int v5_df(const data_set_t *ds, value_list_t *vl) /* {{{ */ static int v5_interface(const data_set_t *ds, value_list_t *vl) /* {{{ */ { if ((vl->plugin_instance[0] != 0) || (vl->type_instance[0] == 0)) - return (FC_TARGET_CONTINUE); + return FC_TARGET_CONTINUE; v5_swap_instances(vl); - return (FC_TARGET_CONTINUE); + return FC_TARGET_CONTINUE; } /* }}} int v5_interface */ /* @@ -112,16 +111,15 @@ static int v5_interface(const data_set_t *ds, value_list_t *vl) /* {{{ */ static int v5_mysql_qcache(const data_set_t *ds, value_list_t *vl) /* {{{ */ { value_list_t new_vl; - value_t new_value; if (vl->values_len != 5) - return (FC_TARGET_STOP); + return FC_TARGET_STOP; /* Copy everything: Time, interval, host, ... */ memcpy(&new_vl, vl, sizeof(new_vl)); /* Reset data we can't simply copy */ - new_vl.values = &new_value; + new_vl.values = &(value_t){.gauge = NAN}; new_vl.values_len = 1; new_vl.meta = NULL; @@ -155,7 +153,7 @@ static int v5_mysql_qcache(const data_set_t *ds, value_list_t *vl) /* {{{ */ plugin_dispatch_values(&new_vl); /* Abort processing */ - return (FC_TARGET_STOP); + return FC_TARGET_STOP; } /* }}} int v5_mysql_qcache */ /* @@ -167,16 +165,15 @@ static int v5_mysql_qcache(const data_set_t *ds, value_list_t *vl) /* {{{ */ static int v5_mysql_threads(const data_set_t *ds, value_list_t *vl) /* {{{ */ { value_list_t new_vl; - value_t new_value; if (vl->values_len != 4) - return (FC_TARGET_STOP); + return FC_TARGET_STOP; /* Copy everything: Time, interval, host, ... */ memcpy(&new_vl, vl, sizeof(new_vl)); /* Reset data we can't simply copy */ - new_vl.values = &new_value; + new_vl.values = &(value_t){.gauge = NAN}; new_vl.values_len = 1; new_vl.meta = NULL; @@ -204,7 +201,7 @@ static int v5_mysql_threads(const data_set_t *ds, value_list_t *vl) /* {{{ */ plugin_dispatch_values(&new_vl); /* Abort processing */ - return (FC_TARGET_STOP); + return FC_TARGET_STOP; } /* }}} int v5_mysql_threads */ /* @@ -216,24 +213,23 @@ static int v5_mysql_threads(const data_set_t *ds, value_list_t *vl) /* {{{ */ static int v5_zfs_arc_counts(const data_set_t *ds, value_list_t *vl) /* {{{ */ { value_list_t new_vl; - value_t new_value; _Bool is_hits; if (vl->values_len != 4) - return (FC_TARGET_STOP); + return FC_TARGET_STOP; if (strcmp("hits", vl->type_instance) == 0) is_hits = 1; else if (strcmp("misses", vl->type_instance) == 0) is_hits = 0; else - return (FC_TARGET_STOP); + return FC_TARGET_STOP; /* Copy everything: Time, interval, host, ... */ memcpy(&new_vl, vl, sizeof(new_vl)); /* Reset data we can't simply copy */ - new_vl.values = &new_value; + new_vl.values = &(value_t){.gauge = NAN}; new_vl.values_len = 1; new_vl.meta = NULL; @@ -242,27 +238,27 @@ static int v5_zfs_arc_counts(const data_set_t *ds, value_list_t *vl) /* {{{ */ /* Dispatch new value lists instead of this one */ new_vl.values[0].derive = (derive_t)vl->values[0].counter; - ssnprintf(new_vl.type_instance, sizeof(new_vl.type_instance), - "demand_data-%s", is_hits ? "hit" : "miss"); + snprintf(new_vl.type_instance, sizeof(new_vl.type_instance), "demand_data-%s", + is_hits ? "hit" : "miss"); plugin_dispatch_values(&new_vl); new_vl.values[0].derive = (derive_t)vl->values[1].counter; - ssnprintf(new_vl.type_instance, sizeof(new_vl.type_instance), - "demand_metadata-%s", is_hits ? "hit" : "miss"); + snprintf(new_vl.type_instance, sizeof(new_vl.type_instance), + "demand_metadata-%s", is_hits ? "hit" : "miss"); plugin_dispatch_values(&new_vl); new_vl.values[0].derive = (derive_t)vl->values[2].counter; - ssnprintf(new_vl.type_instance, sizeof(new_vl.type_instance), - "prefetch_data-%s", is_hits ? "hit" : "miss"); + snprintf(new_vl.type_instance, sizeof(new_vl.type_instance), + "prefetch_data-%s", is_hits ? "hit" : "miss"); plugin_dispatch_values(&new_vl); new_vl.values[0].derive = (derive_t)vl->values[3].counter; - ssnprintf(new_vl.type_instance, sizeof(new_vl.type_instance), - "prefetch_metadata-%s", is_hits ? "hit" : "miss"); + snprintf(new_vl.type_instance, sizeof(new_vl.type_instance), + "prefetch_metadata-%s", is_hits ? "hit" : "miss"); plugin_dispatch_values(&new_vl); /* Abort processing */ - return (FC_TARGET_STOP); + return FC_TARGET_STOP; } /* }}} int v5_zfs_arc_counts */ /* @@ -273,17 +269,14 @@ static int v5_zfs_arc_counts(const data_set_t *ds, value_list_t *vl) /* {{{ */ static int v5_zfs_arc_l2_bytes(const data_set_t *ds, value_list_t *vl) /* {{{ */ { value_list_t new_vl; - value_t new_values[2]; if (vl->values_len != 2) - return (FC_TARGET_STOP); + return FC_TARGET_STOP; /* Copy everything: Time, interval, host, ... */ memcpy(&new_vl, vl, sizeof(new_vl)); /* Reset data we can't simply copy */ - new_vl.values = new_values; - new_vl.values_len = 2; new_vl.meta = NULL; /* Change the type/-instance to "io_octets-L2" */ @@ -291,14 +284,18 @@ static int v5_zfs_arc_l2_bytes(const data_set_t *ds, value_list_t *vl) /* {{{ */ sstrncpy(new_vl.type_instance, "L2", sizeof(new_vl.type_instance)); /* Copy the actual values. */ - new_vl.values[0].derive = (derive_t)vl->values[0].counter; - new_vl.values[1].derive = (derive_t)vl->values[1].counter; + value_t values[] = { + {.derive = (derive_t)vl->values[0].counter}, + {.derive = (derive_t)vl->values[1].counter}, + }; + new_vl.values = values; + new_vl.values_len = STATIC_ARRAY_SIZE(values); /* Dispatch new value lists instead of this one */ plugin_dispatch_values(&new_vl); /* Abort processing */ - return (FC_TARGET_STOP); + return FC_TARGET_STOP; } /* }}} int v5_zfs_arc_l2_bytes */ /* @@ -310,16 +307,15 @@ static int v5_zfs_arc_l2_bytes(const data_set_t *ds, value_list_t *vl) /* {{{ */ static int v5_zfs_arc_l2_size(const data_set_t *ds, value_list_t *vl) /* {{{ */ { value_list_t new_vl; - value_t new_value; if (vl->values_len != 1) - return (FC_TARGET_STOP); + return FC_TARGET_STOP; /* Copy everything: Time, interval, host, ... */ memcpy(&new_vl, vl, sizeof(new_vl)); /* Reset data we can't simply copy */ - new_vl.values = &new_value; + new_vl.values = &(value_t){.gauge = NAN}; new_vl.values_len = 1; new_vl.meta = NULL; @@ -335,7 +331,7 @@ static int v5_zfs_arc_l2_size(const data_set_t *ds, value_list_t *vl) /* {{{ */ plugin_dispatch_values(&new_vl); /* Abort processing */ - return (FC_TARGET_STOP); + return FC_TARGET_STOP; } /* }}} int v5_zfs_arc_l2_size */ /* @@ -347,16 +343,15 @@ static int v5_zfs_arc_l2_size(const data_set_t *ds, value_list_t *vl) /* {{{ */ static int v5_zfs_arc_ratio(const data_set_t *ds, value_list_t *vl) /* {{{ */ { value_list_t new_vl; - value_t new_value; if (vl->values_len != 1) - return (FC_TARGET_STOP); + return FC_TARGET_STOP; /* Copy everything: Time, interval, host, ... */ memcpy(&new_vl, vl, sizeof(new_vl)); /* Reset data we can't simply copy */ - new_vl.values = &new_value; + new_vl.values = &(value_t){.gauge = NAN}; new_vl.values_len = 1; new_vl.meta = NULL; @@ -373,7 +368,7 @@ static int v5_zfs_arc_ratio(const data_set_t *ds, value_list_t *vl) /* {{{ */ plugin_dispatch_values(&new_vl); /* Abort processing */ - return (FC_TARGET_STOP); + return FC_TARGET_STOP; } /* }}} int v5_zfs_arc_ratio */ /* @@ -385,16 +380,15 @@ static int v5_zfs_arc_ratio(const data_set_t *ds, value_list_t *vl) /* {{{ */ static int v5_zfs_arc_size(const data_set_t *ds, value_list_t *vl) /* {{{ */ { value_list_t new_vl; - value_t new_value; if (vl->values_len != 4) - return (FC_TARGET_STOP); + return FC_TARGET_STOP; /* Copy everything: Time, interval, host, ... */ memcpy(&new_vl, vl, sizeof(new_vl)); /* Reset data we can't simply copy */ - new_vl.values = &new_value; + new_vl.values = &(value_t){.gauge = NAN}; new_vl.values_len = 1; new_vl.meta = NULL; @@ -407,46 +401,46 @@ static int v5_zfs_arc_size(const data_set_t *ds, value_list_t *vl) /* {{{ */ plugin_dispatch_values(&new_vl); /* Abort processing */ - return (FC_TARGET_STOP); + return FC_TARGET_STOP; } /* }}} int v5_zfs_arc_size */ static int v5_destroy(void **user_data) /* {{{ */ { - return (0); + return 0; } /* }}} int v5_destroy */ static int v5_create(const oconfig_item_t *ci, void **user_data) /* {{{ */ { *user_data = NULL; - return (0); + return 0; } /* }}} int v5_create */ static int v5_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */ notification_meta_t __attribute__((unused)) * *meta, void __attribute__((unused)) * *user_data) { if ((ds == NULL) || (vl == NULL) || (user_data == NULL)) - return (-EINVAL); + return -EINVAL; if (strcmp("df", vl->type) == 0) - return (v5_df(ds, vl)); + return v5_df(ds, vl); else if (strcmp("interface", vl->plugin) == 0) - return (v5_interface(ds, vl)); + return v5_interface(ds, vl); else if (strcmp("mysql_qcache", vl->type) == 0) - return (v5_mysql_qcache(ds, vl)); + return v5_mysql_qcache(ds, vl); else if (strcmp("mysql_threads", vl->type) == 0) - return (v5_mysql_threads(ds, vl)); + return v5_mysql_threads(ds, vl); else if (strcmp("arc_counts", vl->type) == 0) - return (v5_zfs_arc_counts(ds, vl)); + return v5_zfs_arc_counts(ds, vl); else if (strcmp("arc_l2_bytes", vl->type) == 0) - return (v5_zfs_arc_l2_bytes(ds, vl)); + return v5_zfs_arc_l2_bytes(ds, vl); else if (strcmp("arc_l2_size", vl->type) == 0) - return (v5_zfs_arc_l2_size(ds, vl)); + return v5_zfs_arc_l2_size(ds, vl); else if (strcmp("arc_ratio", vl->type) == 0) - return (v5_zfs_arc_ratio(ds, vl)); + return v5_zfs_arc_ratio(ds, vl); else if (strcmp("arc_size", vl->type) == 0) - return (v5_zfs_arc_size(ds, vl)); + return v5_zfs_arc_size(ds, vl); - return (FC_TARGET_CONTINUE); + return FC_TARGET_CONTINUE; } /* }}} int v5_invoke */ void module_register(void) { @@ -457,5 +451,3 @@ void module_register(void) { tproc.invoke = v5_invoke; fc_register_target("v5upgrade", tproc); } /* module_register */ - -/* vim: set sw=2 sts=2 tw=78 et fdm=marker : */