+static void cna_handle_volume_snap_usage(const host_config_t *host, data_volume_usage_t *v)
+{
+ uint64_t snap_used = 0, value;
+ na_elem_t *data, *elem_snap, *elem_snapshots;
+ na_elem_iter_t iter_snap;
+
+ data = na_server_invoke_elem(host->srv, v->snap_query);
+ if (na_results_status(data) != NA_OK)
+ {
+ if (na_results_errno(data) != EVOLUMEOFFLINE)
+ ERROR ("netapp plugin: cna_handle_volume_snap_usage: na_server_invoke_elem for "
+ "volume \"%s\" failed with error %d: %s", v->name,
+ na_results_errno(data), na_results_reason(data));
+ na_elem_free(data);
+ return;
+ }
+
+ elem_snapshots = na_elem_child (data, "snapshots");
+ if (elem_snapshots == NULL)
+ {
+ ERROR ("netapp plugin: cna_handle_volume_snap_usage: "
+ "na_elem_child (\"snapshots\") failed.");
+ na_elem_free(data);
+ return;
+ }
+
+ iter_snap = na_child_iterator (elem_snapshots);
+ for (elem_snap = na_iterator_next (&iter_snap);
+ elem_snap != NULL;
+ elem_snap = na_iterator_next (&iter_snap))
+ {
+ value = na_child_get_uint64(elem_snap, "cumulative-total", 0);
+ if (value > snap_used)
+ snap_used = value;
+ }
+ na_elem_free (data);
+ /* snap_used is the total size of the oldest snapshot plus all
+ * newer ones in blocks (1KB). */
+ v->snap_used = snap_used * 1024;
+ v->flags |= HAVE_VOLUME_USAGE_SNAP_USED;
+}
+
+static int cna_handle_volume_usage_data (const host_config_t *host, /* {{{ */