+ e = na_elem_new("counters");
+ if (e == NULL)
+ {
+ na_elem_free (cd->query);
+ cd->query = NULL;
+ ERROR ("netapp plugin: na_elem_new failed.");
+ return (-1);
+ }
+ na_child_add_string(e, "foo", "disk_busy");
+ na_child_add_string(e, "foo", "base_for_disk_busy");
+ na_child_add(cd->query, e);
+
+ return (0);
+} /* }}} int cna_setup_disk */
+
+static int cna_query_disk (host_config_t *host) /* {{{ */
+{
+ na_elem_t *data;
+ int status;
+ time_t now;
+
+ if (host == NULL)
+ return (EINVAL);
+
+ /* If the user did not configure disk statistics, return without doing
+ * anything. */
+ if (host->cfg_disk == NULL)
+ return (0);
+
+ now = time (NULL);
+ if ((host->cfg_disk->interval.interval + host->cfg_disk->interval.last_read) > now)
+ return (0);
+
+ status = cna_setup_disk (host->cfg_disk);
+ if (status != 0)
+ return (status);
+ assert (host->cfg_disk->query != NULL);
+
+ data = na_server_invoke_elem(host->srv, host->cfg_disk->query);
+ if (na_results_status (data) != NA_OK)
+ {
+ ERROR ("netapp plugin: cna_query_disk: na_server_invoke_elem failed: %s",
+ na_results_reason (data));
+ na_elem_free (data);
+ return (-1);
+ }
+
+ status = cna_handle_disk_data (host->name, host->cfg_disk, data);
+
+ if (status == 0)
+ host->cfg_disk->interval.last_read = now;
+
+ na_elem_free (data);
+ return (status);
+} /* }}} int cna_query_disk */
+
+/* Data corresponding to <VolumeUsage /> */
+static int cna_submit_volume_usage_data (const char *hostname, /* {{{ */
+ cfg_volume_usage_t *cfg_volume)
+{
+ data_volume_usage_t *v;
+
+ for (v = cfg_volume->volumes; v != NULL; v = v->next)
+ {
+ if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_NORM_FREE))
+ submit_double (hostname, /* plugin instance = */ v->name,
+ "df_complex", "free",
+ (double) v->norm_free, /* timestamp = */ 0);
+
+ if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_NORM_USED))
+ submit_double (hostname, /* plugin instance = */ v->name,
+ "df_complex", "used",
+ (double) v->norm_used, /* timestamp = */ 0);
+
+ if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_SNAP_RSVD))
+ submit_double (hostname, /* plugin instance = */ v->name,
+ "df_complex", "snap_reserved",
+ (double) v->snap_reserved, /* timestamp = */ 0);
+
+ if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_SNAP_USED))
+ submit_double (hostname, /* plugin instance = */ v->name,
+ "df_complex", "snap_used",
+ (double) v->snap_used, /* timestamp = */ 0);
+
+ if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_SIS_SAVED))
+ submit_double (hostname, /* plugin instance = */ v->name,
+ "df_complex", "sis_saved",
+ (double) v->sis_saved, /* timestamp = */ 0);
+
+ /* Clear all the HAVE_* flags */
+ v->flags &= ~HAVE_VOLUME_USAGE_ALL;
+ } /* for (v = cfg_volume->volumes) */
+
+ return (0);
+} /* }}} int cna_submit_volume_usage_data */
+
+static int cna_handle_volume_usage_data (const char *hostname, /* {{{ */
+ cfg_volume_usage_t *cfg_volume, na_elem_t *data)
+{
+ na_elem_t *elem_volume;
+ na_elem_t *elem_volumes;
+ na_elem_iter_t iter_volume;
+
+ elem_volumes = na_elem_child (data, "volumes");
+ if (elem_volumes == NULL)
+ {
+ ERROR ("netapp plugin: cna_handle_volume_usage_data: "
+ "na_elem_child (\"volumes\") failed.");
+ return (-1);
+ }
+
+ iter_volume = na_child_iterator (elem_volumes);
+ for (elem_volume = na_iterator_next (&iter_volume);
+ elem_volume != NULL;
+ elem_volume = na_iterator_next (&iter_volume))
+ {
+ const char *volume_name;
+
+ data_volume_usage_t *v;
+ uint64_t value;
+
+ na_elem_t *sis;
+ const char *sis_state;
+ uint64_t sis_saved_reported;
+
+ volume_name = na_child_get_string (elem_volume, "name");
+ if (volume_name == NULL)
+ continue;
+
+ /* get_volume_usage may return NULL if the volume is to be ignored. */
+ v = get_volume_usage (cfg_volume, volume_name);
+ if (v == NULL)
+ continue;
+
+ if ((v->flags & CFG_VOLUME_USAGE_DF) == 0)
+ continue;
+
+ /* 2^4 exa-bytes? This will take a while ;) */
+ value = na_child_get_uint64(elem_volume, "size-available", UINT64_MAX);
+ if (value != UINT64_MAX) {
+ v->norm_free = value;
+ v->flags |= HAVE_VOLUME_USAGE_NORM_FREE;
+ }
+
+ value = na_child_get_uint64(elem_volume, "size-used", UINT64_MAX);
+ if (value != UINT64_MAX) {
+ v->norm_used = value;
+ v->flags |= HAVE_VOLUME_USAGE_NORM_USED;
+ }
+
+ value = na_child_get_uint64(elem_volume, "snapshot-blocks-reserved", UINT64_MAX);
+ if (value != UINT64_MAX) {