X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fnetapp.c;h=281764c7324f9071bb3c316f2a07fdb90ce55876;hp=45144bf1e964d227bea685dd7081ecf17f0f1e30;hb=d486225f89ea52d8ed2b4242eba2ad94c409f837;hpb=11c8a760c2d354b2f4637bdb297efb253bfaa519 diff --git a/src/netapp.c b/src/netapp.c index 45144bf1..281764c7 100644 --- a/src/netapp.c +++ b/src/netapp.c @@ -459,7 +459,7 @@ static disk_t *get_disk(cfg_disk_t *cd, const char *name) /* {{{ */ disk_t *d; if ((cd == NULL) || (name == NULL)) - return (NULL); + return NULL; for (d = cd->disks; d != NULL; d = d->next) { if (strcmp(d->name, name) == 0) @@ -468,13 +468,13 @@ static disk_t *get_disk(cfg_disk_t *cd, const char *name) /* {{{ */ d = calloc(1, sizeof(*d)); if (d == NULL) - return (NULL); + return NULL; d->next = NULL; d->name = strdup(name); if (d->name == NULL) { sfree(d); - return (NULL); + return NULL; } d->next = cd->disks; @@ -492,12 +492,12 @@ static data_volume_usage_t *get_volume_usage(cfg_volume_usage_t *cvu, /* {{{ */ int ignore_snapshot = 0; if ((cvu == NULL) || (name == NULL)) - return (NULL); + return NULL; last = cvu->volumes; while (last != NULL) { if (strcmp(last->name, name) == 0) - return (last); + return last; if (last->next == NULL) break; @@ -510,18 +510,18 @@ static data_volume_usage_t *get_volume_usage(cfg_volume_usage_t *cvu, /* {{{ */ ignore_capacity = ignorelist_match(cvu->il_capacity, name); ignore_snapshot = ignorelist_match(cvu->il_snapshot, name); if ((ignore_capacity != 0) && (ignore_snapshot != 0)) - return (NULL); + return NULL; /* Not found: allocate. */ new = calloc(1, sizeof(*new)); if (new == NULL) - return (NULL); + return NULL; new->next = NULL; new->name = strdup(name); if (new->name == NULL) { sfree(new); - return (NULL); + return NULL; } if (ignore_capacity == 0) @@ -541,7 +541,7 @@ static data_volume_usage_t *get_volume_usage(cfg_volume_usage_t *cvu, /* {{{ */ else last->next = new; - return (new); + return new; } /* }}} data_volume_usage_t *get_volume_usage */ static data_volume_perf_t *get_volume_perf(cfg_volume_perf_t *cvp, /* {{{ */ @@ -554,12 +554,12 @@ static data_volume_perf_t *get_volume_perf(cfg_volume_perf_t *cvp, /* {{{ */ int ignore_latency = 0; if ((cvp == NULL) || (name == NULL)) - return (NULL); + return NULL; last = cvp->volumes; while (last != NULL) { if (strcmp(last->name, name) == 0) - return (last); + return last; if (last->next == NULL) break; @@ -573,18 +573,18 @@ static data_volume_perf_t *get_volume_perf(cfg_volume_perf_t *cvp, /* {{{ */ ignore_operations = ignorelist_match(cvp->il_operations, name); ignore_latency = ignorelist_match(cvp->il_latency, name); if ((ignore_octets != 0) || (ignore_operations != 0) || (ignore_latency != 0)) - return (NULL); + return NULL; /* Not found: allocate. */ new = calloc(1, sizeof(*new)); if (new == NULL) - return (NULL); + return NULL; new->next = NULL; new->name = strdup(name); if (new->name == NULL) { sfree(new); - return (NULL); + return NULL; } if (ignore_octets == 0) @@ -600,7 +600,7 @@ static data_volume_perf_t *get_volume_perf(cfg_volume_perf_t *cvp, /* {{{ */ else last->next = new; - return (new); + return new; } /* }}} data_volume_perf_t *get_volume_perf */ /* @@ -634,7 +634,7 @@ static int submit_values(const char *host, /* {{{ */ if (type_inst != NULL) sstrncpy(vl.type_instance, type_inst, sizeof(vl.type_instance)); - return (plugin_dispatch_values(&vl)); + return plugin_dispatch_values(&vl); } /* }}} int submit_uint64 */ static int submit_two_derive(const char *host, @@ -646,16 +646,19 @@ static int submit_two_derive(const char *host, {.derive = val0}, {.derive = val1}, }; - return (submit_values(host, plugin_inst, type, type_inst, values, - STATIC_ARRAY_SIZE(values), timestamp, interval)); + return submit_values(host, plugin_inst, type, type_inst, values, + STATIC_ARRAY_SIZE(values), timestamp, interval); } /* }}} int submit_two_derive */ static int submit_derive(const char *host, const char *plugin_inst, /* {{{ */ const char *type, const char *type_inst, derive_t counter, cdtime_t timestamp, cdtime_t interval) { - return (submit_values(host, plugin_inst, type, type_inst, - &(value_t){.derive = counter}, 1, timestamp, interval)); + return submit_values(host, plugin_inst, type, type_inst, + &(value_t){ + .derive = counter, + }, + 1, timestamp, interval); } /* }}} int submit_derive */ static int submit_two_gauge(const char *host, const char *plugin_inst, /* {{{ */ @@ -666,15 +669,18 @@ static int submit_two_gauge(const char *host, const char *plugin_inst, /* {{{ */ {.gauge = val0}, {.gauge = val1}, }; - return (submit_values(host, plugin_inst, type, type_inst, values, - STATIC_ARRAY_SIZE(values), timestamp, interval)); + return submit_values(host, plugin_inst, type, type_inst, values, + STATIC_ARRAY_SIZE(values), timestamp, interval); } /* }}} int submit_two_gauge */ static int submit_double(const char *host, const char *plugin_inst, /* {{{ */ const char *type, const char *type_inst, double d, cdtime_t timestamp, cdtime_t interval) { - return (submit_values(host, plugin_inst, type, type_inst, - &(value_t){.gauge = d}, 1, timestamp, interval)); + return submit_values(host, plugin_inst, type, type_inst, + &(value_t){ + .gauge = d, + }, + 1, timestamp, interval); } /* }}} int submit_uint64 */ /* Calculate hit ratio from old and new counters and submit the resulting @@ -696,8 +702,8 @@ static int submit_cache_ratio(const char *host, /* {{{ */ v.gauge = 100.0 * ((gauge_t)hits) / ((gauge_t)(hits + misses)); } - return (submit_values(host, plugin_inst, "cache_ratio", type_inst, &v, 1, - timestamp, interval)); + return submit_values(host, plugin_inst, "cache_ratio", type_inst, &v, 1, + timestamp, interval); } /* }}} int submit_cache_ratio */ /* Submits all the caches used by WAFL. Uses "submit_cache_ratio". */ @@ -753,7 +759,7 @@ static int submit_wafl_data(const char *hostname, /* Copy HAVE_* flags */ old_data->flags |= (new_data->flags & HAVE_WAFL_ALL); - return (0); + return 0; } /* }}} int submit_wafl_data */ /* Submits volume performance data to the daemon, taking care to honor and @@ -765,15 +771,16 @@ static int submit_volume_perf_data(const char *hostname, /* {{{ */ char plugin_instance[DATA_MAX_NAME_LEN]; if ((hostname == NULL) || (old_data == NULL) || (new_data == NULL)) - return (-1); + return -1; - ssnprintf(plugin_instance, sizeof(plugin_instance), "volume-%s", - old_data->name); + snprintf(plugin_instance, sizeof(plugin_instance), "volume-%s", + old_data->name); /* Check for and submit disk-octet values */ if (HAS_ALL_FLAGS(old_data->flags, CFG_VOLUME_PERF_IO) && - HAS_ALL_FLAGS(new_data->flags, HAVE_VOLUME_PERF_BYTES_READ | - HAVE_VOLUME_PERF_BYTES_WRITE)) { + HAS_ALL_FLAGS(new_data->flags, + HAVE_VOLUME_PERF_BYTES_READ | + HAVE_VOLUME_PERF_BYTES_WRITE)) { submit_two_derive( hostname, plugin_instance, "disk_octets", /* type instance = */ NULL, (derive_t)new_data->read_bytes, (derive_t)new_data->write_bytes, @@ -791,15 +798,15 @@ static int submit_volume_perf_data(const char *hostname, /* {{{ */ } /* Check for, calculate and submit disk-latency values */ - if (HAS_ALL_FLAGS(old_data->flags, CFG_VOLUME_PERF_LATENCY | - HAVE_VOLUME_PERF_OPS_READ | - HAVE_VOLUME_PERF_OPS_WRITE | - HAVE_VOLUME_PERF_LATENCY_READ | - HAVE_VOLUME_PERF_LATENCY_WRITE) && - HAS_ALL_FLAGS(new_data->flags, HAVE_VOLUME_PERF_OPS_READ | - HAVE_VOLUME_PERF_OPS_WRITE | - HAVE_VOLUME_PERF_LATENCY_READ | - HAVE_VOLUME_PERF_LATENCY_WRITE)) { + if (HAS_ALL_FLAGS(old_data->flags, + CFG_VOLUME_PERF_LATENCY | HAVE_VOLUME_PERF_OPS_READ | + HAVE_VOLUME_PERF_OPS_WRITE | + HAVE_VOLUME_PERF_LATENCY_READ | + HAVE_VOLUME_PERF_LATENCY_WRITE) && + HAS_ALL_FLAGS(new_data->flags, + HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE | + HAVE_VOLUME_PERF_LATENCY_READ | + HAVE_VOLUME_PERF_LATENCY_WRITE)) { gauge_t latency_per_op_read; gauge_t latency_per_op_write; @@ -853,7 +860,7 @@ static int submit_volume_perf_data(const char *hostname, /* {{{ */ /* Copy the HAVE_* flags */ old_data->flags |= (new_data->flags & HAVE_VOLUME_PERF_ALL); - return (0); + return 0; } /* }}} int submit_volume_perf_data */ static cdtime_t cna_child_get_cdtime(na_elem_t *data) /* {{{ */ @@ -862,7 +869,7 @@ static cdtime_t cna_child_get_cdtime(na_elem_t *data) /* {{{ */ t = (time_t)na_child_get_uint64(data, "timestamp", /* default = */ 0); - return (TIME_T_TO_CDTIME_T(t)); + return TIME_T_TO_CDTIME_T(t); } /* }}} cdtime_t cna_child_get_cdtime */ /* @@ -889,7 +896,7 @@ static int cna_handle_wafl_data(const char *hostname, "na_elem_child (\"instances\") failed " "for host %s.", hostname); - return (-1); + return -1; } plugin_inst = na_child_get_string(instances, "name"); @@ -898,7 +905,7 @@ static int cna_handle_wafl_data(const char *hostname, "na_child_get_string (\"name\") failed " "for host %s.", hostname); - return (-1); + return -1; } /* Iterate over all counters */ @@ -948,8 +955,8 @@ static int cna_handle_wafl_data(const char *hostname, } } - return ( - submit_wafl_data(hostname, plugin_inst, cfg_wafl, &perf_data, interval)); + return submit_wafl_data(hostname, plugin_inst, cfg_wafl, &perf_data, + interval); } /* }}} void cna_handle_wafl_data */ static int cna_setup_wafl(cfg_wafl_t *cw) /* {{{ */ @@ -957,15 +964,15 @@ static int cna_setup_wafl(cfg_wafl_t *cw) /* {{{ */ na_elem_t *e; if (cw == NULL) - return (EINVAL); + return EINVAL; if (cw->query != NULL) - return (0); + return 0; cw->query = na_elem_new("perf-object-get-instances"); if (cw->query == NULL) { ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } na_child_add_string(cw->query, "objectname", "wafl"); @@ -974,7 +981,7 @@ static int cna_setup_wafl(cfg_wafl_t *cw) /* {{{ */ na_elem_free(cw->query); cw->query = NULL; ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } na_child_add_string(e, "counter", "name_cache_hit"); na_child_add_string(e, "counter", "name_cache_miss"); @@ -987,7 +994,7 @@ static int cna_setup_wafl(cfg_wafl_t *cw) /* {{{ */ na_child_add(cw->query, e); - return (0); + return 0; } /* }}} int cna_setup_wafl */ static int cna_query_wafl(host_config_t *host) /* {{{ */ @@ -997,20 +1004,20 @@ static int cna_query_wafl(host_config_t *host) /* {{{ */ cdtime_t now; if (host == NULL) - return (EINVAL); + return EINVAL; /* If WAFL was not configured, return without doing anything. */ if (host->cfg_wafl == NULL) - return (0); + return 0; now = cdtime(); if ((host->cfg_wafl->interval.interval + host->cfg_wafl->interval.last_read) > now) - return (0); + return 0; status = cna_setup_wafl(host->cfg_wafl); if (status != 0) - return (status); + return status; assert(host->cfg_wafl->query != NULL); data = na_server_invoke_elem(host->srv, host->cfg_wafl->query); @@ -1019,7 +1026,7 @@ static int cna_query_wafl(host_config_t *host) /* {{{ */ "host %s: %s", host->name, na_results_reason(data)); na_elem_free(data); - return (-1); + return -1; } status = cna_handle_wafl_data(host->name, host->cfg_wafl, data, @@ -1029,7 +1036,7 @@ static int cna_query_wafl(host_config_t *host) /* {{{ */ host->cfg_wafl->interval.last_read = now; na_elem_free(data); - return (status); + return status; } /* }}} int cna_query_wafl */ /* Data corresponding to */ @@ -1042,7 +1049,7 @@ static int cna_handle_disk_data(const char *hostname, /* {{{ */ disk_t *worst_disk = NULL; if ((cfg_disk == NULL) || (data == NULL)) - return (EINVAL); + return EINVAL; timestamp = cna_child_get_cdtime(data); @@ -1052,7 +1059,7 @@ static int cna_handle_disk_data(const char *hostname, /* {{{ */ "na_elem_child (\"instances\") failed " "for host %s.", hostname); - return (-1); + return -1; } /* Iterate over all children */ @@ -1137,7 +1144,7 @@ static int cna_handle_disk_data(const char *hostname, /* {{{ */ submit_double(hostname, "system", "percent", "disk_busy", worst_disk->disk_busy_percent, timestamp, interval); - return (0); + return 0; } /* }}} int cna_handle_disk_data */ static int cna_setup_disk(cfg_disk_t *cd) /* {{{ */ @@ -1145,15 +1152,15 @@ static int cna_setup_disk(cfg_disk_t *cd) /* {{{ */ na_elem_t *e; if (cd == NULL) - return (EINVAL); + return EINVAL; if (cd->query != NULL) - return (0); + return 0; cd->query = na_elem_new("perf-object-get-instances"); if (cd->query == NULL) { ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } na_child_add_string(cd->query, "objectname", "disk"); @@ -1162,13 +1169,13 @@ static int cna_setup_disk(cfg_disk_t *cd) /* {{{ */ na_elem_free(cd->query); cd->query = NULL; ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } na_child_add_string(e, "counter", "disk_busy"); na_child_add_string(e, "counter", "base_for_disk_busy"); na_child_add(cd->query, e); - return (0); + return 0; } /* }}} int cna_setup_disk */ static int cna_query_disk(host_config_t *host) /* {{{ */ @@ -1178,21 +1185,21 @@ static int cna_query_disk(host_config_t *host) /* {{{ */ cdtime_t now; if (host == NULL) - return (EINVAL); + return EINVAL; /* If the user did not configure disk statistics, return without doing * anything. */ if (host->cfg_disk == NULL) - return (0); + return 0; now = cdtime(); if ((host->cfg_disk->interval.interval + host->cfg_disk->interval.last_read) > now) - return (0); + return 0; status = cna_setup_disk(host->cfg_disk); if (status != 0) - return (status); + return status; assert(host->cfg_disk->query != NULL); data = na_server_invoke_elem(host->srv, host->cfg_disk->query); @@ -1201,7 +1208,7 @@ static int cna_query_disk(host_config_t *host) /* {{{ */ "host %s: %s", host->name, na_results_reason(data)); na_elem_free(data); - return (-1); + return -1; } status = cna_handle_disk_data(host->name, host->cfg_disk, data, @@ -1211,7 +1218,7 @@ static int cna_query_disk(host_config_t *host) /* {{{ */ host->cfg_disk->interval.last_read = now; na_elem_free(data); - return (status); + return status; } /* }}} int cna_query_disk */ /* Data corresponding to */ @@ -1230,7 +1237,7 @@ static int cna_handle_volume_perf_data(const char *hostname, /* {{{ */ "na_elem_child (\"instances\") failed " "for host %s.", hostname); - return (-1); + return -1; } iter_instances = na_child_iterator(elem_instances); @@ -1299,7 +1306,7 @@ static int cna_handle_volume_perf_data(const char *hostname, /* {{{ */ submit_volume_perf_data(hostname, v, &perf_data, interval); } /* for (volume) */ - return (0); + return 0; } /* }}} int cna_handle_volume_perf_data */ static int cna_setup_volume_perf(cfg_volume_perf_t *cd) /* {{{ */ @@ -1307,15 +1314,15 @@ static int cna_setup_volume_perf(cfg_volume_perf_t *cd) /* {{{ */ na_elem_t *e; if (cd == NULL) - return (EINVAL); + return EINVAL; if (cd->query != NULL) - return (0); + return 0; cd->query = na_elem_new("perf-object-get-instances"); if (cd->query == NULL) { ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } na_child_add_string(cd->query, "objectname", "volume"); @@ -1324,7 +1331,7 @@ static int cna_setup_volume_perf(cfg_volume_perf_t *cd) /* {{{ */ na_elem_free(cd->query); cd->query = NULL; ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } na_child_add_string(e, "counter", "read_ops"); na_child_add_string(e, "counter", "write_ops"); @@ -1334,7 +1341,7 @@ static int cna_setup_volume_perf(cfg_volume_perf_t *cd) /* {{{ */ na_child_add_string(e, "counter", "write_latency"); na_child_add(cd->query, e); - return (0); + return 0; } /* }}} int cna_setup_volume_perf */ static int cna_query_volume_perf(host_config_t *host) /* {{{ */ @@ -1344,21 +1351,21 @@ static int cna_query_volume_perf(host_config_t *host) /* {{{ */ cdtime_t now; if (host == NULL) - return (EINVAL); + return EINVAL; /* If the user did not configure volume performance statistics, return * without doing anything. */ if (host->cfg_volume_perf == NULL) - return (0); + return 0; now = cdtime(); if ((host->cfg_volume_perf->interval.interval + host->cfg_volume_perf->interval.last_read) > now) - return (0); + return 0; status = cna_setup_volume_perf(host->cfg_volume_perf); if (status != 0) - return (status); + return status; assert(host->cfg_volume_perf->query != NULL); data = na_server_invoke_elem(host->srv, host->cfg_volume_perf->query); @@ -1367,7 +1374,7 @@ static int cna_query_volume_perf(host_config_t *host) /* {{{ */ "for host %s: %s", host->name, na_results_reason(data)); na_elem_free(data); - return (-1); + return -1; } status = @@ -1378,7 +1385,7 @@ static int cna_query_volume_perf(host_config_t *host) /* {{{ */ host->cfg_volume_perf->interval.last_read = now; na_elem_free(data); - return (status); + return status; } /* }}} int cna_query_volume_perf */ /* Data corresponding to */ @@ -1397,10 +1404,11 @@ static int cna_submit_volume_usage_data(const char *hostname, /* {{{ */ uint64_t snap_reserve_free = v->snap_reserved; uint64_t snap_norm_used = v->snap_used; - ssnprintf(plugin_instance, sizeof(plugin_instance), "volume-%s", v->name); + snprintf(plugin_instance, sizeof(plugin_instance), "volume-%s", v->name); - if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_USED | - HAVE_VOLUME_USAGE_SNAP_RSVD)) { + if (HAS_ALL_FLAGS(v->flags, + HAVE_VOLUME_USAGE_SNAP_USED | + HAVE_VOLUME_USAGE_SNAP_RSVD)) { if (v->snap_reserved > v->snap_used) { snap_reserve_free = v->snap_reserved - v->snap_used; snap_reserve_used = v->snap_used; @@ -1414,8 +1422,9 @@ static int cna_submit_volume_usage_data(const char *hostname, /* {{{ */ /* The space used by snapshots but not reserved for them is included in * both, norm_used and snap_norm_used. If possible, subtract this here. */ - if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_NORM_USED | - HAVE_VOLUME_USAGE_SNAP_USED)) { + if (HAS_ALL_FLAGS(v->flags, + HAVE_VOLUME_USAGE_NORM_USED | + HAVE_VOLUME_USAGE_SNAP_USED)) { if (norm_used >= snap_norm_used) norm_used -= snap_norm_used; else { @@ -1457,8 +1466,9 @@ static int cna_submit_volume_usage_data(const char *hostname, /* {{{ */ "df_complex", "snap_reserved", (double)snap_reserve_free, /* timestamp = */ 0, interval); - if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_USED | - HAVE_VOLUME_USAGE_SNAP_RSVD)) + if (HAS_ALL_FLAGS(v->flags, + HAVE_VOLUME_USAGE_SNAP_USED | + HAVE_VOLUME_USAGE_SNAP_RSVD)) submit_double(hostname, /* plugin instance = */ plugin_instance, "df_complex", "snap_reserve_used", (double)snap_reserve_used, /* timestamp = */ 0, interval); @@ -1472,7 +1482,7 @@ static int cna_submit_volume_usage_data(const char *hostname, /* {{{ */ v->flags &= ~HAVE_VOLUME_USAGE_ALL; } /* for (v = cfg_volume->volumes) */ - return (0); + return 0; } /* }}} int cna_submit_volume_usage_data */ /* Switch the state of a volume between online and offline and send out a @@ -1488,17 +1498,16 @@ static int cna_change_volume_status(const char *hostname, /* {{{ */ if ((v->flags & IS_VOLUME_USAGE_OFFLINE) != 0) { n.severity = NOTIF_OKAY; - ssnprintf(n.message, sizeof(n.message), "Volume %s is now online.", - v->name); + snprintf(n.message, sizeof(n.message), "Volume %s is now online.", v->name); v->flags &= ~IS_VOLUME_USAGE_OFFLINE; } else { n.severity = NOTIF_WARNING; - ssnprintf(n.message, sizeof(n.message), "Volume %s is now offline.", - v->name); + snprintf(n.message, sizeof(n.message), "Volume %s is now offline.", + v->name); v->flags |= IS_VOLUME_USAGE_OFFLINE; } - return (plugin_dispatch_notification(&n)); + return plugin_dispatch_notification(&n); } /* }}} int cna_change_volume_status */ static void cna_handle_volume_snap_usage(const host_config_t *host, /* {{{ */ @@ -1661,7 +1670,7 @@ static int cna_handle_volume_usage_data(const host_config_t *host, /* {{{ */ "na_elem_child (\"volumes\") failed " "for host %s.", host->name); - return (-1); + return -1; } iter_volume = na_child_iterator(elem_volumes); @@ -1721,25 +1730,25 @@ static int cna_handle_volume_usage_data(const host_config_t *host, /* {{{ */ } } /* for (elem_volume) */ - return (cna_submit_volume_usage_data( - host->name, cfg_volume, host->cfg_volume_usage->interval.interval)); + return cna_submit_volume_usage_data( + host->name, cfg_volume, host->cfg_volume_usage->interval.interval); } /* }}} int cna_handle_volume_usage_data */ static int cna_setup_volume_usage(cfg_volume_usage_t *cvu) /* {{{ */ { if (cvu == NULL) - return (EINVAL); + return EINVAL; if (cvu->query != NULL) - return (0); + return 0; cvu->query = na_elem_new("volume-list-info"); if (cvu->query == NULL) { ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } - return (0); + return 0; } /* }}} int cna_setup_volume_usage */ static int cna_query_volume_usage(host_config_t *host) /* {{{ */ @@ -1749,21 +1758,21 @@ static int cna_query_volume_usage(host_config_t *host) /* {{{ */ cdtime_t now; if (host == NULL) - return (EINVAL); + return EINVAL; /* If the user did not configure volume_usage statistics, return without * doing anything. */ if (host->cfg_volume_usage == NULL) - return (0); + return 0; now = cdtime(); if ((host->cfg_volume_usage->interval.interval + host->cfg_volume_usage->interval.last_read) > now) - return (0); + return 0; status = cna_setup_volume_usage(host->cfg_volume_usage); if (status != 0) - return (status); + return status; assert(host->cfg_volume_usage->query != NULL); data = na_server_invoke_elem(host->srv, host->cfg_volume_usage->query); @@ -1772,7 +1781,7 @@ static int cna_query_volume_usage(host_config_t *host) /* {{{ */ "for host %s: %s", host->name, na_results_reason(data)); na_elem_free(data); - return (-1); + return -1; } status = cna_handle_volume_usage_data(host, host->cfg_volume_usage, data); @@ -1781,7 +1790,7 @@ static int cna_query_volume_usage(host_config_t *host) /* {{{ */ host->cfg_volume_usage->interval.last_read = now; na_elem_free(data); - return (status); + return status; } /* }}} int cna_query_volume_usage */ /* Data corresponding to */ @@ -1796,7 +1805,7 @@ static int cna_handle_quota_data(const host_config_t *host, /* {{{ */ "na_elem_child (\"quotas\") failed " "for host %s.", host->name); - return (-1); + return -1; } iter_quota = na_child_iterator(elem_quotas); @@ -1823,8 +1832,8 @@ static int cna_handle_quota_data(const host_config_t *host, /* {{{ */ if (volume_name == NULL) continue; - ssnprintf(plugin_instance, sizeof(plugin_instance), "quota-%s-%s", - volume_name, tree_name); + snprintf(plugin_instance, sizeof(plugin_instance), "quota-%s-%s", + volume_name, tree_name); value = na_child_get_uint64(elem_quota, "disk-used", UINT64_MAX); if (value != UINT64_MAX) { @@ -1844,24 +1853,24 @@ static int cna_handle_quota_data(const host_config_t *host, /* {{{ */ } } /* for (elem_quota) */ - return (0); + return 0; } /* }}} int cna_handle_volume_usage_data */ static int cna_setup_quota(cfg_quota_t *cq) /* {{{ */ { if (cq == NULL) - return (EINVAL); + return EINVAL; if (cq->query != NULL) - return (0); + return 0; cq->query = na_elem_new("quota-report"); if (cq->query == NULL) { ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } - return (0); + return 0; } /* }}} int cna_setup_quota */ static int cna_query_quota(host_config_t *host) /* {{{ */ @@ -1871,21 +1880,21 @@ static int cna_query_quota(host_config_t *host) /* {{{ */ cdtime_t now; if (host == NULL) - return (EINVAL); + return EINVAL; /* If the user did not configure quota statistics, return without * doing anything. */ if (host->cfg_quota == NULL) - return (0); + return 0; now = cdtime(); if ((host->cfg_quota->interval.interval + host->cfg_quota->interval.last_read) > now) - return (0); + return 0; status = cna_setup_quota(host->cfg_quota); if (status != 0) - return (status); + return status; assert(host->cfg_quota->query != NULL); data = na_server_invoke_elem(host->srv, host->cfg_quota->query); @@ -1894,7 +1903,7 @@ static int cna_query_quota(host_config_t *host) /* {{{ */ "host %s: %s", host->name, na_results_reason(data)); na_elem_free(data); - return (-1); + return -1; } status = cna_handle_quota_data(host, host->cfg_quota, data); @@ -1903,7 +1912,7 @@ static int cna_query_quota(host_config_t *host) /* {{{ */ host->cfg_quota->interval.last_read = now; na_elem_free(data); - return (status); + return status; } /* }}} int cna_query_quota */ /* Data corresponding to */ @@ -1913,7 +1922,7 @@ static int cna_handle_snapvault_data(const char *hostname, /* {{{ */ na_elem_t *status_list = na_elem_child(data, "status-list"); if (status_list == NULL) { ERROR("netapp plugin: SnapVault status record missing status-list"); - return (0); + return 0; } na_elem_iter_t status_iter = na_child_iterator(status_list); @@ -1936,8 +1945,8 @@ static int cna_handle_snapvault_data(const char *hostname, /* {{{ */ continue; /* possible TODO: make plugin instance configurable */ - ssnprintf(plugin_instance, sizeof(plugin_instance), "snapvault-%s", - dest_path); + snprintf(plugin_instance, sizeof(plugin_instance), "snapvault-%s", + dest_path); submit_double(hostname, plugin_instance, /* type = */ "delay", NULL, (double)value, /* timestamp = */ 0, interval); @@ -1957,7 +1966,7 @@ static int cna_handle_snapvault_data(const char *hostname, /* {{{ */ } } /* for (status) */ - return (0); + return 0; } /* }}} int cna_handle_snapvault_data */ static int cna_handle_snapvault_iter(host_config_t *host, /* {{{ */ @@ -1989,7 +1998,7 @@ static int cna_handle_snapvault_iter(host_config_t *host, /* {{{ */ "na_server_invoke failed for host %s: %s", host->name, na_results_reason(data)); na_elem_free(elem); - return (-1); + return -1; } cna_handle_snapvault_data(host->name, host->cfg_snapvault, elem, @@ -2000,25 +2009,25 @@ static int cna_handle_snapvault_iter(host_config_t *host, /* {{{ */ na_elem_free(na_server_invoke( host->srv, "snapvault-secondary-relationship-status-list-iter-end", "tag", tag, NULL)); - return (0); + return 0; } /* }}} int cna_handle_snapvault_iter */ static int cna_setup_snapvault(cfg_snapvault_t *sv) /* {{{ */ { if (sv == NULL) - return (EINVAL); + return EINVAL; if (sv->query != NULL) - return (0); + return 0; sv->query = na_elem_new("snapvault-secondary-relationship-status-list-iter-start"); if (sv->query == NULL) { ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } - return (0); + return 0; } /* }}} int cna_setup_snapvault */ static int cna_query_snapvault(host_config_t *host) /* {{{ */ @@ -2036,11 +2045,11 @@ static int cna_query_snapvault(host_config_t *host) /* {{{ */ now = cdtime(); if ((host->cfg_snapvault->interval.interval + host->cfg_snapvault->interval.last_read) > now) - return (0); + return 0; status = cna_setup_snapvault(host->cfg_snapvault); if (status != 0) - return (status); + return status; assert(host->cfg_snapvault->query != NULL); data = na_server_invoke_elem(host->srv, host->cfg_snapvault->query); @@ -2049,7 +2058,7 @@ static int cna_query_snapvault(host_config_t *host) /* {{{ */ "for host %s: %s", host->name, na_results_reason(data)); na_elem_free(data); - return (-1); + return -1; } status = cna_handle_snapvault_iter(host, data); @@ -2058,7 +2067,7 @@ static int cna_query_snapvault(host_config_t *host) /* {{{ */ host->cfg_snapvault->interval.last_read = now; na_elem_free(data); - return (status); + return status; } /* }}} int cna_query_snapvault */ /* Data corresponding to */ @@ -2084,7 +2093,7 @@ static int cna_handle_system_data(const char *hostname, /* {{{ */ "na_elem_child (\"instances\") failed " "for host %s.", hostname); - return (-1); + return -1; } instance = na_child_get_string(instances, "name"); @@ -2093,7 +2102,7 @@ static int cna_handle_system_data(const char *hostname, /* {{{ */ "na_child_get_string (\"name\") failed " "for host %s.", hostname); - return (-1); + return -1; } counter_iter = na_child_iterator(na_elem_child(instances, "counters")); @@ -2154,25 +2163,25 @@ static int cna_handle_system_data(const char *hostname, /* {{{ */ timestamp, interval); } - return (0); + return 0; } /* }}} int cna_handle_system_data */ static int cna_setup_system(cfg_system_t *cs) /* {{{ */ { if (cs == NULL) - return (EINVAL); + return EINVAL; if (cs->query != NULL) - return (0); + return 0; cs->query = na_elem_new("perf-object-get-instances"); if (cs->query == NULL) { ERROR("netapp plugin: na_elem_new failed."); - return (-1); + return -1; } na_child_add_string(cs->query, "objectname", "system"); - return (0); + return 0; } /* }}} int cna_setup_system */ static int cna_query_system(host_config_t *host) /* {{{ */ @@ -2182,20 +2191,20 @@ static int cna_query_system(host_config_t *host) /* {{{ */ cdtime_t now; if (host == NULL) - return (EINVAL); + return EINVAL; /* If system statistics were not configured, return without doing anything. */ if (host->cfg_system == NULL) - return (0); + return 0; now = cdtime(); if ((host->cfg_system->interval.interval + host->cfg_system->interval.last_read) > now) - return (0); + return 0; status = cna_setup_system(host->cfg_system); if (status != 0) - return (status); + return status; assert(host->cfg_system->query != NULL); data = na_server_invoke_elem(host->srv, host->cfg_system->query); @@ -2204,7 +2213,7 @@ static int cna_query_system(host_config_t *host) /* {{{ */ "host %s: %s", host->name, na_results_reason(data)); na_elem_free(data); - return (-1); + return -1; } status = cna_handle_system_data(host->name, host->cfg_system, data, @@ -2214,7 +2223,7 @@ static int cna_query_system(host_config_t *host) /* {{{ */ host->cfg_system->interval.last_read = now; na_elem_free(data); - return (status); + return status; } /* }}} int cna_query_system */ /* @@ -2225,12 +2234,12 @@ static int cna_query_system(host_config_t *host) /* {{{ */ static int cna_config_bool_to_flag(const oconfig_item_t *ci, /* {{{ */ uint32_t *flags, uint32_t flag) { if ((ci == NULL) || (flags == NULL)) - return (EINVAL); + return EINVAL; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) { WARNING("netapp plugin: The %s option needs exactly one boolean argument.", ci->key); - return (-1); + return -1; } if (ci->values[0].value.boolean) @@ -2238,7 +2247,7 @@ static int cna_config_bool_to_flag(const oconfig_item_t *ci, /* {{{ */ else *flags &= ~flag; - return (0); + return 0; } /* }}} int cna_config_bool_to_flag */ /* Handling of the "Interval" option which is allowed in every block. */ @@ -2249,12 +2258,12 @@ static int cna_config_get_interval(const oconfig_item_t *ci, /* {{{ */ status = cf_util_get_cdtime(ci, &tmp); if (status != 0) - return (status); + return status; out_interval->interval = tmp; out_interval->last_read = 0; - return (0); + return 0; } /* }}} int cna_config_get_interval */ /* Handling of the "GetIO", "GetOps" and "GetLatency" options within a @@ -2335,12 +2344,12 @@ static int cna_config_volume_performance(host_config_t *host, /* {{{ */ cfg_volume_perf_t *cfg_volume_perf; if ((host == NULL) || (ci == NULL)) - return (EINVAL); + return EINVAL; if (host->cfg_volume_perf == NULL) { cfg_volume_perf = calloc(1, sizeof(*cfg_volume_perf)); if (cfg_volume_perf == NULL) - return (ENOMEM); + return ENOMEM; /* Set default flags */ cfg_volume_perf->query = NULL; @@ -2349,14 +2358,14 @@ static int cna_config_volume_performance(host_config_t *host, /* {{{ */ cfg_volume_perf->il_octets = ignorelist_create(/* invert = */ 1); if (cfg_volume_perf->il_octets == NULL) { sfree(cfg_volume_perf); - return (ENOMEM); + return ENOMEM; } cfg_volume_perf->il_operations = ignorelist_create(/* invert = */ 1); if (cfg_volume_perf->il_operations == NULL) { ignorelist_free(cfg_volume_perf->il_octets); sfree(cfg_volume_perf); - return (ENOMEM); + return ENOMEM; } cfg_volume_perf->il_latency = ignorelist_create(/* invert = */ 1); @@ -2364,7 +2373,7 @@ static int cna_config_volume_performance(host_config_t *host, /* {{{ */ ignorelist_free(cfg_volume_perf->il_octets); ignorelist_free(cfg_volume_perf->il_operations); sfree(cfg_volume_perf); - return (ENOMEM); + return ENOMEM; } host->cfg_volume_perf = cfg_volume_perf; @@ -2395,7 +2404,7 @@ static int cna_config_volume_performance(host_config_t *host, /* {{{ */ item->key); } - return (0); + return 0; } /* }}} int cna_config_volume_performance */ /* Handling of the "GetCapacity" and "GetSnapshot" options within a @@ -2456,12 +2465,12 @@ static int cna_config_quota(host_config_t *host, oconfig_item_t *ci) /* {{{ */ cfg_quota_t *cfg_quota; if ((host == NULL) || (ci == NULL)) - return (EINVAL); + return EINVAL; if (host->cfg_quota == NULL) { cfg_quota = calloc(1, sizeof(*cfg_quota)); if (cfg_quota == NULL) - return (ENOMEM); + return ENOMEM; cfg_quota->query = NULL; host->cfg_quota = cfg_quota; @@ -2479,7 +2488,7 @@ static int cna_config_quota(host_config_t *host, oconfig_item_t *ci) /* {{{ */ item->key); } - return (0); + return 0; } /* }}} int cna_config_quota */ /* Corresponds to a block */ @@ -2487,12 +2496,12 @@ static int cna_config_disk(host_config_t *host, oconfig_item_t *ci) { /* {{{ */ cfg_disk_t *cfg_disk; if ((host == NULL) || (ci == NULL)) - return (EINVAL); + return EINVAL; if (host->cfg_disk == NULL) { cfg_disk = calloc(1, sizeof(*cfg_disk)); if (cfg_disk == NULL) - return (ENOMEM); + return ENOMEM; /* Set default flags */ cfg_disk->flags = CFG_DISK_ALL; @@ -2520,7 +2529,7 @@ static int cna_config_disk(host_config_t *host, oconfig_item_t *ci) { /* {{{ */ host->cfg_disk = NULL; } - return (0); + return 0; } /* }}} int cna_config_disk */ /* Corresponds to a block */ @@ -2529,12 +2538,12 @@ static int cna_config_wafl(host_config_t *host, oconfig_item_t *ci) /* {{{ */ cfg_wafl_t *cfg_wafl; if ((host == NULL) || (ci == NULL)) - return (EINVAL); + return EINVAL; if (host->cfg_wafl == NULL) { cfg_wafl = calloc(1, sizeof(*cfg_wafl)); if (cfg_wafl == NULL) - return (ENOMEM); + return ENOMEM; /* Set default flags */ cfg_wafl->flags = CFG_WAFL_ALL; @@ -2569,7 +2578,7 @@ static int cna_config_wafl(host_config_t *host, oconfig_item_t *ci) /* {{{ */ host->cfg_wafl = NULL; } - return (0); + return 0; } /* }}} int cna_config_wafl */ /* @@ -2594,12 +2603,12 @@ static int cna_config_volume_usage(host_config_t *host, /* {{{ */ cfg_volume_usage_t *cfg_volume_usage; if ((host == NULL) || (ci == NULL)) - return (EINVAL); + return EINVAL; if (host->cfg_volume_usage == NULL) { cfg_volume_usage = calloc(1, sizeof(*cfg_volume_usage)); if (cfg_volume_usage == NULL) - return (ENOMEM); + return ENOMEM; /* Set default flags */ cfg_volume_usage->query = NULL; @@ -2608,14 +2617,14 @@ static int cna_config_volume_usage(host_config_t *host, /* {{{ */ cfg_volume_usage->il_capacity = ignorelist_create(/* invert = */ 1); if (cfg_volume_usage->il_capacity == NULL) { sfree(cfg_volume_usage); - return (ENOMEM); + return ENOMEM; } cfg_volume_usage->il_snapshot = ignorelist_create(/* invert = */ 1); if (cfg_volume_usage->il_snapshot == NULL) { ignorelist_free(cfg_volume_usage->il_capacity); sfree(cfg_volume_usage); - return (ENOMEM); + return ENOMEM; } host->cfg_volume_usage = cfg_volume_usage; @@ -2642,7 +2651,7 @@ static int cna_config_volume_usage(host_config_t *host, /* {{{ */ item->key); } - return (0); + return 0; } /* }}} int cna_config_volume_usage */ /* Corresponds to a block */ @@ -2684,12 +2693,12 @@ static int cna_config_system(host_config_t *host, /* {{{ */ cfg_system_t *cfg_system; if ((host == NULL) || (ci == NULL)) - return (EINVAL); + return EINVAL; if (host->cfg_system == NULL) { cfg_system = calloc(1, sizeof(*cfg_system)); if (cfg_system == NULL) - return (ENOMEM); + return ENOMEM; /* Set default flags */ cfg_system->flags = CFG_SYSTEM_ALL; @@ -2726,7 +2735,7 @@ static int cna_config_system(host_config_t *host, /* {{{ */ host->cfg_system = NULL; } - return (0); + return 0; } /* }}} int cna_config_system */ /* Corresponds to a block. */ @@ -2736,7 +2745,7 @@ static host_config_t *cna_alloc_host(void) /* {{{ */ host = calloc(1, sizeof(*host)); if (host == NULL) - return (NULL); + return NULL; host->name = NULL; host->protocol = NA_SERVER_TRANSPORT_HTTPS; @@ -2753,7 +2762,7 @@ static host_config_t *cna_alloc_host(void) /* {{{ */ host->cfg_snapvault = NULL; host->cfg_system = NULL; - return (host); + return host; } /* }}} host_config_t *cna_alloc_host */ static host_config_t *cna_shallow_clone_host(host_config_t *host) /* {{{ */ @@ -2761,11 +2770,11 @@ static host_config_t *cna_shallow_clone_host(host_config_t *host) /* {{{ */ host_config_t *clone; if (host == NULL) - return (NULL); + return NULL; clone = cna_alloc_host(); if (clone == NULL) - return (NULL); + return NULL; if (host->name != NULL) { clone->name = strdup(host->name); @@ -2804,7 +2813,7 @@ static host_config_t *cna_shallow_clone_host(host_config_t *host) /* {{{ */ clone->interval = host->interval; - return (clone); + return clone; } /* }}} host_config_t *cna_shallow_clone_host */ static int cna_read(user_data_t *ud); @@ -2814,10 +2823,10 @@ static int cna_register_host(host_config_t *host) /* {{{ */ char cb_name[256]; if (host->vfiler) - ssnprintf(cb_name, sizeof(cb_name), "netapp-%s-%s", host->name, - host->vfiler); + snprintf(cb_name, sizeof(cb_name), "netapp-%s-%s", host->name, + host->vfiler); else - ssnprintf(cb_name, sizeof(cb_name), "netapp-%s", host->name); + snprintf(cb_name, sizeof(cb_name), "netapp-%s", host->name); plugin_register_complex_read( /* group = */ NULL, cb_name, @@ -2827,28 +2836,28 @@ static int cna_register_host(host_config_t *host) /* {{{ */ .data = host, .free_func = (void *)free_host_config, }); - return (0); + return 0; } /* }}} int cna_register_host */ static int cna_config_host(host_config_t *host, /* {{{ */ const oconfig_item_t *ci) { oconfig_item_t *item; - _Bool is_vfiler = 0; + bool is_vfiler = false; int status; if (!strcasecmp(ci->key, "VFiler")) - is_vfiler = 1; + is_vfiler = true; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING("netapp plugin: \"%s\" needs exactly one string argument. Ignoring " "host block.", ci->key); - return (1); + return 1; } status = cf_util_get_string(ci, &host->name); if (status != 0) - return (1); + return 1; for (int i = 0; i < ci->children_num; ++i) { item = ci->children + i; @@ -2871,7 +2880,7 @@ static int cna_config_host(host_config_t *host, /* {{{ */ WARNING("netapp plugin: \"Protocol\" needs to be either \"http\" or " "\"https\". Ignoring host block \"%s\".", ci->values[0].value.string); - return (1); + return 1; } if (!strcasecmp(item->values[0].value.string, "http")) host->protocol = NA_SERVER_TRANSPORT_HTTP; @@ -2947,7 +2956,7 @@ static int cna_config_host(host_config_t *host, /* {{{ */ if (status != 0) return status; - return (0); + return 0; } /* }}} host_config_t *cna_config_host */ /* @@ -2961,10 +2970,10 @@ static int cna_init_host(host_config_t *host) /* {{{ */ int major_version = 1, minor_version = 1; if (host == NULL) - return (EINVAL); + return EINVAL; if (host->srv != NULL) - return (0); + return 0; if (host->vfiler != NULL) /* Request version 1.7 of the ONTAP API */ minor_version = 7; @@ -2972,7 +2981,7 @@ static int cna_init_host(host_config_t *host) /* {{{ */ host->srv = na_server_open(host->host, major_version, minor_version); if (host->srv == NULL) { ERROR("netapp plugin: na_server_open (%s) failed.", host->host); - return (-1); + return -1; } na_server_set_transport_type(host->srv, host->protocol, @@ -2986,14 +2995,14 @@ static int cna_init_host(host_config_t *host) /* {{{ */ if (!na_server_set_vfiler(host->srv, host->vfiler)) { ERROR("netapp plugin: Failed to connect to VFiler '%s' on host '%s'.", host->vfiler, host->host); - return (-1); + return -1; } else { INFO("netapp plugin: Connected to VFiler '%s' on host '%s'.", host->vfiler, host->host); } } - return (0); + return 0; } /* }}} int cna_init_host */ static int cna_init(void) /* {{{ */ @@ -3006,7 +3015,7 @@ static int cna_init(void) /* {{{ */ return 1; } - return (0); + return 0; } /* }}} cna_init */ static int cna_read_internal(host_config_t *host) { /* {{{ */ @@ -3014,31 +3023,31 @@ static int cna_read_internal(host_config_t *host) { /* {{{ */ status = cna_query_wafl(host); if (status != 0) - return (status); + return status; status = cna_query_disk(host); if (status != 0) - return (status); + return status; status = cna_query_volume_perf(host); if (status != 0) - return (status); + return status; status = cna_query_volume_usage(host); if (status != 0) - return (status); + return status; status = cna_query_quota(host); if (status != 0) - return (status); + return status; status = cna_query_snapvault(host); if (status != 0) - return (status); + return status; status = cna_query_system(host); if (status != 0) - return (status); + return status; return 0; } /* }}} int cna_read_internal */ @@ -3048,13 +3057,13 @@ static int cna_read(user_data_t *ud) { /* {{{ */ int status; if ((ud == NULL) || (ud->data == NULL)) - return (-1); + return -1; host = ud->data; status = cna_init_host(host); if (status != 0) - return (status); + return status; status = cna_read_internal(host); if (status != 0) { @@ -3101,7 +3110,7 @@ static int cna_shutdown(void) /* {{{ */ /* Clean up system resources and stuff. */ na_shutdown(); - return (0); + return 0; } /* }}} int cna_shutdown */ void module_register(void) { @@ -3109,5 +3118,3 @@ void module_register(void) { plugin_register_init("netapp", cna_init); plugin_register_shutdown("netapp", cna_shutdown); } - -/* vim: set sw=2 ts=2 noet fdm=marker : */