2 * collectd - src/netapp.c
3 * Copyright (C) 2009,2010 Sven Trenkel
4 * Copyright (C) 2012-2013 teamix GmbH
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Sven Trenkel <collectd at semidefinite.de>
26 * Sebastian 'tokkee' Harl <sh@teamix.net>
31 #include "utils/common/common.h"
32 #include "utils/ignorelist/ignorelist.h"
34 #include <netapp_api.h>
35 #include <netapp_errno.h>
37 #define HAS_ALL_FLAGS(has, needs) (((has) & (needs)) == (needs))
39 typedef struct host_config_s host_config_t;
40 typedef void service_handler_t(host_config_t *host, na_elem_t *result,
43 struct cna_interval_s {
47 typedef struct cna_interval_s cna_interval_t;
49 /*! Data types for WAFL statistics {{{
51 * \brief Persistent data for WAFL performance counters. (a.k.a. cache
54 * The cache counters use old counter values to calculate a hit ratio for each
55 * counter. The "cfg_wafl_t" struct therefore contains old counter values along
56 * with flags, which are set if the counter is valid.
58 * The function "cna_handle_wafl_data" will fill a new structure of this kind
59 * with new values, then pass both, new and old data, to "submit_wafl_data".
60 * That function calculates the hit ratios, submits the calculated values and
61 * updates the old counter values for the next iteration.
63 #define CFG_WAFL_NAME_CACHE 0x0001
64 #define CFG_WAFL_DIR_CACHE 0x0002
65 #define CFG_WAFL_BUF_CACHE 0x0004
66 #define CFG_WAFL_INODE_CACHE 0x0008
67 #define CFG_WAFL_ALL 0x000F
68 #define HAVE_WAFL_NAME_CACHE_HIT 0x0100
69 #define HAVE_WAFL_NAME_CACHE_MISS 0x0200
70 #define HAVE_WAFL_NAME_CACHE \
71 (HAVE_WAFL_NAME_CACHE_HIT | HAVE_WAFL_NAME_CACHE_MISS)
72 #define HAVE_WAFL_FIND_DIR_HIT 0x0400
73 #define HAVE_WAFL_FIND_DIR_MISS 0x0800
74 #define HAVE_WAFL_FIND_DIR (HAVE_WAFL_FIND_DIR_HIT | HAVE_WAFL_FIND_DIR_MISS)
75 #define HAVE_WAFL_BUF_HASH_HIT 0x1000
76 #define HAVE_WAFL_BUF_HASH_MISS 0x2000
77 #define HAVE_WAFL_BUF_HASH (HAVE_WAFL_BUF_HASH_HIT | HAVE_WAFL_BUF_HASH_MISS)
78 #define HAVE_WAFL_INODE_CACHE_HIT 0x4000
79 #define HAVE_WAFL_INODE_CACHE_MISS 0x8000
80 #define HAVE_WAFL_INODE_CACHE \
81 (HAVE_WAFL_INODE_CACHE_HIT | HAVE_WAFL_INODE_CACHE_MISS)
82 #define HAVE_WAFL_ALL 0xff00
85 cna_interval_t interval;
89 uint64_t name_cache_hit;
90 uint64_t name_cache_miss;
91 uint64_t find_dir_hit;
92 uint64_t find_dir_miss;
93 uint64_t buf_hash_hit;
94 uint64_t buf_hash_miss;
95 uint64_t inode_cache_hit;
96 uint64_t inode_cache_miss;
100 /*! Data types for disk statistics {{{
102 * \brief A disk in the NetApp.
104 * A disk doesn't have any more information than its name at the moment.
105 * The name includes the "disk_" prefix.
107 #define HAVE_DISK_BUSY 0x10
108 #define HAVE_DISK_BASE 0x20
109 #define HAVE_DISK_ALL 0x30
110 typedef struct disk_s {
115 uint64_t base_for_disk_busy;
116 double disk_busy_percent;
120 #define CFG_DISK_BUSIEST 0x01
121 #define CFG_DISK_ALL 0x01
124 cna_interval_t interval;
130 /*! Data types for volume performance statistics {{{
132 * \brief Persistent data for volume performance data.
134 * The code below uses the difference of the operations and latency counters to
135 * calculate an average per-operation latency. For this, old counters need to
136 * be stored in the "data_volume_perf_t" structure. The byte-counters are just
137 * kept for completeness sake. The "flags" member indicates if each counter is
140 * The "cna_handle_volume_perf_data" function will fill a new struct of this
141 * type and pass both, old and new data, to "submit_volume_perf_data". In that
142 * function, the per-operation latency is calculated and dispatched, then the
143 * old counters are updated.
145 #define CFG_VOLUME_PERF_INIT 0x0001
146 #define CFG_VOLUME_PERF_IO 0x0002
147 #define CFG_VOLUME_PERF_OPS 0x0003
148 #define CFG_VOLUME_PERF_LATENCY 0x0008
149 #define CFG_VOLUME_PERF_ALL 0x000F
150 #define HAVE_VOLUME_PERF_BYTES_READ 0x0010
151 #define HAVE_VOLUME_PERF_BYTES_WRITE 0x0020
152 #define HAVE_VOLUME_PERF_OPS_READ 0x0040
153 #define HAVE_VOLUME_PERF_OPS_WRITE 0x0080
154 #define HAVE_VOLUME_PERF_LATENCY_READ 0x0100
155 #define HAVE_VOLUME_PERF_LATENCY_WRITE 0x0200
156 #define HAVE_VOLUME_PERF_ALL 0x03F0
157 struct data_volume_perf_s;
158 typedef struct data_volume_perf_s data_volume_perf_t;
159 struct data_volume_perf_s {
165 uint64_t write_bytes;
168 uint64_t read_latency;
169 uint64_t write_latency;
171 data_volume_perf_t *next;
175 cna_interval_t interval;
178 ignorelist_t *il_octets;
179 ignorelist_t *il_operations;
180 ignorelist_t *il_latency;
182 data_volume_perf_t *volumes;
184 /* }}} data_volume_perf_t */
186 /*! Data types for volume usage statistics {{{
188 * \brief Configuration struct for volume usage data (free / used).
190 #define CFG_VOLUME_USAGE_DF 0x0002
191 #define CFG_VOLUME_USAGE_SNAP 0x0004
192 #define CFG_VOLUME_USAGE_ALL 0x0006
193 #define HAVE_VOLUME_USAGE_NORM_FREE 0x0010
194 #define HAVE_VOLUME_USAGE_NORM_USED 0x0020
195 #define HAVE_VOLUME_USAGE_SNAP_RSVD 0x0040
196 #define HAVE_VOLUME_USAGE_SNAP_USED 0x0080
197 #define HAVE_VOLUME_USAGE_SIS_SAVED 0x0100
198 #define HAVE_VOLUME_USAGE_COMPRESS_SAVED 0x0200
199 #define HAVE_VOLUME_USAGE_DEDUP_SAVED 0x0400
200 #define HAVE_VOLUME_USAGE_ALL 0x07f0
201 #define IS_VOLUME_USAGE_OFFLINE 0x0800
202 struct data_volume_usage_s;
203 typedef struct data_volume_usage_s data_volume_usage_t;
204 struct data_volume_usage_s {
208 na_elem_t *snap_query;
212 uint64_t snap_reserved;
215 uint64_t compress_saved;
216 uint64_t dedup_saved;
218 data_volume_usage_t *next;
222 cna_interval_t interval;
225 ignorelist_t *il_capacity;
226 ignorelist_t *il_snapshot;
228 data_volume_usage_t *volumes;
229 } cfg_volume_usage_t;
230 /* }}} cfg_volume_usage_t */
232 /*! Data types for quota statistics {{{
234 * \brief Persistent data for quota statistics
237 cna_interval_t interval;
240 /* }}} cfg_quota_t */
242 /*! Data types for SnapVault statistics {{{
244 * \brief Persistent data for SnapVault(R) statistics
247 cna_interval_t interval;
250 /* }}} cfg_snapvault_t */
252 /*! Data types for system statistics {{{
254 * \brief Persistent data for system performance counters
256 #define CFG_SYSTEM_CPU 0x01
257 #define CFG_SYSTEM_NET 0x02
258 #define CFG_SYSTEM_OPS 0x04
259 #define CFG_SYSTEM_DISK 0x08
260 #define CFG_SYSTEM_ALL 0x0F
263 cna_interval_t interval;
266 /* }}} cfg_system_t */
268 struct host_config_s {
270 na_server_transport_t protocol;
279 cfg_wafl_t *cfg_wafl;
280 cfg_disk_t *cfg_disk;
281 cfg_volume_perf_t *cfg_volume_perf;
282 cfg_volume_usage_t *cfg_volume_usage;
283 cfg_quota_t *cfg_quota;
284 cfg_snapvault_t *cfg_snapvault;
285 cfg_system_t *cfg_system;
287 struct host_config_s *next;
293 * Used to free the various structures above.
295 static void free_disk(disk_t *disk) /* {{{ */
308 } /* }}} void free_disk */
310 static void free_cfg_wafl(cfg_wafl_t *cw) /* {{{ */
315 if (cw->query != NULL)
316 na_elem_free(cw->query);
319 } /* }}} void free_cfg_wafl */
321 static void free_cfg_disk(cfg_disk_t *cfg_disk) /* {{{ */
323 if (cfg_disk == NULL)
326 if (cfg_disk->query != NULL)
327 na_elem_free(cfg_disk->query);
329 free_disk(cfg_disk->disks);
331 } /* }}} void free_cfg_disk */
333 static void free_cfg_volume_perf(cfg_volume_perf_t *cvp) /* {{{ */
335 data_volume_perf_t *data;
340 /* Free the ignorelists */
341 ignorelist_free(cvp->il_octets);
342 ignorelist_free(cvp->il_operations);
343 ignorelist_free(cvp->il_latency);
345 /* Free the linked list of volumes */
347 while (data != NULL) {
348 data_volume_perf_t *next = data->next;
354 if (cvp->query != NULL)
355 na_elem_free(cvp->query);
358 } /* }}} void free_cfg_volume_perf */
360 static void free_cfg_volume_usage(cfg_volume_usage_t *cvu) /* {{{ */
362 data_volume_usage_t *data;
367 /* Free the ignorelists */
368 ignorelist_free(cvu->il_capacity);
369 ignorelist_free(cvu->il_snapshot);
371 /* Free the linked list of volumes */
373 while (data != NULL) {
374 data_volume_usage_t *next = data->next;
376 if (data->snap_query != NULL)
377 na_elem_free(data->snap_query);
382 if (cvu->query != NULL)
383 na_elem_free(cvu->query);
386 } /* }}} void free_cfg_volume_usage */
388 static void free_cfg_quota(cfg_quota_t *q) /* {{{ */
393 if (q->query != NULL)
394 na_elem_free(q->query);
397 } /* }}} void free_cfg_quota */
399 static void free_cfg_snapvault(cfg_snapvault_t *sv) /* {{{ */
404 if (sv->query != NULL)
405 na_elem_free(sv->query);
408 } /* }}} void free_cfg_snapvault */
410 static void free_cfg_system(cfg_system_t *cs) /* {{{ */
415 if (cs->query != NULL)
416 na_elem_free(cs->query);
419 } /* }}} void free_cfg_system */
421 static void free_host_config(host_config_t *hc) /* {{{ */
436 free_cfg_disk(hc->cfg_disk);
437 free_cfg_wafl(hc->cfg_wafl);
438 free_cfg_volume_perf(hc->cfg_volume_perf);
439 free_cfg_volume_usage(hc->cfg_volume_usage);
440 free_cfg_quota(hc->cfg_quota);
441 free_cfg_snapvault(hc->cfg_snapvault);
442 free_cfg_system(hc->cfg_system);
445 na_server_close(hc->srv);
449 free_host_config(next);
450 } /* }}} void free_host_config */
453 * Auxiliary functions
455 * Used to look up volumes and disks or to handle flags.
457 static disk_t *get_disk(cfg_disk_t *cd, const char *name) /* {{{ */
461 if ((cd == NULL) || (name == NULL))
464 for (d = cd->disks; d != NULL; d = d->next) {
465 if (strcmp(d->name, name) == 0)
469 d = calloc(1, sizeof(*d));
474 d->name = strdup(name);
475 if (d->name == NULL) {
484 } /* }}} disk_t *get_disk */
486 static data_volume_usage_t *get_volume_usage(cfg_volume_usage_t *cvu, /* {{{ */
488 data_volume_usage_t *last;
489 data_volume_usage_t *new;
491 int ignore_capacity = 0;
492 int ignore_snapshot = 0;
494 if ((cvu == NULL) || (name == NULL))
498 while (last != NULL) {
499 if (strcmp(last->name, name) == 0)
502 if (last->next == NULL)
508 /* Check the ignorelists. If *both* tell us to ignore a volume, return NULL.
510 ignore_capacity = ignorelist_match(cvu->il_capacity, name);
511 ignore_snapshot = ignorelist_match(cvu->il_snapshot, name);
512 if ((ignore_capacity != 0) && (ignore_snapshot != 0))
515 /* Not found: allocate. */
516 new = calloc(1, sizeof(*new));
521 new->name = strdup(name);
522 if (new->name == NULL) {
527 if (ignore_capacity == 0)
528 new->flags |= CFG_VOLUME_USAGE_DF;
529 if (ignore_snapshot == 0) {
530 new->flags |= CFG_VOLUME_USAGE_SNAP;
531 new->snap_query = na_elem_new("snapshot-list-info");
532 na_child_add_string(new->snap_query, "target-type", "volume");
533 na_child_add_string(new->snap_query, "target-name", name);
535 new->snap_query = NULL;
538 /* Add to end of list. */
545 } /* }}} data_volume_usage_t *get_volume_usage */
547 static data_volume_perf_t *get_volume_perf(cfg_volume_perf_t *cvp, /* {{{ */
549 data_volume_perf_t *last;
550 data_volume_perf_t *new;
552 int ignore_octets = 0;
553 int ignore_operations = 0;
554 int ignore_latency = 0;
556 if ((cvp == NULL) || (name == NULL))
560 while (last != NULL) {
561 if (strcmp(last->name, name) == 0)
564 if (last->next == NULL)
570 /* Check the ignorelists. If *all three* tell us to ignore a volume, return
572 ignore_octets = ignorelist_match(cvp->il_octets, name);
573 ignore_operations = ignorelist_match(cvp->il_operations, name);
574 ignore_latency = ignorelist_match(cvp->il_latency, name);
575 if ((ignore_octets != 0) || (ignore_operations != 0) || (ignore_latency != 0))
578 /* Not found: allocate. */
579 new = calloc(1, sizeof(*new));
584 new->name = strdup(name);
585 if (new->name == NULL) {
590 if (ignore_octets == 0)
591 new->flags |= CFG_VOLUME_PERF_IO;
592 if (ignore_operations == 0)
593 new->flags |= CFG_VOLUME_PERF_OPS;
594 if (ignore_latency == 0)
595 new->flags |= CFG_VOLUME_PERF_LATENCY;
597 /* Add to end of list. */
604 } /* }}} data_volume_perf_t *get_volume_perf */
607 * Various submit functions.
609 * They all eventually call "submit_values" which creates a value_list_t and
610 * dispatches it to the daemon.
612 static int submit_values(const char *host, /* {{{ */
613 const char *plugin_inst, const char *type,
614 const char *type_inst, value_t *values,
615 size_t values_len, cdtime_t timestamp,
617 value_list_t vl = VALUE_LIST_INIT;
620 vl.values_len = values_len;
626 vl.interval = interval;
629 sstrncpy(vl.host, host, sizeof(vl.host));
630 sstrncpy(vl.plugin, "netapp", sizeof(vl.plugin));
631 if (plugin_inst != NULL)
632 sstrncpy(vl.plugin_instance, plugin_inst, sizeof(vl.plugin_instance));
633 sstrncpy(vl.type, type, sizeof(vl.type));
634 if (type_inst != NULL)
635 sstrncpy(vl.type_instance, type_inst, sizeof(vl.type_instance));
637 return plugin_dispatch_values(&vl);
638 } /* }}} int submit_uint64 */
640 static int submit_two_derive(const char *host,
641 const char *plugin_inst, /* {{{ */
642 const char *type, const char *type_inst,
643 derive_t val0, derive_t val1, cdtime_t timestamp,
646 {.derive = val0}, {.derive = val1},
649 return submit_values(host, plugin_inst, type, type_inst, values,
650 STATIC_ARRAY_SIZE(values), timestamp, interval);
651 } /* }}} int submit_two_derive */
653 static int submit_derive(const char *host, const char *plugin_inst, /* {{{ */
654 const char *type, const char *type_inst,
655 derive_t counter, cdtime_t timestamp,
657 return submit_values(host, plugin_inst, type, type_inst,
661 1, timestamp, interval);
662 } /* }}} int submit_derive */
664 static int submit_two_gauge(const char *host, const char *plugin_inst, /* {{{ */
665 const char *type, const char *type_inst,
666 gauge_t val0, gauge_t val1, cdtime_t timestamp,
669 {.gauge = val0}, {.gauge = val1},
672 return submit_values(host, plugin_inst, type, type_inst, values,
673 STATIC_ARRAY_SIZE(values), timestamp, interval);
674 } /* }}} int submit_two_gauge */
676 static int submit_double(const char *host, const char *plugin_inst, /* {{{ */
677 const char *type, const char *type_inst, double d,
678 cdtime_t timestamp, cdtime_t interval) {
679 return submit_values(host, plugin_inst, type, type_inst,
683 1, timestamp, interval);
684 } /* }}} int submit_uint64 */
686 /* Calculate hit ratio from old and new counters and submit the resulting
687 * percentage. Used by "submit_wafl_data". */
688 static int submit_cache_ratio(const char *host, /* {{{ */
689 const char *plugin_inst, const char *type_inst,
690 uint64_t new_hits, uint64_t new_misses,
691 uint64_t old_hits, uint64_t old_misses,
692 cdtime_t timestamp, cdtime_t interval) {
693 value_t v = {.gauge = NAN};
695 if ((new_hits >= old_hits) && (new_misses >= old_misses)) {
699 hits = new_hits - old_hits;
700 misses = new_misses - old_misses;
702 v.gauge = 100.0 * ((gauge_t)hits) / ((gauge_t)(hits + misses));
705 return submit_values(host, plugin_inst, "cache_ratio", type_inst, &v, 1,
706 timestamp, interval);
707 } /* }}} int submit_cache_ratio */
709 /* Submits all the caches used by WAFL. Uses "submit_cache_ratio". */
710 static int submit_wafl_data(const char *hostname,
711 const char *instance, /* {{{ */
712 cfg_wafl_t *old_data, const cfg_wafl_t *new_data,
714 /* Submit requested counters */
715 if (HAS_ALL_FLAGS(old_data->flags,
716 CFG_WAFL_NAME_CACHE | HAVE_WAFL_NAME_CACHE) &&
717 HAS_ALL_FLAGS(new_data->flags, HAVE_WAFL_NAME_CACHE))
718 submit_cache_ratio(hostname, instance, "name_cache_hit",
719 new_data->name_cache_hit, new_data->name_cache_miss,
720 old_data->name_cache_hit, old_data->name_cache_miss,
721 new_data->timestamp, interval);
723 if (HAS_ALL_FLAGS(old_data->flags, CFG_WAFL_DIR_CACHE | HAVE_WAFL_FIND_DIR) &&
724 HAS_ALL_FLAGS(new_data->flags, HAVE_WAFL_FIND_DIR))
725 submit_cache_ratio(hostname, instance, "find_dir_hit",
726 new_data->find_dir_hit, new_data->find_dir_miss,
727 old_data->find_dir_hit, old_data->find_dir_miss,
728 new_data->timestamp, interval);
730 if (HAS_ALL_FLAGS(old_data->flags, CFG_WAFL_BUF_CACHE | HAVE_WAFL_BUF_HASH) &&
731 HAS_ALL_FLAGS(new_data->flags, HAVE_WAFL_BUF_HASH))
732 submit_cache_ratio(hostname, instance, "buf_hash_hit",
733 new_data->buf_hash_hit, new_data->buf_hash_miss,
734 old_data->buf_hash_hit, old_data->buf_hash_miss,
735 new_data->timestamp, interval);
737 if (HAS_ALL_FLAGS(old_data->flags,
738 CFG_WAFL_INODE_CACHE | HAVE_WAFL_INODE_CACHE) &&
739 HAS_ALL_FLAGS(new_data->flags, HAVE_WAFL_INODE_CACHE))
740 submit_cache_ratio(hostname, instance, "inode_cache_hit",
741 new_data->inode_cache_hit, new_data->inode_cache_miss,
742 old_data->inode_cache_hit, old_data->inode_cache_miss,
743 new_data->timestamp, interval);
745 /* Clear old HAVE_* flags */
746 old_data->flags &= ~HAVE_WAFL_ALL;
748 /* Copy all counters */
749 old_data->timestamp = new_data->timestamp;
750 old_data->name_cache_hit = new_data->name_cache_hit;
751 old_data->name_cache_miss = new_data->name_cache_miss;
752 old_data->find_dir_hit = new_data->find_dir_hit;
753 old_data->find_dir_miss = new_data->find_dir_miss;
754 old_data->buf_hash_hit = new_data->buf_hash_hit;
755 old_data->buf_hash_miss = new_data->buf_hash_miss;
756 old_data->inode_cache_hit = new_data->inode_cache_hit;
757 old_data->inode_cache_miss = new_data->inode_cache_miss;
759 /* Copy HAVE_* flags */
760 old_data->flags |= (new_data->flags & HAVE_WAFL_ALL);
763 } /* }}} int submit_wafl_data */
765 /* Submits volume performance data to the daemon, taking care to honor and
766 * update flags appropriately. */
767 static int submit_volume_perf_data(const char *hostname, /* {{{ */
768 data_volume_perf_t *old_data,
769 const data_volume_perf_t *new_data,
771 char plugin_instance[DATA_MAX_NAME_LEN];
773 if ((hostname == NULL) || (old_data == NULL) || (new_data == NULL))
776 ssnprintf(plugin_instance, sizeof(plugin_instance), "volume-%s",
779 /* Check for and submit disk-octet values */
780 if (HAS_ALL_FLAGS(old_data->flags, CFG_VOLUME_PERF_IO) &&
781 HAS_ALL_FLAGS(new_data->flags,
782 HAVE_VOLUME_PERF_BYTES_READ |
783 HAVE_VOLUME_PERF_BYTES_WRITE)) {
785 hostname, plugin_instance, "disk_octets", /* type instance = */ NULL,
786 (derive_t)new_data->read_bytes, (derive_t)new_data->write_bytes,
787 new_data->timestamp, interval);
790 /* Check for and submit disk-operations values */
791 if (HAS_ALL_FLAGS(old_data->flags, CFG_VOLUME_PERF_OPS) &&
792 HAS_ALL_FLAGS(new_data->flags,
793 HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE)) {
794 submit_two_derive(hostname, plugin_instance, "disk_ops",
795 /* type instance = */ NULL, (derive_t)new_data->read_ops,
796 (derive_t)new_data->write_ops, new_data->timestamp,
800 /* Check for, calculate and submit disk-latency values */
801 if (HAS_ALL_FLAGS(old_data->flags,
802 CFG_VOLUME_PERF_LATENCY | HAVE_VOLUME_PERF_OPS_READ |
803 HAVE_VOLUME_PERF_OPS_WRITE |
804 HAVE_VOLUME_PERF_LATENCY_READ |
805 HAVE_VOLUME_PERF_LATENCY_WRITE) &&
806 HAS_ALL_FLAGS(new_data->flags,
807 HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE |
808 HAVE_VOLUME_PERF_LATENCY_READ |
809 HAVE_VOLUME_PERF_LATENCY_WRITE)) {
810 gauge_t latency_per_op_read;
811 gauge_t latency_per_op_write;
813 latency_per_op_read = NAN;
814 latency_per_op_write = NAN;
816 /* Check if a counter wrapped around. */
817 if ((new_data->read_ops > old_data->read_ops) &&
818 (new_data->read_latency > old_data->read_latency)) {
819 uint64_t diff_ops_read;
820 uint64_t diff_latency_read;
822 diff_ops_read = new_data->read_ops - old_data->read_ops;
823 diff_latency_read = new_data->read_latency - old_data->read_latency;
825 if (diff_ops_read > 0)
826 latency_per_op_read =
827 ((gauge_t)diff_latency_read) / ((gauge_t)diff_ops_read);
830 if ((new_data->write_ops > old_data->write_ops) &&
831 (new_data->write_latency > old_data->write_latency)) {
832 uint64_t diff_ops_write;
833 uint64_t diff_latency_write;
835 diff_ops_write = new_data->write_ops - old_data->write_ops;
836 diff_latency_write = new_data->write_latency - old_data->write_latency;
838 if (diff_ops_write > 0)
839 latency_per_op_write =
840 ((gauge_t)diff_latency_write) / ((gauge_t)diff_ops_write);
843 submit_two_gauge(hostname, plugin_instance, "disk_latency",
844 /* type instance = */ NULL, latency_per_op_read,
845 latency_per_op_write, new_data->timestamp, interval);
848 /* Clear all HAVE_* flags. */
849 old_data->flags &= ~HAVE_VOLUME_PERF_ALL;
851 /* Copy all counters */
852 old_data->timestamp = new_data->timestamp;
853 old_data->read_bytes = new_data->read_bytes;
854 old_data->write_bytes = new_data->write_bytes;
855 old_data->read_ops = new_data->read_ops;
856 old_data->write_ops = new_data->write_ops;
857 old_data->read_latency = new_data->read_latency;
858 old_data->write_latency = new_data->write_latency;
860 /* Copy the HAVE_* flags */
861 old_data->flags |= (new_data->flags & HAVE_VOLUME_PERF_ALL);
864 } /* }}} int submit_volume_perf_data */
866 static cdtime_t cna_child_get_cdtime(na_elem_t *data) /* {{{ */
870 t = (time_t)na_child_get_uint64(data, "timestamp", /* default = */ 0);
872 return TIME_T_TO_CDTIME_T(t);
873 } /* }}} cdtime_t cna_child_get_cdtime */
878 * These functions are called with appropriate data returned by the libnetapp
879 * interface which is parsed and submitted with the above functions.
881 /* Data corresponding to <WAFL /> */
882 static int cna_handle_wafl_data(const char *hostname,
883 cfg_wafl_t *cfg_wafl, /* {{{ */
884 na_elem_t *data, cdtime_t interval) {
885 cfg_wafl_t perf_data = {0};
886 const char *plugin_inst;
888 na_elem_t *instances;
889 na_elem_iter_t counter_iter;
891 perf_data.timestamp = cna_child_get_cdtime(data);
893 instances = na_elem_child(na_elem_child(data, "instances"), "instance-data");
894 if (instances == NULL) {
895 ERROR("netapp plugin: cna_handle_wafl_data: "
896 "na_elem_child (\"instances\") failed "
902 plugin_inst = na_child_get_string(instances, "name");
903 if (plugin_inst == NULL) {
904 ERROR("netapp plugin: cna_handle_wafl_data: "
905 "na_child_get_string (\"name\") failed "
911 /* Iterate over all counters */
912 counter_iter = na_child_iterator(na_elem_child(instances, "counters"));
913 for (na_elem_t *counter = na_iterator_next(&counter_iter); counter != NULL;
914 counter = na_iterator_next(&counter_iter)) {
918 name = na_child_get_string(counter, "name");
922 value = na_child_get_uint64(counter, "value", UINT64_MAX);
923 if (value == UINT64_MAX)
926 if (!strcmp(name, "name_cache_hit")) {
927 perf_data.name_cache_hit = value;
928 perf_data.flags |= HAVE_WAFL_NAME_CACHE_HIT;
929 } else if (!strcmp(name, "name_cache_miss")) {
930 perf_data.name_cache_miss = value;
931 perf_data.flags |= HAVE_WAFL_NAME_CACHE_MISS;
932 } else if (!strcmp(name, "find_dir_hit")) {
933 perf_data.find_dir_hit = value;
934 perf_data.flags |= HAVE_WAFL_FIND_DIR_HIT;
935 } else if (!strcmp(name, "find_dir_miss")) {
936 perf_data.find_dir_miss = value;
937 perf_data.flags |= HAVE_WAFL_FIND_DIR_MISS;
938 } else if (!strcmp(name, "buf_hash_hit")) {
939 perf_data.buf_hash_hit = value;
940 perf_data.flags |= HAVE_WAFL_BUF_HASH_HIT;
941 } else if (!strcmp(name, "buf_hash_miss")) {
942 perf_data.buf_hash_miss = value;
943 perf_data.flags |= HAVE_WAFL_BUF_HASH_MISS;
944 } else if (!strcmp(name, "inode_cache_hit")) {
945 perf_data.inode_cache_hit = value;
946 perf_data.flags |= HAVE_WAFL_INODE_CACHE_HIT;
947 } else if (!strcmp(name, "inode_cache_miss")) {
948 perf_data.inode_cache_miss = value;
949 perf_data.flags |= HAVE_WAFL_INODE_CACHE_MISS;
951 DEBUG("netapp plugin: cna_handle_wafl_data: "
952 "Found unexpected child: %s "
958 return submit_wafl_data(hostname, plugin_inst, cfg_wafl, &perf_data,
960 } /* }}} void cna_handle_wafl_data */
962 static int cna_setup_wafl(cfg_wafl_t *cw) /* {{{ */
969 if (cw->query != NULL)
972 cw->query = na_elem_new("perf-object-get-instances");
973 if (cw->query == NULL) {
974 ERROR("netapp plugin: na_elem_new failed.");
977 na_child_add_string(cw->query, "objectname", "wafl");
979 e = na_elem_new("counters");
981 na_elem_free(cw->query);
983 ERROR("netapp plugin: na_elem_new failed.");
986 na_child_add_string(e, "counter", "name_cache_hit");
987 na_child_add_string(e, "counter", "name_cache_miss");
988 na_child_add_string(e, "counter", "find_dir_hit");
989 na_child_add_string(e, "counter", "find_dir_miss");
990 na_child_add_string(e, "counter", "buf_hash_hit");
991 na_child_add_string(e, "counter", "buf_hash_miss");
992 na_child_add_string(e, "counter", "inode_cache_hit");
993 na_child_add_string(e, "counter", "inode_cache_miss");
995 na_child_add(cw->query, e);
998 } /* }}} int cna_setup_wafl */
1000 static int cna_query_wafl(host_config_t *host) /* {{{ */
1009 /* If WAFL was not configured, return without doing anything. */
1010 if (host->cfg_wafl == NULL)
1014 if ((host->cfg_wafl->interval.interval + host->cfg_wafl->interval.last_read) >
1018 status = cna_setup_wafl(host->cfg_wafl);
1021 assert(host->cfg_wafl->query != NULL);
1023 data = na_server_invoke_elem(host->srv, host->cfg_wafl->query);
1024 if (na_results_status(data) != NA_OK) {
1025 ERROR("netapp plugin: cna_query_wafl: na_server_invoke_elem failed for "
1027 host->name, na_results_reason(data));
1032 status = cna_handle_wafl_data(host->name, host->cfg_wafl, data,
1033 host->cfg_wafl->interval.interval);
1036 host->cfg_wafl->interval.last_read = now;
1040 } /* }}} int cna_query_wafl */
1042 /* Data corresponding to <Disks /> */
1043 static int cna_handle_disk_data(const char *hostname, /* {{{ */
1044 cfg_disk_t *cfg_disk, na_elem_t *data,
1045 cdtime_t interval) {
1047 na_elem_t *instances;
1048 na_elem_iter_t instance_iter;
1049 disk_t *worst_disk = NULL;
1051 if ((cfg_disk == NULL) || (data == NULL))
1054 timestamp = cna_child_get_cdtime(data);
1056 instances = na_elem_child(data, "instances");
1057 if (instances == NULL) {
1058 ERROR("netapp plugin: cna_handle_disk_data: "
1059 "na_elem_child (\"instances\") failed "
1065 /* Iterate over all children */
1066 instance_iter = na_child_iterator(instances);
1067 for (na_elem_t *instance = na_iterator_next(&instance_iter); instance != NULL;
1068 instance = na_iterator_next(&instance_iter)) {
1070 disk_t new_data = {0};
1072 na_elem_iter_t counter_iterator;
1074 new_data.timestamp = timestamp;
1075 new_data.disk_busy_percent = NAN;
1077 old_data = get_disk(cfg_disk, na_child_get_string(instance, "name"));
1078 if (old_data == NULL)
1081 /* Look for the "disk_busy" and "base_for_disk_busy" counters */
1082 counter_iterator = na_child_iterator(na_elem_child(instance, "counters"));
1083 for (na_elem_t *counter = na_iterator_next(&counter_iterator);
1084 counter != NULL; counter = na_iterator_next(&counter_iterator)) {
1088 name = na_child_get_string(counter, "name");
1092 value = na_child_get_uint64(counter, "value", UINT64_MAX);
1093 if (value == UINT64_MAX)
1096 if (strcmp(name, "disk_busy") == 0) {
1097 new_data.disk_busy = value;
1098 new_data.flags |= HAVE_DISK_BUSY;
1099 } else if (strcmp(name, "base_for_disk_busy") == 0) {
1100 new_data.base_for_disk_busy = value;
1101 new_data.flags |= HAVE_DISK_BASE;
1103 DEBUG("netapp plugin: cna_handle_disk_data: "
1104 "Counter not handled: %s = %" PRIu64,
1109 /* If all required counters are available and did not just wrap around,
1110 * calculate the busy percentage. Otherwise, the value is initialized to
1111 * NAN at the top of the for-loop. */
1112 if (HAS_ALL_FLAGS(old_data->flags, HAVE_DISK_BUSY | HAVE_DISK_BASE) &&
1113 HAS_ALL_FLAGS(new_data.flags, HAVE_DISK_BUSY | HAVE_DISK_BASE) &&
1114 (new_data.disk_busy >= old_data->disk_busy) &&
1115 (new_data.base_for_disk_busy > old_data->base_for_disk_busy)) {
1119 busy_diff = new_data.disk_busy - old_data->disk_busy;
1120 base_diff = new_data.base_for_disk_busy - old_data->base_for_disk_busy;
1122 new_data.disk_busy_percent =
1123 100.0 * ((gauge_t)busy_diff) / ((gauge_t)base_diff);
1126 /* Clear HAVE_* flags */
1127 old_data->flags &= ~HAVE_DISK_ALL;
1130 old_data->timestamp = new_data.timestamp;
1131 old_data->disk_busy = new_data.disk_busy;
1132 old_data->base_for_disk_busy = new_data.base_for_disk_busy;
1133 old_data->disk_busy_percent = new_data.disk_busy_percent;
1136 old_data->flags |= (new_data.flags & HAVE_DISK_ALL);
1138 if ((worst_disk == NULL) ||
1139 (worst_disk->disk_busy_percent < old_data->disk_busy_percent))
1140 worst_disk = old_data;
1141 } /* for (all disks) */
1143 if ((cfg_disk->flags & CFG_DISK_BUSIEST) && (worst_disk != NULL))
1144 submit_double(hostname, "system", "percent", "disk_busy",
1145 worst_disk->disk_busy_percent, timestamp, interval);
1148 } /* }}} int cna_handle_disk_data */
1150 static int cna_setup_disk(cfg_disk_t *cd) /* {{{ */
1157 if (cd->query != NULL)
1160 cd->query = na_elem_new("perf-object-get-instances");
1161 if (cd->query == NULL) {
1162 ERROR("netapp plugin: na_elem_new failed.");
1165 na_child_add_string(cd->query, "objectname", "disk");
1167 e = na_elem_new("counters");
1169 na_elem_free(cd->query);
1171 ERROR("netapp plugin: na_elem_new failed.");
1174 na_child_add_string(e, "counter", "disk_busy");
1175 na_child_add_string(e, "counter", "base_for_disk_busy");
1176 na_child_add(cd->query, e);
1179 } /* }}} int cna_setup_disk */
1181 static int cna_query_disk(host_config_t *host) /* {{{ */
1190 /* If the user did not configure disk statistics, return without doing
1192 if (host->cfg_disk == NULL)
1196 if ((host->cfg_disk->interval.interval + host->cfg_disk->interval.last_read) >
1200 status = cna_setup_disk(host->cfg_disk);
1203 assert(host->cfg_disk->query != NULL);
1205 data = na_server_invoke_elem(host->srv, host->cfg_disk->query);
1206 if (na_results_status(data) != NA_OK) {
1207 ERROR("netapp plugin: cna_query_disk: na_server_invoke_elem failed for "
1209 host->name, na_results_reason(data));
1214 status = cna_handle_disk_data(host->name, host->cfg_disk, data,
1215 host->cfg_disk->interval.interval);
1218 host->cfg_disk->interval.last_read = now;
1222 } /* }}} int cna_query_disk */
1224 /* Data corresponding to <VolumePerf /> */
1225 static int cna_handle_volume_perf_data(const char *hostname, /* {{{ */
1226 cfg_volume_perf_t *cvp, na_elem_t *data,
1227 cdtime_t interval) {
1229 na_elem_t *elem_instances;
1230 na_elem_iter_t iter_instances;
1232 timestamp = cna_child_get_cdtime(data);
1234 elem_instances = na_elem_child(data, "instances");
1235 if (elem_instances == NULL) {
1236 ERROR("netapp plugin: handle_volume_perf_data: "
1237 "na_elem_child (\"instances\") failed "
1243 iter_instances = na_child_iterator(elem_instances);
1244 for (na_elem_t *elem_instance = na_iterator_next(&iter_instances);
1245 elem_instance != NULL;
1246 elem_instance = na_iterator_next(&iter_instances)) {
1249 data_volume_perf_t perf_data = {0};
1250 data_volume_perf_t *v;
1252 na_elem_t *elem_counters;
1253 na_elem_iter_t iter_counters;
1255 perf_data.timestamp = timestamp;
1257 name = na_child_get_string(elem_instance, "name");
1261 /* get_volume_perf may return NULL if this volume is to be ignored. */
1262 v = get_volume_perf(cvp, name);
1266 elem_counters = na_elem_child(elem_instance, "counters");
1267 if (elem_counters == NULL)
1270 iter_counters = na_child_iterator(elem_counters);
1271 for (na_elem_t *elem_counter = na_iterator_next(&iter_counters);
1272 elem_counter != NULL;
1273 elem_counter = na_iterator_next(&iter_counters)) {
1277 name = na_child_get_string(elem_counter, "name");
1281 value = na_child_get_uint64(elem_counter, "value", UINT64_MAX);
1282 if (value == UINT64_MAX)
1285 if (!strcmp(name, "read_data")) {
1286 perf_data.read_bytes = value;
1287 perf_data.flags |= HAVE_VOLUME_PERF_BYTES_READ;
1288 } else if (!strcmp(name, "write_data")) {
1289 perf_data.write_bytes = value;
1290 perf_data.flags |= HAVE_VOLUME_PERF_BYTES_WRITE;
1291 } else if (!strcmp(name, "read_ops")) {
1292 perf_data.read_ops = value;
1293 perf_data.flags |= HAVE_VOLUME_PERF_OPS_READ;
1294 } else if (!strcmp(name, "write_ops")) {
1295 perf_data.write_ops = value;
1296 perf_data.flags |= HAVE_VOLUME_PERF_OPS_WRITE;
1297 } else if (!strcmp(name, "read_latency")) {
1298 perf_data.read_latency = value;
1299 perf_data.flags |= HAVE_VOLUME_PERF_LATENCY_READ;
1300 } else if (!strcmp(name, "write_latency")) {
1301 perf_data.write_latency = value;
1302 perf_data.flags |= HAVE_VOLUME_PERF_LATENCY_WRITE;
1304 } /* for (elem_counter) */
1306 submit_volume_perf_data(hostname, v, &perf_data, interval);
1307 } /* for (volume) */
1310 } /* }}} int cna_handle_volume_perf_data */
1312 static int cna_setup_volume_perf(cfg_volume_perf_t *cd) /* {{{ */
1319 if (cd->query != NULL)
1322 cd->query = na_elem_new("perf-object-get-instances");
1323 if (cd->query == NULL) {
1324 ERROR("netapp plugin: na_elem_new failed.");
1327 na_child_add_string(cd->query, "objectname", "volume");
1329 e = na_elem_new("counters");
1331 na_elem_free(cd->query);
1333 ERROR("netapp plugin: na_elem_new failed.");
1336 na_child_add_string(e, "counter", "read_ops");
1337 na_child_add_string(e, "counter", "write_ops");
1338 na_child_add_string(e, "counter", "read_data");
1339 na_child_add_string(e, "counter", "write_data");
1340 na_child_add_string(e, "counter", "read_latency");
1341 na_child_add_string(e, "counter", "write_latency");
1342 na_child_add(cd->query, e);
1345 } /* }}} int cna_setup_volume_perf */
1347 static int cna_query_volume_perf(host_config_t *host) /* {{{ */
1356 /* If the user did not configure volume performance statistics, return
1357 * without doing anything. */
1358 if (host->cfg_volume_perf == NULL)
1362 if ((host->cfg_volume_perf->interval.interval +
1363 host->cfg_volume_perf->interval.last_read) > now)
1366 status = cna_setup_volume_perf(host->cfg_volume_perf);
1369 assert(host->cfg_volume_perf->query != NULL);
1371 data = na_server_invoke_elem(host->srv, host->cfg_volume_perf->query);
1372 if (na_results_status(data) != NA_OK) {
1373 ERROR("netapp plugin: cna_query_volume_perf: na_server_invoke_elem failed "
1375 host->name, na_results_reason(data));
1381 cna_handle_volume_perf_data(host->name, host->cfg_volume_perf, data,
1382 host->cfg_volume_perf->interval.interval);
1385 host->cfg_volume_perf->interval.last_read = now;
1389 } /* }}} int cna_query_volume_perf */
1391 /* Data corresponding to <VolumeUsage /> */
1392 static int cna_submit_volume_usage_data(const char *hostname, /* {{{ */
1393 cfg_volume_usage_t *cfg_volume,
1395 for (data_volume_usage_t *v = cfg_volume->volumes; v != NULL; v = v->next) {
1396 char plugin_instance[DATA_MAX_NAME_LEN];
1398 uint64_t norm_used = v->norm_used;
1399 uint64_t norm_free = v->norm_free;
1400 uint64_t sis_saved = v->sis_saved;
1401 uint64_t compress_saved = v->compress_saved;
1402 uint64_t dedup_saved = v->dedup_saved;
1403 uint64_t snap_reserve_used = 0;
1404 uint64_t snap_reserve_free = v->snap_reserved;
1405 uint64_t snap_norm_used = v->snap_used;
1407 ssnprintf(plugin_instance, sizeof(plugin_instance), "volume-%s", v->name);
1409 if (HAS_ALL_FLAGS(v->flags,
1410 HAVE_VOLUME_USAGE_SNAP_USED |
1411 HAVE_VOLUME_USAGE_SNAP_RSVD)) {
1412 if (v->snap_reserved > v->snap_used) {
1413 snap_reserve_free = v->snap_reserved - v->snap_used;
1414 snap_reserve_used = v->snap_used;
1417 snap_reserve_free = 0;
1418 snap_reserve_used = v->snap_reserved;
1419 snap_norm_used = v->snap_used - v->snap_reserved;
1423 /* The space used by snapshots but not reserved for them is included in
1424 * both, norm_used and snap_norm_used. If possible, subtract this here. */
1425 if (HAS_ALL_FLAGS(v->flags,
1426 HAVE_VOLUME_USAGE_NORM_USED |
1427 HAVE_VOLUME_USAGE_SNAP_USED)) {
1428 if (norm_used >= snap_norm_used)
1429 norm_used -= snap_norm_used;
1431 ERROR("netapp plugin: (norm_used = %" PRIu64 ") < (snap_norm_used = "
1432 "%" PRIu64 ") for host %s. Invalidating both.",
1433 norm_used, snap_norm_used, hostname);
1435 ~(HAVE_VOLUME_USAGE_NORM_USED | HAVE_VOLUME_USAGE_SNAP_USED);
1439 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_NORM_FREE))
1440 submit_double(hostname, /* plugin instance = */ plugin_instance,
1441 "df_complex", "free", (double)norm_free,
1442 /* timestamp = */ 0, interval);
1444 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SIS_SAVED))
1445 submit_double(hostname, /* plugin instance = */ plugin_instance,
1446 "df_complex", "sis_saved", (double)sis_saved,
1447 /* timestamp = */ 0, interval);
1449 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_COMPRESS_SAVED))
1450 submit_double(hostname, /* plugin instance = */ plugin_instance,
1451 "df_complex", "compression_saved", (double)compress_saved,
1452 /* timestamp = */ 0, interval);
1454 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_DEDUP_SAVED))
1455 submit_double(hostname, /* plugin instance = */ plugin_instance,
1456 "df_complex", "dedup_saved", (double)dedup_saved,
1457 /* timestamp = */ 0, interval);
1459 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_NORM_USED))
1460 submit_double(hostname, /* plugin instance = */ plugin_instance,
1461 "df_complex", "used", (double)norm_used,
1462 /* timestamp = */ 0, interval);
1464 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_RSVD))
1465 submit_double(hostname, /* plugin instance = */ plugin_instance,
1466 "df_complex", "snap_reserved", (double)snap_reserve_free,
1467 /* timestamp = */ 0, interval);
1469 if (HAS_ALL_FLAGS(v->flags,
1470 HAVE_VOLUME_USAGE_SNAP_USED |
1471 HAVE_VOLUME_USAGE_SNAP_RSVD))
1472 submit_double(hostname, /* plugin instance = */ plugin_instance,
1473 "df_complex", "snap_reserve_used",
1474 (double)snap_reserve_used, /* timestamp = */ 0, interval);
1476 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_USED))
1477 submit_double(hostname, /* plugin instance = */ plugin_instance,
1478 "df_complex", "snap_normal_used", (double)snap_norm_used,
1479 /* timestamp = */ 0, interval);
1481 /* Clear all the HAVE_* flags */
1482 v->flags &= ~HAVE_VOLUME_USAGE_ALL;
1483 } /* for (v = cfg_volume->volumes) */
1486 } /* }}} int cna_submit_volume_usage_data */
1488 /* Switch the state of a volume between online and offline and send out a
1490 static int cna_change_volume_status(const char *hostname, /* {{{ */
1491 data_volume_usage_t *v) {
1492 notification_t n = {0};
1495 sstrncpy(n.host, hostname, sizeof(n.host));
1496 sstrncpy(n.plugin, "netapp", sizeof(n.plugin));
1497 sstrncpy(n.plugin_instance, v->name, sizeof(n.plugin_instance));
1499 if ((v->flags & IS_VOLUME_USAGE_OFFLINE) != 0) {
1500 n.severity = NOTIF_OKAY;
1501 ssnprintf(n.message, sizeof(n.message), "Volume %s is now online.",
1503 v->flags &= ~IS_VOLUME_USAGE_OFFLINE;
1505 n.severity = NOTIF_WARNING;
1506 ssnprintf(n.message, sizeof(n.message), "Volume %s is now offline.",
1508 v->flags |= IS_VOLUME_USAGE_OFFLINE;
1511 return plugin_dispatch_notification(&n);
1512 } /* }}} int cna_change_volume_status */
1514 static void cna_handle_volume_snap_usage(const host_config_t *host, /* {{{ */
1515 data_volume_usage_t *v) {
1516 uint64_t snap_used = 0, value;
1517 na_elem_t *data, *elem_snapshots;
1518 na_elem_iter_t iter_snap;
1520 data = na_server_invoke_elem(host->srv, v->snap_query);
1521 if (na_results_status(data) != NA_OK) {
1522 if (na_results_errno(data) == EVOLUMEOFFLINE) {
1523 if ((v->flags & IS_VOLUME_USAGE_OFFLINE) == 0)
1524 cna_change_volume_status(host->name, v);
1526 ERROR("netapp plugin: cna_handle_volume_snap_usage: "
1527 "na_server_invoke_elem for "
1528 "volume \"%s\" on host %s failed with error %d: %s",
1529 v->name, host->name, na_results_errno(data),
1530 na_results_reason(data));
1536 if ((v->flags & IS_VOLUME_USAGE_OFFLINE) != 0)
1537 cna_change_volume_status(host->name, v);
1539 elem_snapshots = na_elem_child(data, "snapshots");
1540 if (elem_snapshots == NULL) {
1541 ERROR("netapp plugin: cna_handle_volume_snap_usage: "
1542 "na_elem_child (\"snapshots\") failed "
1549 iter_snap = na_child_iterator(elem_snapshots);
1550 for (na_elem_t *elem_snap = na_iterator_next(&iter_snap); elem_snap != NULL;
1551 elem_snap = na_iterator_next(&iter_snap)) {
1552 value = na_child_get_uint64(elem_snap, "cumulative-total", 0);
1553 /* "cumulative-total" is the total size of the oldest snapshot plus all
1554 * newer ones in blocks (1KB). We therefore are looking for the highest
1555 * number of all snapshots - that's the size required for the snapshots. */
1556 if (value > snap_used)
1560 /* snap_used is in 1024 byte blocks */
1561 v->snap_used = snap_used * 1024;
1562 v->flags |= HAVE_VOLUME_USAGE_SNAP_USED;
1563 } /* }}} void cna_handle_volume_snap_usage */
1565 static void cna_handle_volume_sis_data(const host_config_t *host, /* {{{ */
1566 data_volume_usage_t *v, na_elem_t *sis) {
1567 const char *sis_state;
1568 uint64_t sis_saved_reported;
1570 if (na_elem_child(sis, "sis-info"))
1571 sis = na_elem_child(sis, "sis-info");
1573 sis_state = na_child_get_string(sis, "state");
1574 if (sis_state == NULL)
1577 /* If SIS is not enabled, there's nothing left to do for this volume. */
1578 if (strcmp("enabled", sis_state) != 0)
1581 sis_saved_reported = na_child_get_uint64(sis, "size-saved", UINT64_MAX);
1582 if (sis_saved_reported == UINT64_MAX)
1585 /* size-saved is actually a 32 bit number, so ... time for some guesswork. */
1586 if ((sis_saved_reported >> 32) != 0) {
1587 /* In case they ever fix this bug. */
1588 v->sis_saved = sis_saved_reported;
1589 v->flags |= HAVE_VOLUME_USAGE_SIS_SAVED;
1590 } else { /* really hacky work-around code. {{{ */
1591 uint64_t sis_saved_percent;
1592 uint64_t sis_saved_guess;
1593 uint64_t overflow_guess;
1594 uint64_t guess1, guess2, guess3;
1596 /* Check if we have v->norm_used. Without it, we cannot calculate
1597 * sis_saved_guess. */
1598 if ((v->flags & HAVE_VOLUME_USAGE_NORM_USED) == 0)
1602 na_child_get_uint64(sis, "percentage-saved", UINT64_MAX);
1603 if (sis_saved_percent > 100)
1606 /* The "size-saved" value is a 32bit unsigned integer. This is a bug and
1607 * will hopefully be fixed in later versions. To work around the bug, try
1608 * to figure out how often the 32bit integer wrapped around by using the
1609 * "percentage-saved" value. Because the percentage is in the range
1610 * [0-100], this should work as long as the saved space does not exceed
1612 /* percentage-saved = size-saved / (size-saved + size-used) */
1613 if (sis_saved_percent < 100)
1615 v->norm_used * sis_saved_percent / (100 - sis_saved_percent);
1617 sis_saved_guess = v->norm_used;
1619 overflow_guess = sis_saved_guess >> 32;
1620 guess1 = overflow_guess ? ((overflow_guess - 1) << 32) + sis_saved_reported
1621 : sis_saved_reported;
1622 guess2 = (overflow_guess << 32) + sis_saved_reported;
1623 guess3 = ((overflow_guess + 1) << 32) + sis_saved_reported;
1625 if (sis_saved_guess < guess2) {
1626 if ((sis_saved_guess - guess1) < (guess2 - sis_saved_guess))
1627 v->sis_saved = guess1;
1629 v->sis_saved = guess2;
1631 if ((sis_saved_guess - guess2) < (guess3 - sis_saved_guess))
1632 v->sis_saved = guess2;
1634 v->sis_saved = guess3;
1636 v->flags |= HAVE_VOLUME_USAGE_SIS_SAVED;
1637 } /* }}} end of 32-bit workaround */
1638 } /* }}} void cna_handle_volume_sis_data */
1640 /* ONTAP >= 8.1 uses SIS for managing dedup and compression */
1641 static void cna_handle_volume_sis_saved(const host_config_t *host, /* {{{ */
1642 data_volume_usage_t *v,
1646 if (na_elem_child(sis, "sis-info"))
1647 sis = na_elem_child(sis, "sis-info");
1649 saved = na_child_get_uint64(sis, "compress-saved", UINT64_MAX);
1650 if (saved != UINT64_MAX) {
1651 v->compress_saved = saved;
1652 v->flags |= HAVE_VOLUME_USAGE_COMPRESS_SAVED;
1655 saved = na_child_get_uint64(sis, "dedup-saved", UINT64_MAX);
1656 if (saved != UINT64_MAX) {
1657 v->dedup_saved = saved;
1658 v->flags |= HAVE_VOLUME_USAGE_DEDUP_SAVED;
1660 } /* }}} void cna_handle_volume_sis_saved */
1662 static int cna_handle_volume_usage_data(const host_config_t *host, /* {{{ */
1663 cfg_volume_usage_t *cfg_volume,
1665 na_elem_t *elem_volumes;
1666 na_elem_iter_t iter_volume;
1668 elem_volumes = na_elem_child(data, "volumes");
1669 if (elem_volumes == NULL) {
1670 ERROR("netapp plugin: cna_handle_volume_usage_data: "
1671 "na_elem_child (\"volumes\") failed "
1677 iter_volume = na_child_iterator(elem_volumes);
1678 for (na_elem_t *elem_volume = na_iterator_next(&iter_volume);
1679 elem_volume != NULL; elem_volume = na_iterator_next(&iter_volume)) {
1680 const char *volume_name, *state;
1682 data_volume_usage_t *v;
1687 volume_name = na_child_get_string(elem_volume, "name");
1688 if (volume_name == NULL)
1691 state = na_child_get_string(elem_volume, "state");
1692 if ((state == NULL) || (strcmp(state, "online") != 0))
1695 /* get_volume_usage may return NULL if the volume is to be ignored. */
1696 v = get_volume_usage(cfg_volume, volume_name);
1700 if ((v->flags & CFG_VOLUME_USAGE_SNAP) != 0)
1701 cna_handle_volume_snap_usage(host, v);
1703 if ((v->flags & CFG_VOLUME_USAGE_DF) == 0)
1706 /* 2^4 exa-bytes? This will take a while ;) */
1707 value = na_child_get_uint64(elem_volume, "size-available", UINT64_MAX);
1708 if (value != UINT64_MAX) {
1709 v->norm_free = value;
1710 v->flags |= HAVE_VOLUME_USAGE_NORM_FREE;
1713 value = na_child_get_uint64(elem_volume, "size-used", UINT64_MAX);
1714 if (value != UINT64_MAX) {
1715 v->norm_used = value;
1716 v->flags |= HAVE_VOLUME_USAGE_NORM_USED;
1719 value = na_child_get_uint64(elem_volume, "snapshot-blocks-reserved",
1721 if (value != UINT64_MAX) {
1722 /* 1 block == 1024 bytes as per API docs */
1723 v->snap_reserved = 1024 * value;
1724 v->flags |= HAVE_VOLUME_USAGE_SNAP_RSVD;
1727 sis = na_elem_child(elem_volume, "sis");
1729 cna_handle_volume_sis_data(host, v, sis);
1730 cna_handle_volume_sis_saved(host, v, sis);
1732 } /* for (elem_volume) */
1734 return cna_submit_volume_usage_data(
1735 host->name, cfg_volume, host->cfg_volume_usage->interval.interval);
1736 } /* }}} int cna_handle_volume_usage_data */
1738 static int cna_setup_volume_usage(cfg_volume_usage_t *cvu) /* {{{ */
1743 if (cvu->query != NULL)
1746 cvu->query = na_elem_new("volume-list-info");
1747 if (cvu->query == NULL) {
1748 ERROR("netapp plugin: na_elem_new failed.");
1753 } /* }}} int cna_setup_volume_usage */
1755 static int cna_query_volume_usage(host_config_t *host) /* {{{ */
1764 /* If the user did not configure volume_usage statistics, return without
1765 * doing anything. */
1766 if (host->cfg_volume_usage == NULL)
1770 if ((host->cfg_volume_usage->interval.interval +
1771 host->cfg_volume_usage->interval.last_read) > now)
1774 status = cna_setup_volume_usage(host->cfg_volume_usage);
1777 assert(host->cfg_volume_usage->query != NULL);
1779 data = na_server_invoke_elem(host->srv, host->cfg_volume_usage->query);
1780 if (na_results_status(data) != NA_OK) {
1781 ERROR("netapp plugin: cna_query_volume_usage: na_server_invoke_elem failed "
1783 host->name, na_results_reason(data));
1788 status = cna_handle_volume_usage_data(host, host->cfg_volume_usage, data);
1791 host->cfg_volume_usage->interval.last_read = now;
1795 } /* }}} int cna_query_volume_usage */
1797 /* Data corresponding to <Quota /> */
1798 static int cna_handle_quota_data(const host_config_t *host, /* {{{ */
1799 cfg_quota_t *cfg_quota, na_elem_t *data) {
1800 na_elem_t *elem_quotas;
1801 na_elem_iter_t iter_quota;
1803 elem_quotas = na_elem_child(data, "quotas");
1804 if (elem_quotas == NULL) {
1805 ERROR("netapp plugin: cna_handle_quota_data: "
1806 "na_elem_child (\"quotas\") failed "
1812 iter_quota = na_child_iterator(elem_quotas);
1813 for (na_elem_t *elem_quota = na_iterator_next(&iter_quota);
1814 elem_quota != NULL; elem_quota = na_iterator_next(&iter_quota)) {
1815 const char *quota_type, *volume_name, *tree_name;
1818 char plugin_instance[DATA_MAX_NAME_LEN];
1820 quota_type = na_child_get_string(elem_quota, "quota-type");
1821 if (quota_type == NULL)
1824 /* possible TODO: support other types as well */
1825 if (strcmp(quota_type, "tree") != 0)
1828 tree_name = na_child_get_string(elem_quota, "tree");
1829 if ((tree_name == NULL) || (*tree_name == '\0'))
1832 volume_name = na_child_get_string(elem_quota, "volume");
1833 if (volume_name == NULL)
1836 ssnprintf(plugin_instance, sizeof(plugin_instance), "quota-%s-%s",
1837 volume_name, tree_name);
1839 value = na_child_get_uint64(elem_quota, "disk-used", UINT64_MAX);
1840 if (value != UINT64_MAX) {
1841 value *= 1024; /* disk-used reports kilobytes */
1842 submit_double(host->name, plugin_instance,
1843 /* type = */ "df_complex", /* type instance = */ NULL,
1844 (double)value, /* timestamp = */ 0,
1845 host->cfg_quota->interval.interval);
1848 value = na_child_get_uint64(elem_quota, "files-used", UINT64_MAX);
1849 if (value != UINT64_MAX) {
1850 submit_double(host->name, plugin_instance,
1851 /* type = */ "files", /* type instance = */ NULL,
1852 (double)value, /* timestamp = */ 0,
1853 host->cfg_quota->interval.interval);
1855 } /* for (elem_quota) */
1858 } /* }}} int cna_handle_volume_usage_data */
1860 static int cna_setup_quota(cfg_quota_t *cq) /* {{{ */
1865 if (cq->query != NULL)
1868 cq->query = na_elem_new("quota-report");
1869 if (cq->query == NULL) {
1870 ERROR("netapp plugin: na_elem_new failed.");
1875 } /* }}} int cna_setup_quota */
1877 static int cna_query_quota(host_config_t *host) /* {{{ */
1886 /* If the user did not configure quota statistics, return without
1887 * doing anything. */
1888 if (host->cfg_quota == NULL)
1892 if ((host->cfg_quota->interval.interval +
1893 host->cfg_quota->interval.last_read) > now)
1896 status = cna_setup_quota(host->cfg_quota);
1899 assert(host->cfg_quota->query != NULL);
1901 data = na_server_invoke_elem(host->srv, host->cfg_quota->query);
1902 if (na_results_status(data) != NA_OK) {
1903 ERROR("netapp plugin: cna_query_quota: na_server_invoke_elem failed for "
1905 host->name, na_results_reason(data));
1910 status = cna_handle_quota_data(host, host->cfg_quota, data);
1913 host->cfg_quota->interval.last_read = now;
1917 } /* }}} int cna_query_quota */
1919 /* Data corresponding to <SnapVault /> */
1920 static int cna_handle_snapvault_data(const char *hostname, /* {{{ */
1921 cfg_snapvault_t *cfg_snapvault,
1922 na_elem_t *data, cdtime_t interval) {
1923 na_elem_t *status_list = na_elem_child(data, "status-list");
1924 if (status_list == NULL) {
1925 ERROR("netapp plugin: SnapVault status record missing status-list");
1929 na_elem_iter_t status_iter = na_child_iterator(status_list);
1930 for (na_elem_t *status = na_iterator_next(&status_iter); status != NULL;
1931 status = na_iterator_next(&status_iter)) {
1932 const char *dest_sys, *dest_path, *src_sys, *src_path;
1933 char plugin_instance[DATA_MAX_NAME_LEN];
1936 dest_sys = na_child_get_string(status, "destination-system");
1937 dest_path = na_child_get_string(status, "destination-path");
1938 src_sys = na_child_get_string(status, "source-system");
1939 src_path = na_child_get_string(status, "source-path");
1941 if ((!dest_sys) || (!dest_path) || (!src_sys) || (!src_path))
1944 value = na_child_get_uint64(status, "lag-time", UINT64_MAX);
1945 if (value == UINT64_MAX) /* no successful baseline transfer yet */
1948 /* possible TODO: make plugin instance configurable */
1949 ssnprintf(plugin_instance, sizeof(plugin_instance), "snapvault-%s",
1951 submit_double(hostname, plugin_instance, /* type = */ "delay", NULL,
1952 (double)value, /* timestamp = */ 0, interval);
1954 value = na_child_get_uint64(status, "last-transfer-duration", UINT64_MAX);
1955 if (value != UINT64_MAX)
1956 submit_double(hostname, plugin_instance, /* type = */ "duration",
1957 "last_transfer", (double)value, /* timestamp = */ 0,
1960 value = na_child_get_uint64(status, "transfer-progress", UINT64_MAX);
1961 if (value == UINT64_MAX)
1962 value = na_child_get_uint64(status, "last-transfer-size", UINT64_MAX);
1963 if (value != UINT64_MAX) {
1964 value *= 1024; /* this is kilobytes */
1965 submit_derive(hostname, plugin_instance, /* type = */ "if_rx_octets",
1966 "transferred", value, /* timestamp = */ 0, interval);
1968 } /* for (status) */
1971 } /* }}} int cna_handle_snapvault_data */
1973 static int cna_handle_snapvault_iter(host_config_t *host, /* {{{ */
1977 uint32_t records_count;
1979 records_count = na_child_get_uint32(data, "records", UINT32_MAX);
1980 if (records_count == UINT32_MAX)
1983 tag = na_child_get_string(data, "tag");
1987 DEBUG("netapp plugin: Iterating %u SV records (tag = %s)", records_count,
1990 for (uint32_t i = 0; i < records_count; ++i) {
1993 elem = na_server_invoke(
1994 host->srv, "snapvault-secondary-relationship-status-list-iter-next",
1995 "maximum", "1", "tag", tag, NULL);
1997 if (na_results_status(elem) != NA_OK) {
1998 ERROR("netapp plugin: cna_handle_snapvault_iter: "
1999 "na_server_invoke failed for host %s: %s",
2000 host->name, na_results_reason(data));
2005 cna_handle_snapvault_data(host->name, host->cfg_snapvault, elem,
2006 host->cfg_snapvault->interval.interval);
2010 na_elem_free(na_server_invoke(
2011 host->srv, "snapvault-secondary-relationship-status-list-iter-end", "tag",
2014 } /* }}} int cna_handle_snapvault_iter */
2016 static int cna_setup_snapvault(cfg_snapvault_t *sv) /* {{{ */
2021 if (sv->query != NULL)
2025 na_elem_new("snapvault-secondary-relationship-status-list-iter-start");
2026 if (sv->query == NULL) {
2027 ERROR("netapp plugin: na_elem_new failed.");
2032 } /* }}} int cna_setup_snapvault */
2034 static int cna_query_snapvault(host_config_t *host) /* {{{ */
2043 if (host->cfg_snapvault == NULL)
2047 if ((host->cfg_snapvault->interval.interval +
2048 host->cfg_snapvault->interval.last_read) > now)
2051 status = cna_setup_snapvault(host->cfg_snapvault);
2054 assert(host->cfg_snapvault->query != NULL);
2056 data = na_server_invoke_elem(host->srv, host->cfg_snapvault->query);
2057 if (na_results_status(data) != NA_OK) {
2058 ERROR("netapp plugin: cna_query_snapvault: na_server_invoke_elem failed "
2060 host->name, na_results_reason(data));
2065 status = cna_handle_snapvault_iter(host, data);
2068 host->cfg_snapvault->interval.last_read = now;
2072 } /* }}} int cna_query_snapvault */
2074 /* Data corresponding to <System /> */
2075 static int cna_handle_system_data(const char *hostname, /* {{{ */
2076 cfg_system_t *cfg_system, na_elem_t *data,
2078 na_elem_t *instances;
2079 na_elem_iter_t counter_iter;
2081 derive_t disk_read = 0, disk_written = 0;
2082 derive_t net_recv = 0, net_sent = 0;
2083 derive_t cpu_busy = 0, cpu_total = 0;
2084 uint32_t counter_flags = 0;
2086 const char *instance;
2089 timestamp = cna_child_get_cdtime(data);
2091 instances = na_elem_child(na_elem_child(data, "instances"), "instance-data");
2092 if (instances == NULL) {
2093 ERROR("netapp plugin: cna_handle_system_data: "
2094 "na_elem_child (\"instances\") failed "
2100 instance = na_child_get_string(instances, "name");
2101 if (instance == NULL) {
2102 ERROR("netapp plugin: cna_handle_system_data: "
2103 "na_child_get_string (\"name\") failed "
2109 counter_iter = na_child_iterator(na_elem_child(instances, "counters"));
2110 for (na_elem_t *counter = na_iterator_next(&counter_iter); counter != NULL;
2111 counter = na_iterator_next(&counter_iter)) {
2115 name = na_child_get_string(counter, "name");
2119 value = na_child_get_uint64(counter, "value", UINT64_MAX);
2120 if (value == UINT64_MAX)
2123 if (!strcmp(name, "disk_data_read")) {
2124 disk_read = (derive_t)(value * 1024);
2125 counter_flags |= 0x01;
2126 } else if (!strcmp(name, "disk_data_written")) {
2127 disk_written = (derive_t)(value * 1024);
2128 counter_flags |= 0x02;
2129 } else if (!strcmp(name, "net_data_recv")) {
2130 net_recv = (derive_t)(value * 1024);
2131 counter_flags |= 0x04;
2132 } else if (!strcmp(name, "net_data_sent")) {
2133 net_sent = (derive_t)(value * 1024);
2134 counter_flags |= 0x08;
2135 } else if (!strcmp(name, "cpu_busy")) {
2136 cpu_busy = (derive_t)value;
2137 counter_flags |= 0x10;
2138 } else if (!strcmp(name, "cpu_elapsed_time")) {
2139 cpu_total = (derive_t)value;
2140 counter_flags |= 0x20;
2141 } else if ((cfg_system->flags & CFG_SYSTEM_OPS) && (value > 0) &&
2142 (strlen(name) > 4) &&
2143 (!strcmp(name + strlen(name) - 4, "_ops"))) {
2144 submit_derive(hostname, instance, "disk_ops_complex", name,
2145 (derive_t)value, timestamp, interval);
2147 } /* for (counter) */
2149 if ((cfg_system->flags & CFG_SYSTEM_DISK) &&
2150 (HAS_ALL_FLAGS(counter_flags, 0x01 | 0x02)))
2151 submit_two_derive(hostname, instance, "disk_octets", NULL, disk_read,
2152 disk_written, timestamp, interval);
2154 if ((cfg_system->flags & CFG_SYSTEM_NET) &&
2155 (HAS_ALL_FLAGS(counter_flags, 0x04 | 0x08)))
2156 submit_two_derive(hostname, instance, "if_octets", NULL, net_recv, net_sent,
2157 timestamp, interval);
2159 if ((cfg_system->flags & CFG_SYSTEM_CPU) &&
2160 (HAS_ALL_FLAGS(counter_flags, 0x10 | 0x20))) {
2161 submit_derive(hostname, instance, "cpu", "system", cpu_busy, timestamp,
2163 submit_derive(hostname, instance, "cpu", "idle", cpu_total - cpu_busy,
2164 timestamp, interval);
2168 } /* }}} int cna_handle_system_data */
2170 static int cna_setup_system(cfg_system_t *cs) /* {{{ */
2175 if (cs->query != NULL)
2178 cs->query = na_elem_new("perf-object-get-instances");
2179 if (cs->query == NULL) {
2180 ERROR("netapp plugin: na_elem_new failed.");
2183 na_child_add_string(cs->query, "objectname", "system");
2186 } /* }}} int cna_setup_system */
2188 static int cna_query_system(host_config_t *host) /* {{{ */
2197 /* If system statistics were not configured, return without doing anything. */
2198 if (host->cfg_system == NULL)
2202 if ((host->cfg_system->interval.interval +
2203 host->cfg_system->interval.last_read) > now)
2206 status = cna_setup_system(host->cfg_system);
2209 assert(host->cfg_system->query != NULL);
2211 data = na_server_invoke_elem(host->srv, host->cfg_system->query);
2212 if (na_results_status(data) != NA_OK) {
2213 ERROR("netapp plugin: cna_query_system: na_server_invoke_elem failed for "
2215 host->name, na_results_reason(data));
2220 status = cna_handle_system_data(host->name, host->cfg_system, data,
2221 host->cfg_system->interval.interval);
2224 host->cfg_system->interval.last_read = now;
2228 } /* }}} int cna_query_system */
2231 * Configuration handling
2234 /* Handling of the "GetIO", "GetOps" and "GetLatency" options within a
2235 * <VolumePerf /> block. */
2236 static void cna_config_volume_perf_option(cfg_volume_perf_t *cvp, /* {{{ */
2237 const oconfig_item_t *ci) {
2241 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2243 "netapp plugin: The %s option requires exactly one string argument.",
2248 name = ci->values[0].value.string;
2250 if (strcasecmp("GetIO", ci->key) == 0)
2251 il = cvp->il_octets;
2252 else if (strcasecmp("GetOps", ci->key) == 0)
2253 il = cvp->il_operations;
2254 else if (strcasecmp("GetLatency", ci->key) == 0)
2255 il = cvp->il_latency;
2259 ignorelist_add(il, name);
2260 } /* }}} void cna_config_volume_perf_option */
2262 /* Handling of the "IgnoreSelectedIO", "IgnoreSelectedOps" and
2263 * "IgnoreSelectedLatency" options within a <VolumePerf /> block. */
2264 static void cna_config_volume_perf_default(cfg_volume_perf_t *cvp, /* {{{ */
2265 const oconfig_item_t *ci) {
2268 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
2270 "netapp plugin: The %s option requires exactly one string argument.",
2275 if (strcasecmp("IgnoreSelectedIO", ci->key) == 0)
2276 il = cvp->il_octets;
2277 else if (strcasecmp("IgnoreSelectedOps", ci->key) == 0)
2278 il = cvp->il_operations;
2279 else if (strcasecmp("IgnoreSelectedLatency", ci->key) == 0)
2280 il = cvp->il_latency;
2284 if (ci->values[0].value.boolean)
2285 ignorelist_set_invert(il, /* invert = */ 0);
2287 ignorelist_set_invert(il, /* invert = */ 1);
2288 } /* }}} void cna_config_volume_perf_default */
2290 /* Corresponds to a <Disks /> block */
2295 * IgnoreSelectedIO false
2299 * IgnoreSelectedOps false
2303 * IgnoreSelectedLatency false
2306 /* Corresponds to a <VolumePerf /> block */
2307 static int cna_config_volume_performance(host_config_t *host, /* {{{ */
2308 const oconfig_item_t *ci) {
2309 cfg_volume_perf_t *cfg_volume_perf;
2311 if ((host == NULL) || (ci == NULL))
2314 if (host->cfg_volume_perf == NULL) {
2315 cfg_volume_perf = calloc(1, sizeof(*cfg_volume_perf));
2316 if (cfg_volume_perf == NULL)
2319 /* Set default flags */
2320 cfg_volume_perf->query = NULL;
2321 cfg_volume_perf->volumes = NULL;
2323 cfg_volume_perf->il_octets = ignorelist_create(/* invert = */ 1);
2324 if (cfg_volume_perf->il_octets == NULL) {
2325 sfree(cfg_volume_perf);
2329 cfg_volume_perf->il_operations = ignorelist_create(/* invert = */ 1);
2330 if (cfg_volume_perf->il_operations == NULL) {
2331 ignorelist_free(cfg_volume_perf->il_octets);
2332 sfree(cfg_volume_perf);
2336 cfg_volume_perf->il_latency = ignorelist_create(/* invert = */ 1);
2337 if (cfg_volume_perf->il_latency == NULL) {
2338 ignorelist_free(cfg_volume_perf->il_octets);
2339 ignorelist_free(cfg_volume_perf->il_operations);
2340 sfree(cfg_volume_perf);
2344 host->cfg_volume_perf = cfg_volume_perf;
2346 cfg_volume_perf = host->cfg_volume_perf;
2348 for (int i = 0; i < ci->children_num; ++i) {
2349 oconfig_item_t *item = ci->children + i;
2351 /* if (!item || !item->key || !*item->key) continue; */
2352 if (strcasecmp(item->key, "Interval") == 0)
2353 cf_util_get_cdtime(item, &cfg_volume_perf->interval.interval);
2354 else if (!strcasecmp(item->key, "GetIO"))
2355 cna_config_volume_perf_option(cfg_volume_perf, item);
2356 else if (!strcasecmp(item->key, "GetOps"))
2357 cna_config_volume_perf_option(cfg_volume_perf, item);
2358 else if (!strcasecmp(item->key, "GetLatency"))
2359 cna_config_volume_perf_option(cfg_volume_perf, item);
2360 else if (!strcasecmp(item->key, "IgnoreSelectedIO"))
2361 cna_config_volume_perf_default(cfg_volume_perf, item);
2362 else if (!strcasecmp(item->key, "IgnoreSelectedOps"))
2363 cna_config_volume_perf_default(cfg_volume_perf, item);
2364 else if (!strcasecmp(item->key, "IgnoreSelectedLatency"))
2365 cna_config_volume_perf_default(cfg_volume_perf, item);
2367 WARNING("netapp plugin: The option %s is not allowed within "
2368 "`VolumePerf' blocks.",
2373 } /* }}} int cna_config_volume_performance */
2375 /* Handling of the "GetCapacity" and "GetSnapshot" options within a
2376 * <VolumeUsage /> block. */
2377 static void cna_config_volume_usage_option(cfg_volume_usage_t *cvu, /* {{{ */
2378 const oconfig_item_t *ci) {
2382 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2384 "netapp plugin: The %s option requires exactly one string argument.",
2389 name = ci->values[0].value.string;
2391 if (strcasecmp("GetCapacity", ci->key) == 0)
2392 il = cvu->il_capacity;
2393 else if (strcasecmp("GetSnapshot", ci->key) == 0)
2394 il = cvu->il_snapshot;
2398 ignorelist_add(il, name);
2399 } /* }}} void cna_config_volume_usage_option */
2401 /* Handling of the "IgnoreSelectedCapacity" and "IgnoreSelectedSnapshot"
2402 * options within a <VolumeUsage /> block. */
2403 static void cna_config_volume_usage_default(cfg_volume_usage_t *cvu, /* {{{ */
2404 const oconfig_item_t *ci) {
2407 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
2409 "netapp plugin: The %s option requires exactly one string argument.",
2414 if (strcasecmp("IgnoreSelectedCapacity", ci->key) == 0)
2415 il = cvu->il_capacity;
2416 else if (strcasecmp("IgnoreSelectedSnapshot", ci->key) == 0)
2417 il = cvu->il_snapshot;
2421 if (ci->values[0].value.boolean)
2422 ignorelist_set_invert(il, /* invert = */ 0);
2424 ignorelist_set_invert(il, /* invert = */ 1);
2425 } /* }}} void cna_config_volume_usage_default */
2427 /* Corresponds to a <Quota /> block */
2428 static int cna_config_quota(host_config_t *host, oconfig_item_t *ci) /* {{{ */
2430 cfg_quota_t *cfg_quota;
2432 if ((host == NULL) || (ci == NULL))
2435 if (host->cfg_quota == NULL) {
2436 cfg_quota = calloc(1, sizeof(*cfg_quota));
2437 if (cfg_quota == NULL)
2439 cfg_quota->query = NULL;
2441 host->cfg_quota = cfg_quota;
2443 cfg_quota = host->cfg_quota;
2445 for (int i = 0; i < ci->children_num; ++i) {
2446 oconfig_item_t *item = ci->children + i;
2448 if (strcasecmp(item->key, "Interval") == 0)
2449 cf_util_get_cdtime(item, &cfg_quota->interval.interval);
2451 WARNING("netapp plugin: The option %s is not allowed within "
2457 } /* }}} int cna_config_quota */
2459 /* Corresponds to a <Disks /> block */
2460 static int cna_config_disk(host_config_t *host, oconfig_item_t *ci) { /* {{{ */
2461 cfg_disk_t *cfg_disk;
2463 if ((host == NULL) || (ci == NULL))
2466 if (host->cfg_disk == NULL) {
2467 cfg_disk = calloc(1, sizeof(*cfg_disk));
2468 if (cfg_disk == NULL)
2471 /* Set default flags */
2472 cfg_disk->flags = CFG_DISK_ALL;
2473 cfg_disk->query = NULL;
2474 cfg_disk->disks = NULL;
2476 host->cfg_disk = cfg_disk;
2478 cfg_disk = host->cfg_disk;
2480 for (int i = 0; i < ci->children_num; ++i) {
2481 oconfig_item_t *item = ci->children + i;
2483 /* if (!item || !item->key || !*item->key) continue; */
2484 if (strcasecmp(item->key, "Interval") == 0)
2485 cf_util_get_cdtime(item, &cfg_disk->interval.interval);
2486 else if (strcasecmp(item->key, "GetBusy") == 0)
2487 cf_util_get_flag(item, &cfg_disk->flags, CFG_DISK_BUSIEST);
2490 if ((cfg_disk->flags & CFG_DISK_ALL) == 0) {
2491 NOTICE("netapp plugin: All disk related values have been disabled. "
2492 "Collection of per-disk data will be disabled entirely.");
2493 free_cfg_disk(host->cfg_disk);
2494 host->cfg_disk = NULL;
2498 } /* }}} int cna_config_disk */
2500 /* Corresponds to a <WAFL /> block */
2501 static int cna_config_wafl(host_config_t *host, oconfig_item_t *ci) /* {{{ */
2503 cfg_wafl_t *cfg_wafl;
2505 if ((host == NULL) || (ci == NULL))
2508 if (host->cfg_wafl == NULL) {
2509 cfg_wafl = calloc(1, sizeof(*cfg_wafl));
2510 if (cfg_wafl == NULL)
2513 /* Set default flags */
2514 cfg_wafl->flags = CFG_WAFL_ALL;
2516 host->cfg_wafl = cfg_wafl;
2518 cfg_wafl = host->cfg_wafl;
2520 for (int i = 0; i < ci->children_num; ++i) {
2521 oconfig_item_t *item = ci->children + i;
2523 if (strcasecmp(item->key, "Interval") == 0)
2524 cf_util_get_cdtime(item, &cfg_wafl->interval.interval);
2525 else if (!strcasecmp(item->key, "GetNameCache"))
2526 cf_util_get_flag(item, &cfg_wafl->flags, CFG_WAFL_NAME_CACHE);
2527 else if (!strcasecmp(item->key, "GetDirCache"))
2528 cf_util_get_flag(item, &cfg_wafl->flags, CFG_WAFL_DIR_CACHE);
2529 else if (!strcasecmp(item->key, "GetBufferCache"))
2530 cf_util_get_flag(item, &cfg_wafl->flags, CFG_WAFL_BUF_CACHE);
2531 else if (!strcasecmp(item->key, "GetInodeCache"))
2532 cf_util_get_flag(item, &cfg_wafl->flags, CFG_WAFL_INODE_CACHE);
2534 WARNING("netapp plugin: The %s config option is not allowed within "
2539 if ((cfg_wafl->flags & CFG_WAFL_ALL) == 0) {
2540 NOTICE("netapp plugin: All WAFL related values have been disabled. "
2541 "Collection of WAFL data will be disabled entirely.");
2542 free_cfg_wafl(host->cfg_wafl);
2543 host->cfg_wafl = NULL;
2547 } /* }}} int cna_config_wafl */
2551 * GetCapacity "vol0"
2552 * GetCapacity "vol1"
2553 * GetCapacity "vol2"
2554 * GetCapacity "vol3"
2555 * GetCapacity "vol4"
2556 * IgnoreSelectedCapacity false
2558 * GetSnapshot "vol0"
2559 * GetSnapshot "vol3"
2560 * GetSnapshot "vol4"
2561 * GetSnapshot "vol7"
2562 * IgnoreSelectedSnapshot false
2565 /* Corresponds to a <VolumeUsage /> block */
2566 static int cna_config_volume_usage(host_config_t *host, /* {{{ */
2567 const oconfig_item_t *ci) {
2568 cfg_volume_usage_t *cfg_volume_usage;
2570 if ((host == NULL) || (ci == NULL))
2573 if (host->cfg_volume_usage == NULL) {
2574 cfg_volume_usage = calloc(1, sizeof(*cfg_volume_usage));
2575 if (cfg_volume_usage == NULL)
2578 /* Set default flags */
2579 cfg_volume_usage->query = NULL;
2580 cfg_volume_usage->volumes = NULL;
2582 cfg_volume_usage->il_capacity = ignorelist_create(/* invert = */ 1);
2583 if (cfg_volume_usage->il_capacity == NULL) {
2584 sfree(cfg_volume_usage);
2588 cfg_volume_usage->il_snapshot = ignorelist_create(/* invert = */ 1);
2589 if (cfg_volume_usage->il_snapshot == NULL) {
2590 ignorelist_free(cfg_volume_usage->il_capacity);
2591 sfree(cfg_volume_usage);
2595 host->cfg_volume_usage = cfg_volume_usage;
2597 cfg_volume_usage = host->cfg_volume_usage;
2599 for (int i = 0; i < ci->children_num; ++i) {
2600 oconfig_item_t *item = ci->children + i;
2602 /* if (!item || !item->key || !*item->key) continue; */
2603 if (strcasecmp(item->key, "Interval") == 0)
2604 cf_util_get_cdtime(item, &cfg_volume_usage->interval.interval);
2605 else if (!strcasecmp(item->key, "GetCapacity"))
2606 cna_config_volume_usage_option(cfg_volume_usage, item);
2607 else if (!strcasecmp(item->key, "GetSnapshot"))
2608 cna_config_volume_usage_option(cfg_volume_usage, item);
2609 else if (!strcasecmp(item->key, "IgnoreSelectedCapacity"))
2610 cna_config_volume_usage_default(cfg_volume_usage, item);
2611 else if (!strcasecmp(item->key, "IgnoreSelectedSnapshot"))
2612 cna_config_volume_usage_default(cfg_volume_usage, item);
2614 WARNING("netapp plugin: The option %s is not allowed within "
2615 "`VolumeUsage' blocks.",
2620 } /* }}} int cna_config_volume_usage */
2622 /* Corresponds to a <SnapVault /> block */
2623 static int cna_config_snapvault(host_config_t *host, /* {{{ */
2624 const oconfig_item_t *ci) {
2625 cfg_snapvault_t *cfg_snapvault;
2627 if ((host == NULL) || (ci == NULL))
2630 if (host->cfg_snapvault == NULL) {
2631 cfg_snapvault = calloc(1, sizeof(*cfg_snapvault));
2632 if (cfg_snapvault == NULL)
2634 cfg_snapvault->query = NULL;
2636 host->cfg_snapvault = cfg_snapvault;
2639 cfg_snapvault = host->cfg_snapvault;
2641 for (int i = 0; i < ci->children_num; ++i) {
2642 oconfig_item_t *item = ci->children + i;
2644 if (strcasecmp(item->key, "Interval") == 0)
2645 cf_util_get_cdtime(item, &cfg_snapvault->interval.interval);
2647 WARNING("netapp plugin: The option %s is not allowed within "
2648 "`SnapVault' blocks.",
2653 } /* }}} int cna_config_snapvault */
2655 /* Corresponds to a <System /> block */
2656 static int cna_config_system(host_config_t *host, /* {{{ */
2657 oconfig_item_t *ci) {
2658 cfg_system_t *cfg_system;
2660 if ((host == NULL) || (ci == NULL))
2663 if (host->cfg_system == NULL) {
2664 cfg_system = calloc(1, sizeof(*cfg_system));
2665 if (cfg_system == NULL)
2668 /* Set default flags */
2669 cfg_system->flags = CFG_SYSTEM_ALL;
2670 cfg_system->query = NULL;
2672 host->cfg_system = cfg_system;
2674 cfg_system = host->cfg_system;
2676 for (int i = 0; i < ci->children_num; ++i) {
2677 oconfig_item_t *item = ci->children + i;
2679 if (strcasecmp(item->key, "Interval") == 0) {
2680 cf_util_get_cdtime(item, &cfg_system->interval.interval);
2681 } else if (!strcasecmp(item->key, "GetCPULoad")) {
2682 cf_util_get_flag(item, &cfg_system->flags, CFG_SYSTEM_CPU);
2683 } else if (!strcasecmp(item->key, "GetInterfaces")) {
2684 cf_util_get_flag(item, &cfg_system->flags, CFG_SYSTEM_NET);
2685 } else if (!strcasecmp(item->key, "GetDiskOps")) {
2686 cf_util_get_flag(item, &cfg_system->flags, CFG_SYSTEM_OPS);
2687 } else if (!strcasecmp(item->key, "GetDiskIO")) {
2688 cf_util_get_flag(item, &cfg_system->flags, CFG_SYSTEM_DISK);
2690 WARNING("netapp plugin: The %s config option is not allowed within "
2696 if ((cfg_system->flags & CFG_SYSTEM_ALL) == 0) {
2697 NOTICE("netapp plugin: All system related values have been disabled. "
2698 "Collection of system data will be disabled entirely.");
2699 free_cfg_system(host->cfg_system);
2700 host->cfg_system = NULL;
2704 } /* }}} int cna_config_system */
2706 /* Corresponds to a <Host /> block. */
2707 static host_config_t *cna_alloc_host(void) /* {{{ */
2709 host_config_t *host;
2711 host = calloc(1, sizeof(*host));
2716 host->protocol = NA_SERVER_TRANSPORT_HTTPS;
2718 host->username = NULL;
2719 host->password = NULL;
2720 host->vfiler = NULL;
2722 host->cfg_wafl = NULL;
2723 host->cfg_disk = NULL;
2724 host->cfg_volume_perf = NULL;
2725 host->cfg_volume_usage = NULL;
2726 host->cfg_quota = NULL;
2727 host->cfg_snapvault = NULL;
2728 host->cfg_system = NULL;
2731 } /* }}} host_config_t *cna_alloc_host */
2733 static host_config_t *cna_shallow_clone_host(host_config_t *host) /* {{{ */
2735 host_config_t *clone;
2740 clone = cna_alloc_host();
2744 if (host->name != NULL) {
2745 clone->name = strdup(host->name);
2746 if (clone->name == NULL) {
2747 free_host_config(clone);
2752 clone->protocol = host->protocol;
2754 if (host->host != NULL) {
2755 clone->host = strdup(host->host);
2756 if (clone->host == NULL) {
2757 free_host_config(clone);
2762 clone->port = host->port;
2764 if (host->username != NULL) {
2765 clone->username = strdup(host->username);
2766 if (clone->username == NULL) {
2767 free_host_config(clone);
2771 if (host->password != NULL) {
2772 clone->password = strdup(host->password);
2773 if (clone->password == NULL) {
2774 free_host_config(clone);
2779 clone->interval = host->interval;
2782 } /* }}} host_config_t *cna_shallow_clone_host */
2784 static int cna_read(user_data_t *ud);
2786 static int cna_register_host(host_config_t *host) /* {{{ */
2791 ssnprintf(cb_name, sizeof(cb_name), "netapp-%s-%s", host->name,
2794 ssnprintf(cb_name, sizeof(cb_name), "netapp-%s", host->name);
2796 plugin_register_complex_read(
2797 /* group = */ NULL, cb_name,
2798 /* callback = */ cna_read,
2799 /* interval = */ host->interval,
2801 .data = host, .free_func = (void *)free_host_config,
2805 } /* }}} int cna_register_host */
2807 static int cna_config_host(host_config_t *host, /* {{{ */
2808 const oconfig_item_t *ci) {
2809 oconfig_item_t *item;
2810 bool is_vfiler = false;
2813 if (!strcasecmp(ci->key, "VFiler"))
2816 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2817 WARNING("netapp plugin: \"%s\" needs exactly one string argument. Ignoring "
2823 status = cf_util_get_string(ci, &host->name);
2827 for (int i = 0; i < ci->children_num; ++i) {
2828 item = ci->children + i;
2832 if (!strcasecmp(item->key, "Address")) {
2833 status = cf_util_get_string(item, &host->host);
2834 } else if (!strcasecmp(item->key, "Port")) {
2837 tmp = cf_util_get_port_number(item);
2840 } else if (!strcasecmp(item->key, "Protocol")) {
2841 if ((item->values_num != 1) ||
2842 (item->values[0].type != OCONFIG_TYPE_STRING) ||
2843 (strcasecmp(item->values[0].value.string, "http") &&
2844 strcasecmp(item->values[0].value.string, "https"))) {
2845 WARNING("netapp plugin: \"Protocol\" needs to be either \"http\" or "
2846 "\"https\". Ignoring host block \"%s\".",
2847 ci->values[0].value.string);
2850 if (!strcasecmp(item->values[0].value.string, "http"))
2851 host->protocol = NA_SERVER_TRANSPORT_HTTP;
2853 host->protocol = NA_SERVER_TRANSPORT_HTTPS;
2854 } else if (!strcasecmp(item->key, "User")) {
2855 status = cf_util_get_string(item, &host->username);
2856 } else if (!strcasecmp(item->key, "Password")) {
2857 status = cf_util_get_string(item, &host->password);
2858 } else if (!strcasecmp(item->key, "Interval")) {
2859 status = cf_util_get_cdtime(item, &host->interval);
2860 } else if (!strcasecmp(item->key, "WAFL")) {
2861 cna_config_wafl(host, item);
2862 } else if (!strcasecmp(item->key, "Disks")) {
2863 cna_config_disk(host, item);
2864 } else if (!strcasecmp(item->key, "VolumePerf")) {
2865 cna_config_volume_performance(host, item);
2866 } else if (!strcasecmp(item->key, "VolumeUsage")) {
2867 cna_config_volume_usage(host, item);
2868 } else if (!strcasecmp(item->key, "Quota")) {
2869 cna_config_quota(host, item);
2870 } else if (!strcasecmp(item->key, "SnapVault")) {
2871 cna_config_snapvault(host, item);
2872 } else if (!strcasecmp(item->key, "System")) {
2873 cna_config_system(host, item);
2874 } else if ((!strcasecmp(item->key, "VFiler")) && (!is_vfiler)) {
2875 host_config_t *vfiler;
2877 vfiler = cna_shallow_clone_host(host);
2879 ERROR("netapp plugin: Failed to allocate host object for vfiler.");
2883 if (cna_config_host(vfiler, item)) {
2884 free_host_config(vfiler);
2888 cna_register_host(vfiler);
2889 } else if ((!strcasecmp(item->key, "VFilerName")) && is_vfiler) {
2890 status = cf_util_get_string(item, &host->vfiler);
2892 WARNING("netapp plugin: Ignoring unknown config option \"%s\" in %s "
2894 item->key, is_vfiler ? "vfiler" : "host",
2895 ci->values[0].value.string);
2902 if (host->host == NULL)
2903 host->host = strdup(host->name);
2905 if (is_vfiler && (!host->vfiler))
2906 host->vfiler = strdup(host->name);
2908 if (host->host == NULL)
2911 if (host->port <= 0)
2912 host->port = (host->protocol == NA_SERVER_TRANSPORT_HTTP) ? 80 : 443;
2914 if ((host->username == NULL) || (host->password == NULL)) {
2915 WARNING("netapp plugin: Please supply login information for host \"%s\". "
2916 "Ignoring host block.",
2925 } /* }}} host_config_t *cna_config_host */
2928 * Callbacks registered with the daemon
2930 * Pretty standard stuff here.
2932 static int cna_init_host(host_config_t *host) /* {{{ */
2934 /* Request version 1.1 of the ONTAP API */
2935 int major_version = 1, minor_version = 1;
2940 if (host->srv != NULL)
2943 if (host->vfiler != NULL) /* Request version 1.7 of the ONTAP API */
2946 host->srv = na_server_open(host->host, major_version, minor_version);
2947 if (host->srv == NULL) {
2948 ERROR("netapp plugin: na_server_open (%s) failed.", host->host);
2952 na_server_set_transport_type(host->srv, host->protocol,
2953 /* transportarg = */ NULL);
2954 na_server_set_port(host->srv, host->port);
2955 na_server_style(host->srv, NA_STYLE_LOGIN_PASSWORD);
2956 na_server_adminuser(host->srv, host->username, host->password);
2957 na_server_set_timeout(host->srv, 5 /* seconds */);
2959 if (host->vfiler != NULL) {
2960 if (!na_server_set_vfiler(host->srv, host->vfiler)) {
2961 ERROR("netapp plugin: Failed to connect to VFiler '%s' on host '%s'.",
2962 host->vfiler, host->host);
2965 INFO("netapp plugin: Connected to VFiler '%s' on host '%s'.",
2966 host->vfiler, host->host);
2971 } /* }}} int cna_init_host */
2973 static int cna_init(void) /* {{{ */
2975 char err[256] = {0};
2977 if (!na_startup(err, sizeof(err))) {
2978 err[sizeof(err) - 1] = '\0';
2979 ERROR("netapp plugin: Error initializing netapp API: %s", err);
2984 } /* }}} cna_init */
2986 static int cna_read_internal(host_config_t *host) { /* {{{ */
2989 status = cna_query_wafl(host);
2993 status = cna_query_disk(host);
2997 status = cna_query_volume_perf(host);
3001 status = cna_query_volume_usage(host);
3005 status = cna_query_quota(host);
3009 status = cna_query_snapvault(host);
3013 status = cna_query_system(host);
3018 } /* }}} int cna_read_internal */
3020 static int cna_read(user_data_t *ud) { /* {{{ */
3021 host_config_t *host;
3024 if ((ud == NULL) || (ud->data == NULL))
3029 status = cna_init_host(host);
3033 status = cna_read_internal(host);
3035 if (host->srv != NULL)
3036 na_server_close(host->srv);
3041 } /* }}} int cna_read */
3043 static int cna_config(oconfig_item_t *ci) { /* {{{ */
3044 oconfig_item_t *item;
3046 for (int i = 0; i < ci->children_num; ++i) {
3047 item = ci->children + i;
3049 if (strcasecmp(item->key, "Host") == 0) {
3050 host_config_t *host;
3052 host = cna_alloc_host();
3054 ERROR("netapp plugin: Failed to allocate host object.");
3058 if (cna_config_host(host, item) != 0) {
3059 free_host_config(host);
3063 cna_register_host(host);
3064 } else /* if (item->key != "Host") */
3066 WARNING("netapp plugin: Ignoring unknown config option \"%s\".",
3071 } /* }}} int cna_config */
3073 static int cna_shutdown(void) /* {{{ */
3075 /* Clean up system resources and stuff. */
3079 } /* }}} int cna_shutdown */
3081 void module_register(void) {
3082 plugin_register_complex_config("netapp", cna_config);
3083 plugin_register_init("netapp", cna_init);
3084 plugin_register_shutdown("netapp", cna_shutdown);