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>
32 #include "utils_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 snprintf(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 snprintf(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 snprintf(n.message, sizeof(n.message), "Volume %s is now online.", v->name);
1502 v->flags &= ~IS_VOLUME_USAGE_OFFLINE;
1504 n.severity = NOTIF_WARNING;
1505 snprintf(n.message, sizeof(n.message), "Volume %s is now offline.",
1507 v->flags |= IS_VOLUME_USAGE_OFFLINE;
1510 return plugin_dispatch_notification(&n);
1511 } /* }}} int cna_change_volume_status */
1513 static void cna_handle_volume_snap_usage(const host_config_t *host, /* {{{ */
1514 data_volume_usage_t *v) {
1515 uint64_t snap_used = 0, value;
1516 na_elem_t *data, *elem_snapshots;
1517 na_elem_iter_t iter_snap;
1519 data = na_server_invoke_elem(host->srv, v->snap_query);
1520 if (na_results_status(data) != NA_OK) {
1521 if (na_results_errno(data) == EVOLUMEOFFLINE) {
1522 if ((v->flags & IS_VOLUME_USAGE_OFFLINE) == 0)
1523 cna_change_volume_status(host->name, v);
1525 ERROR("netapp plugin: cna_handle_volume_snap_usage: "
1526 "na_server_invoke_elem for "
1527 "volume \"%s\" on host %s failed with error %d: %s",
1528 v->name, host->name, na_results_errno(data),
1529 na_results_reason(data));
1535 if ((v->flags & IS_VOLUME_USAGE_OFFLINE) != 0)
1536 cna_change_volume_status(host->name, v);
1538 elem_snapshots = na_elem_child(data, "snapshots");
1539 if (elem_snapshots == NULL) {
1540 ERROR("netapp plugin: cna_handle_volume_snap_usage: "
1541 "na_elem_child (\"snapshots\") failed "
1548 iter_snap = na_child_iterator(elem_snapshots);
1549 for (na_elem_t *elem_snap = na_iterator_next(&iter_snap); elem_snap != NULL;
1550 elem_snap = na_iterator_next(&iter_snap)) {
1551 value = na_child_get_uint64(elem_snap, "cumulative-total", 0);
1552 /* "cumulative-total" is the total size of the oldest snapshot plus all
1553 * newer ones in blocks (1KB). We therefore are looking for the highest
1554 * number of all snapshots - that's the size required for the snapshots. */
1555 if (value > snap_used)
1559 /* snap_used is in 1024 byte blocks */
1560 v->snap_used = snap_used * 1024;
1561 v->flags |= HAVE_VOLUME_USAGE_SNAP_USED;
1562 } /* }}} void cna_handle_volume_snap_usage */
1564 static void cna_handle_volume_sis_data(const host_config_t *host, /* {{{ */
1565 data_volume_usage_t *v, na_elem_t *sis) {
1566 const char *sis_state;
1567 uint64_t sis_saved_reported;
1569 if (na_elem_child(sis, "sis-info"))
1570 sis = na_elem_child(sis, "sis-info");
1572 sis_state = na_child_get_string(sis, "state");
1573 if (sis_state == NULL)
1576 /* If SIS is not enabled, there's nothing left to do for this volume. */
1577 if (strcmp("enabled", sis_state) != 0)
1580 sis_saved_reported = na_child_get_uint64(sis, "size-saved", UINT64_MAX);
1581 if (sis_saved_reported == UINT64_MAX)
1584 /* size-saved is actually a 32 bit number, so ... time for some guesswork. */
1585 if ((sis_saved_reported >> 32) != 0) {
1586 /* In case they ever fix this bug. */
1587 v->sis_saved = sis_saved_reported;
1588 v->flags |= HAVE_VOLUME_USAGE_SIS_SAVED;
1589 } else { /* really hacky work-around code. {{{ */
1590 uint64_t sis_saved_percent;
1591 uint64_t sis_saved_guess;
1592 uint64_t overflow_guess;
1593 uint64_t guess1, guess2, guess3;
1595 /* Check if we have v->norm_used. Without it, we cannot calculate
1596 * sis_saved_guess. */
1597 if ((v->flags & HAVE_VOLUME_USAGE_NORM_USED) == 0)
1601 na_child_get_uint64(sis, "percentage-saved", UINT64_MAX);
1602 if (sis_saved_percent > 100)
1605 /* The "size-saved" value is a 32bit unsigned integer. This is a bug and
1606 * will hopefully be fixed in later versions. To work around the bug, try
1607 * to figure out how often the 32bit integer wrapped around by using the
1608 * "percentage-saved" value. Because the percentage is in the range
1609 * [0-100], this should work as long as the saved space does not exceed
1611 /* percentage-saved = size-saved / (size-saved + size-used) */
1612 if (sis_saved_percent < 100)
1614 v->norm_used * sis_saved_percent / (100 - sis_saved_percent);
1616 sis_saved_guess = v->norm_used;
1618 overflow_guess = sis_saved_guess >> 32;
1619 guess1 = overflow_guess ? ((overflow_guess - 1) << 32) + sis_saved_reported
1620 : sis_saved_reported;
1621 guess2 = (overflow_guess << 32) + sis_saved_reported;
1622 guess3 = ((overflow_guess + 1) << 32) + sis_saved_reported;
1624 if (sis_saved_guess < guess2) {
1625 if ((sis_saved_guess - guess1) < (guess2 - sis_saved_guess))
1626 v->sis_saved = guess1;
1628 v->sis_saved = guess2;
1630 if ((sis_saved_guess - guess2) < (guess3 - sis_saved_guess))
1631 v->sis_saved = guess2;
1633 v->sis_saved = guess3;
1635 v->flags |= HAVE_VOLUME_USAGE_SIS_SAVED;
1636 } /* }}} end of 32-bit workaround */
1637 } /* }}} void cna_handle_volume_sis_data */
1639 /* ONTAP >= 8.1 uses SIS for managing dedup and compression */
1640 static void cna_handle_volume_sis_saved(const host_config_t *host, /* {{{ */
1641 data_volume_usage_t *v,
1645 if (na_elem_child(sis, "sis-info"))
1646 sis = na_elem_child(sis, "sis-info");
1648 saved = na_child_get_uint64(sis, "compress-saved", UINT64_MAX);
1649 if (saved != UINT64_MAX) {
1650 v->compress_saved = saved;
1651 v->flags |= HAVE_VOLUME_USAGE_COMPRESS_SAVED;
1654 saved = na_child_get_uint64(sis, "dedup-saved", UINT64_MAX);
1655 if (saved != UINT64_MAX) {
1656 v->dedup_saved = saved;
1657 v->flags |= HAVE_VOLUME_USAGE_DEDUP_SAVED;
1659 } /* }}} void cna_handle_volume_sis_saved */
1661 static int cna_handle_volume_usage_data(const host_config_t *host, /* {{{ */
1662 cfg_volume_usage_t *cfg_volume,
1664 na_elem_t *elem_volumes;
1665 na_elem_iter_t iter_volume;
1667 elem_volumes = na_elem_child(data, "volumes");
1668 if (elem_volumes == NULL) {
1669 ERROR("netapp plugin: cna_handle_volume_usage_data: "
1670 "na_elem_child (\"volumes\") failed "
1676 iter_volume = na_child_iterator(elem_volumes);
1677 for (na_elem_t *elem_volume = na_iterator_next(&iter_volume);
1678 elem_volume != NULL; elem_volume = na_iterator_next(&iter_volume)) {
1679 const char *volume_name, *state;
1681 data_volume_usage_t *v;
1686 volume_name = na_child_get_string(elem_volume, "name");
1687 if (volume_name == NULL)
1690 state = na_child_get_string(elem_volume, "state");
1691 if ((state == NULL) || (strcmp(state, "online") != 0))
1694 /* get_volume_usage may return NULL if the volume is to be ignored. */
1695 v = get_volume_usage(cfg_volume, volume_name);
1699 if ((v->flags & CFG_VOLUME_USAGE_SNAP) != 0)
1700 cna_handle_volume_snap_usage(host, v);
1702 if ((v->flags & CFG_VOLUME_USAGE_DF) == 0)
1705 /* 2^4 exa-bytes? This will take a while ;) */
1706 value = na_child_get_uint64(elem_volume, "size-available", UINT64_MAX);
1707 if (value != UINT64_MAX) {
1708 v->norm_free = value;
1709 v->flags |= HAVE_VOLUME_USAGE_NORM_FREE;
1712 value = na_child_get_uint64(elem_volume, "size-used", UINT64_MAX);
1713 if (value != UINT64_MAX) {
1714 v->norm_used = value;
1715 v->flags |= HAVE_VOLUME_USAGE_NORM_USED;
1718 value = na_child_get_uint64(elem_volume, "snapshot-blocks-reserved",
1720 if (value != UINT64_MAX) {
1721 /* 1 block == 1024 bytes as per API docs */
1722 v->snap_reserved = 1024 * value;
1723 v->flags |= HAVE_VOLUME_USAGE_SNAP_RSVD;
1726 sis = na_elem_child(elem_volume, "sis");
1728 cna_handle_volume_sis_data(host, v, sis);
1729 cna_handle_volume_sis_saved(host, v, sis);
1731 } /* for (elem_volume) */
1733 return cna_submit_volume_usage_data(
1734 host->name, cfg_volume, host->cfg_volume_usage->interval.interval);
1735 } /* }}} int cna_handle_volume_usage_data */
1737 static int cna_setup_volume_usage(cfg_volume_usage_t *cvu) /* {{{ */
1742 if (cvu->query != NULL)
1745 cvu->query = na_elem_new("volume-list-info");
1746 if (cvu->query == NULL) {
1747 ERROR("netapp plugin: na_elem_new failed.");
1752 } /* }}} int cna_setup_volume_usage */
1754 static int cna_query_volume_usage(host_config_t *host) /* {{{ */
1763 /* If the user did not configure volume_usage statistics, return without
1764 * doing anything. */
1765 if (host->cfg_volume_usage == NULL)
1769 if ((host->cfg_volume_usage->interval.interval +
1770 host->cfg_volume_usage->interval.last_read) > now)
1773 status = cna_setup_volume_usage(host->cfg_volume_usage);
1776 assert(host->cfg_volume_usage->query != NULL);
1778 data = na_server_invoke_elem(host->srv, host->cfg_volume_usage->query);
1779 if (na_results_status(data) != NA_OK) {
1780 ERROR("netapp plugin: cna_query_volume_usage: na_server_invoke_elem failed "
1782 host->name, na_results_reason(data));
1787 status = cna_handle_volume_usage_data(host, host->cfg_volume_usage, data);
1790 host->cfg_volume_usage->interval.last_read = now;
1794 } /* }}} int cna_query_volume_usage */
1796 /* Data corresponding to <Quota /> */
1797 static int cna_handle_quota_data(const host_config_t *host, /* {{{ */
1798 cfg_quota_t *cfg_quota, na_elem_t *data) {
1799 na_elem_t *elem_quotas;
1800 na_elem_iter_t iter_quota;
1802 elem_quotas = na_elem_child(data, "quotas");
1803 if (elem_quotas == NULL) {
1804 ERROR("netapp plugin: cna_handle_quota_data: "
1805 "na_elem_child (\"quotas\") failed "
1811 iter_quota = na_child_iterator(elem_quotas);
1812 for (na_elem_t *elem_quota = na_iterator_next(&iter_quota);
1813 elem_quota != NULL; elem_quota = na_iterator_next(&iter_quota)) {
1814 const char *quota_type, *volume_name, *tree_name;
1817 char plugin_instance[DATA_MAX_NAME_LEN];
1819 quota_type = na_child_get_string(elem_quota, "quota-type");
1820 if (quota_type == NULL)
1823 /* possible TODO: support other types as well */
1824 if (strcmp(quota_type, "tree") != 0)
1827 tree_name = na_child_get_string(elem_quota, "tree");
1828 if ((tree_name == NULL) || (*tree_name == '\0'))
1831 volume_name = na_child_get_string(elem_quota, "volume");
1832 if (volume_name == NULL)
1835 snprintf(plugin_instance, sizeof(plugin_instance), "quota-%s-%s",
1836 volume_name, tree_name);
1838 value = na_child_get_uint64(elem_quota, "disk-used", UINT64_MAX);
1839 if (value != UINT64_MAX) {
1840 value *= 1024; /* disk-used reports kilobytes */
1841 submit_double(host->name, plugin_instance,
1842 /* type = */ "df_complex", /* type instance = */ NULL,
1843 (double)value, /* timestamp = */ 0,
1844 host->cfg_quota->interval.interval);
1847 value = na_child_get_uint64(elem_quota, "files-used", UINT64_MAX);
1848 if (value != UINT64_MAX) {
1849 submit_double(host->name, plugin_instance,
1850 /* type = */ "files", /* type instance = */ NULL,
1851 (double)value, /* timestamp = */ 0,
1852 host->cfg_quota->interval.interval);
1854 } /* for (elem_quota) */
1857 } /* }}} int cna_handle_volume_usage_data */
1859 static int cna_setup_quota(cfg_quota_t *cq) /* {{{ */
1864 if (cq->query != NULL)
1867 cq->query = na_elem_new("quota-report");
1868 if (cq->query == NULL) {
1869 ERROR("netapp plugin: na_elem_new failed.");
1874 } /* }}} int cna_setup_quota */
1876 static int cna_query_quota(host_config_t *host) /* {{{ */
1885 /* If the user did not configure quota statistics, return without
1886 * doing anything. */
1887 if (host->cfg_quota == NULL)
1891 if ((host->cfg_quota->interval.interval +
1892 host->cfg_quota->interval.last_read) > now)
1895 status = cna_setup_quota(host->cfg_quota);
1898 assert(host->cfg_quota->query != NULL);
1900 data = na_server_invoke_elem(host->srv, host->cfg_quota->query);
1901 if (na_results_status(data) != NA_OK) {
1902 ERROR("netapp plugin: cna_query_quota: na_server_invoke_elem failed for "
1904 host->name, na_results_reason(data));
1909 status = cna_handle_quota_data(host, host->cfg_quota, data);
1912 host->cfg_quota->interval.last_read = now;
1916 } /* }}} int cna_query_quota */
1918 /* Data corresponding to <SnapVault /> */
1919 static int cna_handle_snapvault_data(const char *hostname, /* {{{ */
1920 cfg_snapvault_t *cfg_snapvault,
1921 na_elem_t *data, cdtime_t interval) {
1922 na_elem_t *status_list = na_elem_child(data, "status-list");
1923 if (status_list == NULL) {
1924 ERROR("netapp plugin: SnapVault status record missing status-list");
1928 na_elem_iter_t status_iter = na_child_iterator(status_list);
1929 for (na_elem_t *status = na_iterator_next(&status_iter); status != NULL;
1930 status = na_iterator_next(&status_iter)) {
1931 const char *dest_sys, *dest_path, *src_sys, *src_path;
1932 char plugin_instance[DATA_MAX_NAME_LEN];
1935 dest_sys = na_child_get_string(status, "destination-system");
1936 dest_path = na_child_get_string(status, "destination-path");
1937 src_sys = na_child_get_string(status, "source-system");
1938 src_path = na_child_get_string(status, "source-path");
1940 if ((!dest_sys) || (!dest_path) || (!src_sys) || (!src_path))
1943 value = na_child_get_uint64(status, "lag-time", UINT64_MAX);
1944 if (value == UINT64_MAX) /* no successful baseline transfer yet */
1947 /* possible TODO: make plugin instance configurable */
1948 snprintf(plugin_instance, sizeof(plugin_instance), "snapvault-%s",
1950 submit_double(hostname, plugin_instance, /* type = */ "delay", NULL,
1951 (double)value, /* timestamp = */ 0, interval);
1953 value = na_child_get_uint64(status, "last-transfer-duration", UINT64_MAX);
1954 if (value != UINT64_MAX)
1955 submit_double(hostname, plugin_instance, /* type = */ "duration",
1956 "last_transfer", (double)value, /* timestamp = */ 0,
1959 value = na_child_get_uint64(status, "transfer-progress", UINT64_MAX);
1960 if (value == UINT64_MAX)
1961 value = na_child_get_uint64(status, "last-transfer-size", UINT64_MAX);
1962 if (value != UINT64_MAX) {
1963 value *= 1024; /* this is kilobytes */
1964 submit_derive(hostname, plugin_instance, /* type = */ "if_rx_octets",
1965 "transferred", value, /* timestamp = */ 0, interval);
1967 } /* for (status) */
1970 } /* }}} int cna_handle_snapvault_data */
1972 static int cna_handle_snapvault_iter(host_config_t *host, /* {{{ */
1976 uint32_t records_count;
1978 records_count = na_child_get_uint32(data, "records", UINT32_MAX);
1979 if (records_count == UINT32_MAX)
1982 tag = na_child_get_string(data, "tag");
1986 DEBUG("netapp plugin: Iterating %u SV records (tag = %s)", records_count,
1989 for (uint32_t i = 0; i < records_count; ++i) {
1992 elem = na_server_invoke(
1993 host->srv, "snapvault-secondary-relationship-status-list-iter-next",
1994 "maximum", "1", "tag", tag, NULL);
1996 if (na_results_status(elem) != NA_OK) {
1997 ERROR("netapp plugin: cna_handle_snapvault_iter: "
1998 "na_server_invoke failed for host %s: %s",
1999 host->name, na_results_reason(data));
2004 cna_handle_snapvault_data(host->name, host->cfg_snapvault, elem,
2005 host->cfg_snapvault->interval.interval);
2009 na_elem_free(na_server_invoke(
2010 host->srv, "snapvault-secondary-relationship-status-list-iter-end", "tag",
2013 } /* }}} int cna_handle_snapvault_iter */
2015 static int cna_setup_snapvault(cfg_snapvault_t *sv) /* {{{ */
2020 if (sv->query != NULL)
2024 na_elem_new("snapvault-secondary-relationship-status-list-iter-start");
2025 if (sv->query == NULL) {
2026 ERROR("netapp plugin: na_elem_new failed.");
2031 } /* }}} int cna_setup_snapvault */
2033 static int cna_query_snapvault(host_config_t *host) /* {{{ */
2042 if (host->cfg_snapvault == NULL)
2046 if ((host->cfg_snapvault->interval.interval +
2047 host->cfg_snapvault->interval.last_read) > now)
2050 status = cna_setup_snapvault(host->cfg_snapvault);
2053 assert(host->cfg_snapvault->query != NULL);
2055 data = na_server_invoke_elem(host->srv, host->cfg_snapvault->query);
2056 if (na_results_status(data) != NA_OK) {
2057 ERROR("netapp plugin: cna_query_snapvault: na_server_invoke_elem failed "
2059 host->name, na_results_reason(data));
2064 status = cna_handle_snapvault_iter(host, data);
2067 host->cfg_snapvault->interval.last_read = now;
2071 } /* }}} int cna_query_snapvault */
2073 /* Data corresponding to <System /> */
2074 static int cna_handle_system_data(const char *hostname, /* {{{ */
2075 cfg_system_t *cfg_system, na_elem_t *data,
2077 na_elem_t *instances;
2078 na_elem_iter_t counter_iter;
2080 derive_t disk_read = 0, disk_written = 0;
2081 derive_t net_recv = 0, net_sent = 0;
2082 derive_t cpu_busy = 0, cpu_total = 0;
2083 uint32_t counter_flags = 0;
2085 const char *instance;
2088 timestamp = cna_child_get_cdtime(data);
2090 instances = na_elem_child(na_elem_child(data, "instances"), "instance-data");
2091 if (instances == NULL) {
2092 ERROR("netapp plugin: cna_handle_system_data: "
2093 "na_elem_child (\"instances\") failed "
2099 instance = na_child_get_string(instances, "name");
2100 if (instance == NULL) {
2101 ERROR("netapp plugin: cna_handle_system_data: "
2102 "na_child_get_string (\"name\") failed "
2108 counter_iter = na_child_iterator(na_elem_child(instances, "counters"));
2109 for (na_elem_t *counter = na_iterator_next(&counter_iter); counter != NULL;
2110 counter = na_iterator_next(&counter_iter)) {
2114 name = na_child_get_string(counter, "name");
2118 value = na_child_get_uint64(counter, "value", UINT64_MAX);
2119 if (value == UINT64_MAX)
2122 if (!strcmp(name, "disk_data_read")) {
2123 disk_read = (derive_t)(value * 1024);
2124 counter_flags |= 0x01;
2125 } else if (!strcmp(name, "disk_data_written")) {
2126 disk_written = (derive_t)(value * 1024);
2127 counter_flags |= 0x02;
2128 } else if (!strcmp(name, "net_data_recv")) {
2129 net_recv = (derive_t)(value * 1024);
2130 counter_flags |= 0x04;
2131 } else if (!strcmp(name, "net_data_sent")) {
2132 net_sent = (derive_t)(value * 1024);
2133 counter_flags |= 0x08;
2134 } else if (!strcmp(name, "cpu_busy")) {
2135 cpu_busy = (derive_t)value;
2136 counter_flags |= 0x10;
2137 } else if (!strcmp(name, "cpu_elapsed_time")) {
2138 cpu_total = (derive_t)value;
2139 counter_flags |= 0x20;
2140 } else if ((cfg_system->flags & CFG_SYSTEM_OPS) && (value > 0) &&
2141 (strlen(name) > 4) &&
2142 (!strcmp(name + strlen(name) - 4, "_ops"))) {
2143 submit_derive(hostname, instance, "disk_ops_complex", name,
2144 (derive_t)value, timestamp, interval);
2146 } /* for (counter) */
2148 if ((cfg_system->flags & CFG_SYSTEM_DISK) &&
2149 (HAS_ALL_FLAGS(counter_flags, 0x01 | 0x02)))
2150 submit_two_derive(hostname, instance, "disk_octets", NULL, disk_read,
2151 disk_written, timestamp, interval);
2153 if ((cfg_system->flags & CFG_SYSTEM_NET) &&
2154 (HAS_ALL_FLAGS(counter_flags, 0x04 | 0x08)))
2155 submit_two_derive(hostname, instance, "if_octets", NULL, net_recv, net_sent,
2156 timestamp, interval);
2158 if ((cfg_system->flags & CFG_SYSTEM_CPU) &&
2159 (HAS_ALL_FLAGS(counter_flags, 0x10 | 0x20))) {
2160 submit_derive(hostname, instance, "cpu", "system", cpu_busy, timestamp,
2162 submit_derive(hostname, instance, "cpu", "idle", cpu_total - cpu_busy,
2163 timestamp, interval);
2167 } /* }}} int cna_handle_system_data */
2169 static int cna_setup_system(cfg_system_t *cs) /* {{{ */
2174 if (cs->query != NULL)
2177 cs->query = na_elem_new("perf-object-get-instances");
2178 if (cs->query == NULL) {
2179 ERROR("netapp plugin: na_elem_new failed.");
2182 na_child_add_string(cs->query, "objectname", "system");
2185 } /* }}} int cna_setup_system */
2187 static int cna_query_system(host_config_t *host) /* {{{ */
2196 /* If system statistics were not configured, return without doing anything. */
2197 if (host->cfg_system == NULL)
2201 if ((host->cfg_system->interval.interval +
2202 host->cfg_system->interval.last_read) > now)
2205 status = cna_setup_system(host->cfg_system);
2208 assert(host->cfg_system->query != NULL);
2210 data = na_server_invoke_elem(host->srv, host->cfg_system->query);
2211 if (na_results_status(data) != NA_OK) {
2212 ERROR("netapp plugin: cna_query_system: na_server_invoke_elem failed for "
2214 host->name, na_results_reason(data));
2219 status = cna_handle_system_data(host->name, host->cfg_system, data,
2220 host->cfg_system->interval.interval);
2223 host->cfg_system->interval.last_read = now;
2227 } /* }}} int cna_query_system */
2230 * Configuration handling
2232 /* Sets a given flag if the boolean argument is true and unsets the flag if it
2233 * is false. On error, the flag-field is not changed. */
2234 static int cna_config_bool_to_flag(const oconfig_item_t *ci, /* {{{ */
2235 uint32_t *flags, uint32_t flag) {
2236 if ((ci == NULL) || (flags == NULL))
2239 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
2240 WARNING("netapp plugin: The %s option needs exactly one boolean argument.",
2245 if (ci->values[0].value.boolean)
2251 } /* }}} int cna_config_bool_to_flag */
2253 /* Handling of the "Interval" option which is allowed in every block. */
2254 static int cna_config_get_interval(const oconfig_item_t *ci, /* {{{ */
2255 cna_interval_t *out_interval) {
2259 status = cf_util_get_cdtime(ci, &tmp);
2263 out_interval->interval = tmp;
2264 out_interval->last_read = 0;
2267 } /* }}} int cna_config_get_interval */
2269 /* Handling of the "GetIO", "GetOps" and "GetLatency" options within a
2270 * <VolumePerf /> block. */
2271 static void cna_config_volume_perf_option(cfg_volume_perf_t *cvp, /* {{{ */
2272 const oconfig_item_t *ci) {
2276 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2278 "netapp plugin: The %s option requires exactly one string argument.",
2283 name = ci->values[0].value.string;
2285 if (strcasecmp("GetIO", ci->key) == 0)
2286 il = cvp->il_octets;
2287 else if (strcasecmp("GetOps", ci->key) == 0)
2288 il = cvp->il_operations;
2289 else if (strcasecmp("GetLatency", ci->key) == 0)
2290 il = cvp->il_latency;
2294 ignorelist_add(il, name);
2295 } /* }}} void cna_config_volume_perf_option */
2297 /* Handling of the "IgnoreSelectedIO", "IgnoreSelectedOps" and
2298 * "IgnoreSelectedLatency" options within a <VolumePerf /> block. */
2299 static void cna_config_volume_perf_default(cfg_volume_perf_t *cvp, /* {{{ */
2300 const oconfig_item_t *ci) {
2303 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
2305 "netapp plugin: The %s option requires exactly one string argument.",
2310 if (strcasecmp("IgnoreSelectedIO", ci->key) == 0)
2311 il = cvp->il_octets;
2312 else if (strcasecmp("IgnoreSelectedOps", ci->key) == 0)
2313 il = cvp->il_operations;
2314 else if (strcasecmp("IgnoreSelectedLatency", ci->key) == 0)
2315 il = cvp->il_latency;
2319 if (ci->values[0].value.boolean)
2320 ignorelist_set_invert(il, /* invert = */ 0);
2322 ignorelist_set_invert(il, /* invert = */ 1);
2323 } /* }}} void cna_config_volume_perf_default */
2325 /* Corresponds to a <Disks /> block */
2330 * IgnoreSelectedIO false
2334 * IgnoreSelectedOps false
2338 * IgnoreSelectedLatency false
2341 /* Corresponds to a <VolumePerf /> block */
2342 static int cna_config_volume_performance(host_config_t *host, /* {{{ */
2343 const oconfig_item_t *ci) {
2344 cfg_volume_perf_t *cfg_volume_perf;
2346 if ((host == NULL) || (ci == NULL))
2349 if (host->cfg_volume_perf == NULL) {
2350 cfg_volume_perf = calloc(1, sizeof(*cfg_volume_perf));
2351 if (cfg_volume_perf == NULL)
2354 /* Set default flags */
2355 cfg_volume_perf->query = NULL;
2356 cfg_volume_perf->volumes = NULL;
2358 cfg_volume_perf->il_octets = ignorelist_create(/* invert = */ 1);
2359 if (cfg_volume_perf->il_octets == NULL) {
2360 sfree(cfg_volume_perf);
2364 cfg_volume_perf->il_operations = ignorelist_create(/* invert = */ 1);
2365 if (cfg_volume_perf->il_operations == NULL) {
2366 ignorelist_free(cfg_volume_perf->il_octets);
2367 sfree(cfg_volume_perf);
2371 cfg_volume_perf->il_latency = ignorelist_create(/* invert = */ 1);
2372 if (cfg_volume_perf->il_latency == NULL) {
2373 ignorelist_free(cfg_volume_perf->il_octets);
2374 ignorelist_free(cfg_volume_perf->il_operations);
2375 sfree(cfg_volume_perf);
2379 host->cfg_volume_perf = cfg_volume_perf;
2381 cfg_volume_perf = host->cfg_volume_perf;
2383 for (int i = 0; i < ci->children_num; ++i) {
2384 oconfig_item_t *item = ci->children + i;
2386 /* if (!item || !item->key || !*item->key) continue; */
2387 if (strcasecmp(item->key, "Interval") == 0)
2388 cna_config_get_interval(item, &cfg_volume_perf->interval);
2389 else if (!strcasecmp(item->key, "GetIO"))
2390 cna_config_volume_perf_option(cfg_volume_perf, item);
2391 else if (!strcasecmp(item->key, "GetOps"))
2392 cna_config_volume_perf_option(cfg_volume_perf, item);
2393 else if (!strcasecmp(item->key, "GetLatency"))
2394 cna_config_volume_perf_option(cfg_volume_perf, item);
2395 else if (!strcasecmp(item->key, "IgnoreSelectedIO"))
2396 cna_config_volume_perf_default(cfg_volume_perf, item);
2397 else if (!strcasecmp(item->key, "IgnoreSelectedOps"))
2398 cna_config_volume_perf_default(cfg_volume_perf, item);
2399 else if (!strcasecmp(item->key, "IgnoreSelectedLatency"))
2400 cna_config_volume_perf_default(cfg_volume_perf, item);
2402 WARNING("netapp plugin: The option %s is not allowed within "
2403 "`VolumePerf' blocks.",
2408 } /* }}} int cna_config_volume_performance */
2410 /* Handling of the "GetCapacity" and "GetSnapshot" options within a
2411 * <VolumeUsage /> block. */
2412 static void cna_config_volume_usage_option(cfg_volume_usage_t *cvu, /* {{{ */
2413 const oconfig_item_t *ci) {
2417 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2419 "netapp plugin: The %s option requires exactly one string argument.",
2424 name = ci->values[0].value.string;
2426 if (strcasecmp("GetCapacity", ci->key) == 0)
2427 il = cvu->il_capacity;
2428 else if (strcasecmp("GetSnapshot", ci->key) == 0)
2429 il = cvu->il_snapshot;
2433 ignorelist_add(il, name);
2434 } /* }}} void cna_config_volume_usage_option */
2436 /* Handling of the "IgnoreSelectedCapacity" and "IgnoreSelectedSnapshot"
2437 * options within a <VolumeUsage /> block. */
2438 static void cna_config_volume_usage_default(cfg_volume_usage_t *cvu, /* {{{ */
2439 const oconfig_item_t *ci) {
2442 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
2444 "netapp plugin: The %s option requires exactly one string argument.",
2449 if (strcasecmp("IgnoreSelectedCapacity", ci->key) == 0)
2450 il = cvu->il_capacity;
2451 else if (strcasecmp("IgnoreSelectedSnapshot", ci->key) == 0)
2452 il = cvu->il_snapshot;
2456 if (ci->values[0].value.boolean)
2457 ignorelist_set_invert(il, /* invert = */ 0);
2459 ignorelist_set_invert(il, /* invert = */ 1);
2460 } /* }}} void cna_config_volume_usage_default */
2462 /* Corresponds to a <Quota /> block */
2463 static int cna_config_quota(host_config_t *host, oconfig_item_t *ci) /* {{{ */
2465 cfg_quota_t *cfg_quota;
2467 if ((host == NULL) || (ci == NULL))
2470 if (host->cfg_quota == NULL) {
2471 cfg_quota = calloc(1, sizeof(*cfg_quota));
2472 if (cfg_quota == NULL)
2474 cfg_quota->query = NULL;
2476 host->cfg_quota = cfg_quota;
2478 cfg_quota = host->cfg_quota;
2480 for (int i = 0; i < ci->children_num; ++i) {
2481 oconfig_item_t *item = ci->children + i;
2483 if (strcasecmp(item->key, "Interval") == 0)
2484 cna_config_get_interval(item, &cfg_quota->interval);
2486 WARNING("netapp plugin: The option %s is not allowed within "
2492 } /* }}} int cna_config_quota */
2494 /* Corresponds to a <Disks /> block */
2495 static int cna_config_disk(host_config_t *host, oconfig_item_t *ci) { /* {{{ */
2496 cfg_disk_t *cfg_disk;
2498 if ((host == NULL) || (ci == NULL))
2501 if (host->cfg_disk == NULL) {
2502 cfg_disk = calloc(1, sizeof(*cfg_disk));
2503 if (cfg_disk == NULL)
2506 /* Set default flags */
2507 cfg_disk->flags = CFG_DISK_ALL;
2508 cfg_disk->query = NULL;
2509 cfg_disk->disks = NULL;
2511 host->cfg_disk = cfg_disk;
2513 cfg_disk = host->cfg_disk;
2515 for (int i = 0; i < ci->children_num; ++i) {
2516 oconfig_item_t *item = ci->children + i;
2518 /* if (!item || !item->key || !*item->key) continue; */
2519 if (strcasecmp(item->key, "Interval") == 0)
2520 cna_config_get_interval(item, &cfg_disk->interval);
2521 else if (strcasecmp(item->key, "GetBusy") == 0)
2522 cna_config_bool_to_flag(item, &cfg_disk->flags, CFG_DISK_BUSIEST);
2525 if ((cfg_disk->flags & CFG_DISK_ALL) == 0) {
2526 NOTICE("netapp plugin: All disk related values have been disabled. "
2527 "Collection of per-disk data will be disabled entirely.");
2528 free_cfg_disk(host->cfg_disk);
2529 host->cfg_disk = NULL;
2533 } /* }}} int cna_config_disk */
2535 /* Corresponds to a <WAFL /> block */
2536 static int cna_config_wafl(host_config_t *host, oconfig_item_t *ci) /* {{{ */
2538 cfg_wafl_t *cfg_wafl;
2540 if ((host == NULL) || (ci == NULL))
2543 if (host->cfg_wafl == NULL) {
2544 cfg_wafl = calloc(1, sizeof(*cfg_wafl));
2545 if (cfg_wafl == NULL)
2548 /* Set default flags */
2549 cfg_wafl->flags = CFG_WAFL_ALL;
2551 host->cfg_wafl = cfg_wafl;
2553 cfg_wafl = host->cfg_wafl;
2555 for (int i = 0; i < ci->children_num; ++i) {
2556 oconfig_item_t *item = ci->children + i;
2558 if (strcasecmp(item->key, "Interval") == 0)
2559 cna_config_get_interval(item, &cfg_wafl->interval);
2560 else if (!strcasecmp(item->key, "GetNameCache"))
2561 cna_config_bool_to_flag(item, &cfg_wafl->flags, CFG_WAFL_NAME_CACHE);
2562 else if (!strcasecmp(item->key, "GetDirCache"))
2563 cna_config_bool_to_flag(item, &cfg_wafl->flags, CFG_WAFL_DIR_CACHE);
2564 else if (!strcasecmp(item->key, "GetBufferCache"))
2565 cna_config_bool_to_flag(item, &cfg_wafl->flags, CFG_WAFL_BUF_CACHE);
2566 else if (!strcasecmp(item->key, "GetInodeCache"))
2567 cna_config_bool_to_flag(item, &cfg_wafl->flags, CFG_WAFL_INODE_CACHE);
2569 WARNING("netapp plugin: The %s config option is not allowed within "
2574 if ((cfg_wafl->flags & CFG_WAFL_ALL) == 0) {
2575 NOTICE("netapp plugin: All WAFL related values have been disabled. "
2576 "Collection of WAFL data will be disabled entirely.");
2577 free_cfg_wafl(host->cfg_wafl);
2578 host->cfg_wafl = NULL;
2582 } /* }}} int cna_config_wafl */
2586 * GetCapacity "vol0"
2587 * GetCapacity "vol1"
2588 * GetCapacity "vol2"
2589 * GetCapacity "vol3"
2590 * GetCapacity "vol4"
2591 * IgnoreSelectedCapacity false
2593 * GetSnapshot "vol0"
2594 * GetSnapshot "vol3"
2595 * GetSnapshot "vol4"
2596 * GetSnapshot "vol7"
2597 * IgnoreSelectedSnapshot false
2600 /* Corresponds to a <VolumeUsage /> block */
2601 static int cna_config_volume_usage(host_config_t *host, /* {{{ */
2602 const oconfig_item_t *ci) {
2603 cfg_volume_usage_t *cfg_volume_usage;
2605 if ((host == NULL) || (ci == NULL))
2608 if (host->cfg_volume_usage == NULL) {
2609 cfg_volume_usage = calloc(1, sizeof(*cfg_volume_usage));
2610 if (cfg_volume_usage == NULL)
2613 /* Set default flags */
2614 cfg_volume_usage->query = NULL;
2615 cfg_volume_usage->volumes = NULL;
2617 cfg_volume_usage->il_capacity = ignorelist_create(/* invert = */ 1);
2618 if (cfg_volume_usage->il_capacity == NULL) {
2619 sfree(cfg_volume_usage);
2623 cfg_volume_usage->il_snapshot = ignorelist_create(/* invert = */ 1);
2624 if (cfg_volume_usage->il_snapshot == NULL) {
2625 ignorelist_free(cfg_volume_usage->il_capacity);
2626 sfree(cfg_volume_usage);
2630 host->cfg_volume_usage = cfg_volume_usage;
2632 cfg_volume_usage = host->cfg_volume_usage;
2634 for (int i = 0; i < ci->children_num; ++i) {
2635 oconfig_item_t *item = ci->children + i;
2637 /* if (!item || !item->key || !*item->key) continue; */
2638 if (strcasecmp(item->key, "Interval") == 0)
2639 cna_config_get_interval(item, &cfg_volume_usage->interval);
2640 else if (!strcasecmp(item->key, "GetCapacity"))
2641 cna_config_volume_usage_option(cfg_volume_usage, item);
2642 else if (!strcasecmp(item->key, "GetSnapshot"))
2643 cna_config_volume_usage_option(cfg_volume_usage, item);
2644 else if (!strcasecmp(item->key, "IgnoreSelectedCapacity"))
2645 cna_config_volume_usage_default(cfg_volume_usage, item);
2646 else if (!strcasecmp(item->key, "IgnoreSelectedSnapshot"))
2647 cna_config_volume_usage_default(cfg_volume_usage, item);
2649 WARNING("netapp plugin: The option %s is not allowed within "
2650 "`VolumeUsage' blocks.",
2655 } /* }}} int cna_config_volume_usage */
2657 /* Corresponds to a <SnapVault /> block */
2658 static int cna_config_snapvault(host_config_t *host, /* {{{ */
2659 const oconfig_item_t *ci) {
2660 cfg_snapvault_t *cfg_snapvault;
2662 if ((host == NULL) || (ci == NULL))
2665 if (host->cfg_snapvault == NULL) {
2666 cfg_snapvault = calloc(1, sizeof(*cfg_snapvault));
2667 if (cfg_snapvault == NULL)
2669 cfg_snapvault->query = NULL;
2671 host->cfg_snapvault = cfg_snapvault;
2674 cfg_snapvault = host->cfg_snapvault;
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 cna_config_get_interval(item, &cfg_snapvault->interval);
2682 WARNING("netapp plugin: The option %s is not allowed within "
2683 "`SnapVault' blocks.",
2688 } /* }}} int cna_config_snapvault */
2690 /* Corresponds to a <System /> block */
2691 static int cna_config_system(host_config_t *host, /* {{{ */
2692 oconfig_item_t *ci) {
2693 cfg_system_t *cfg_system;
2695 if ((host == NULL) || (ci == NULL))
2698 if (host->cfg_system == NULL) {
2699 cfg_system = calloc(1, sizeof(*cfg_system));
2700 if (cfg_system == NULL)
2703 /* Set default flags */
2704 cfg_system->flags = CFG_SYSTEM_ALL;
2705 cfg_system->query = NULL;
2707 host->cfg_system = cfg_system;
2709 cfg_system = host->cfg_system;
2711 for (int i = 0; i < ci->children_num; ++i) {
2712 oconfig_item_t *item = ci->children + i;
2714 if (strcasecmp(item->key, "Interval") == 0) {
2715 cna_config_get_interval(item, &cfg_system->interval);
2716 } else if (!strcasecmp(item->key, "GetCPULoad")) {
2717 cna_config_bool_to_flag(item, &cfg_system->flags, CFG_SYSTEM_CPU);
2718 } else if (!strcasecmp(item->key, "GetInterfaces")) {
2719 cna_config_bool_to_flag(item, &cfg_system->flags, CFG_SYSTEM_NET);
2720 } else if (!strcasecmp(item->key, "GetDiskOps")) {
2721 cna_config_bool_to_flag(item, &cfg_system->flags, CFG_SYSTEM_OPS);
2722 } else if (!strcasecmp(item->key, "GetDiskIO")) {
2723 cna_config_bool_to_flag(item, &cfg_system->flags, CFG_SYSTEM_DISK);
2725 WARNING("netapp plugin: The %s config option is not allowed within "
2731 if ((cfg_system->flags & CFG_SYSTEM_ALL) == 0) {
2732 NOTICE("netapp plugin: All system related values have been disabled. "
2733 "Collection of system data will be disabled entirely.");
2734 free_cfg_system(host->cfg_system);
2735 host->cfg_system = NULL;
2739 } /* }}} int cna_config_system */
2741 /* Corresponds to a <Host /> block. */
2742 static host_config_t *cna_alloc_host(void) /* {{{ */
2744 host_config_t *host;
2746 host = calloc(1, sizeof(*host));
2751 host->protocol = NA_SERVER_TRANSPORT_HTTPS;
2753 host->username = NULL;
2754 host->password = NULL;
2755 host->vfiler = NULL;
2757 host->cfg_wafl = NULL;
2758 host->cfg_disk = NULL;
2759 host->cfg_volume_perf = NULL;
2760 host->cfg_volume_usage = NULL;
2761 host->cfg_quota = NULL;
2762 host->cfg_snapvault = NULL;
2763 host->cfg_system = NULL;
2766 } /* }}} host_config_t *cna_alloc_host */
2768 static host_config_t *cna_shallow_clone_host(host_config_t *host) /* {{{ */
2770 host_config_t *clone;
2775 clone = cna_alloc_host();
2779 if (host->name != NULL) {
2780 clone->name = strdup(host->name);
2781 if (clone->name == NULL) {
2782 free_host_config(clone);
2787 clone->protocol = host->protocol;
2789 if (host->host != NULL) {
2790 clone->host = strdup(host->host);
2791 if (clone->host == NULL) {
2792 free_host_config(clone);
2797 clone->port = host->port;
2799 if (host->username != NULL) {
2800 clone->username = strdup(host->username);
2801 if (clone->username == NULL) {
2802 free_host_config(clone);
2806 if (host->password != NULL) {
2807 clone->password = strdup(host->password);
2808 if (clone->password == NULL) {
2809 free_host_config(clone);
2814 clone->interval = host->interval;
2817 } /* }}} host_config_t *cna_shallow_clone_host */
2819 static int cna_read(user_data_t *ud);
2821 static int cna_register_host(host_config_t *host) /* {{{ */
2826 snprintf(cb_name, sizeof(cb_name), "netapp-%s-%s", host->name,
2829 snprintf(cb_name, sizeof(cb_name), "netapp-%s", host->name);
2831 plugin_register_complex_read(
2832 /* group = */ NULL, cb_name,
2833 /* callback = */ cna_read,
2834 /* interval = */ host->interval,
2836 .data = host, .free_func = (void *)free_host_config,
2840 } /* }}} int cna_register_host */
2842 static int cna_config_host(host_config_t *host, /* {{{ */
2843 const oconfig_item_t *ci) {
2844 oconfig_item_t *item;
2845 _Bool is_vfiler = 0;
2848 if (!strcasecmp(ci->key, "VFiler"))
2851 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2852 WARNING("netapp plugin: \"%s\" needs exactly one string argument. Ignoring "
2858 status = cf_util_get_string(ci, &host->name);
2862 for (int i = 0; i < ci->children_num; ++i) {
2863 item = ci->children + i;
2867 if (!strcasecmp(item->key, "Address")) {
2868 status = cf_util_get_string(item, &host->host);
2869 } else if (!strcasecmp(item->key, "Port")) {
2872 tmp = cf_util_get_port_number(item);
2875 } else if (!strcasecmp(item->key, "Protocol")) {
2876 if ((item->values_num != 1) ||
2877 (item->values[0].type != OCONFIG_TYPE_STRING) ||
2878 (strcasecmp(item->values[0].value.string, "http") &&
2879 strcasecmp(item->values[0].value.string, "https"))) {
2880 WARNING("netapp plugin: \"Protocol\" needs to be either \"http\" or "
2881 "\"https\". Ignoring host block \"%s\".",
2882 ci->values[0].value.string);
2885 if (!strcasecmp(item->values[0].value.string, "http"))
2886 host->protocol = NA_SERVER_TRANSPORT_HTTP;
2888 host->protocol = NA_SERVER_TRANSPORT_HTTPS;
2889 } else if (!strcasecmp(item->key, "User")) {
2890 status = cf_util_get_string(item, &host->username);
2891 } else if (!strcasecmp(item->key, "Password")) {
2892 status = cf_util_get_string(item, &host->password);
2893 } else if (!strcasecmp(item->key, "Interval")) {
2894 status = cf_util_get_cdtime(item, &host->interval);
2895 } else if (!strcasecmp(item->key, "WAFL")) {
2896 cna_config_wafl(host, item);
2897 } else if (!strcasecmp(item->key, "Disks")) {
2898 cna_config_disk(host, item);
2899 } else if (!strcasecmp(item->key, "VolumePerf")) {
2900 cna_config_volume_performance(host, item);
2901 } else if (!strcasecmp(item->key, "VolumeUsage")) {
2902 cna_config_volume_usage(host, item);
2903 } else if (!strcasecmp(item->key, "Quota")) {
2904 cna_config_quota(host, item);
2905 } else if (!strcasecmp(item->key, "SnapVault")) {
2906 cna_config_snapvault(host, item);
2907 } else if (!strcasecmp(item->key, "System")) {
2908 cna_config_system(host, item);
2909 } else if ((!strcasecmp(item->key, "VFiler")) && (!is_vfiler)) {
2910 host_config_t *vfiler;
2912 vfiler = cna_shallow_clone_host(host);
2914 ERROR("netapp plugin: Failed to allocate host object for vfiler.");
2918 if (cna_config_host(vfiler, item)) {
2919 free_host_config(vfiler);
2923 cna_register_host(vfiler);
2924 } else if ((!strcasecmp(item->key, "VFilerName")) && is_vfiler) {
2925 status = cf_util_get_string(item, &host->vfiler);
2927 WARNING("netapp plugin: Ignoring unknown config option \"%s\" in %s "
2929 item->key, is_vfiler ? "vfiler" : "host",
2930 ci->values[0].value.string);
2937 if (host->host == NULL)
2938 host->host = strdup(host->name);
2940 if (is_vfiler && (!host->vfiler))
2941 host->vfiler = strdup(host->name);
2943 if (host->host == NULL)
2946 if (host->port <= 0)
2947 host->port = (host->protocol == NA_SERVER_TRANSPORT_HTTP) ? 80 : 443;
2949 if ((host->username == NULL) || (host->password == NULL)) {
2950 WARNING("netapp plugin: Please supply login information for host \"%s\". "
2951 "Ignoring host block.",
2960 } /* }}} host_config_t *cna_config_host */
2963 * Callbacks registered with the daemon
2965 * Pretty standard stuff here.
2967 static int cna_init_host(host_config_t *host) /* {{{ */
2969 /* Request version 1.1 of the ONTAP API */
2970 int major_version = 1, minor_version = 1;
2975 if (host->srv != NULL)
2978 if (host->vfiler != NULL) /* Request version 1.7 of the ONTAP API */
2981 host->srv = na_server_open(host->host, major_version, minor_version);
2982 if (host->srv == NULL) {
2983 ERROR("netapp plugin: na_server_open (%s) failed.", host->host);
2987 na_server_set_transport_type(host->srv, host->protocol,
2988 /* transportarg = */ NULL);
2989 na_server_set_port(host->srv, host->port);
2990 na_server_style(host->srv, NA_STYLE_LOGIN_PASSWORD);
2991 na_server_adminuser(host->srv, host->username, host->password);
2992 na_server_set_timeout(host->srv, 5 /* seconds */);
2994 if (host->vfiler != NULL) {
2995 if (!na_server_set_vfiler(host->srv, host->vfiler)) {
2996 ERROR("netapp plugin: Failed to connect to VFiler '%s' on host '%s'.",
2997 host->vfiler, host->host);
3000 INFO("netapp plugin: Connected to VFiler '%s' on host '%s'.",
3001 host->vfiler, host->host);
3006 } /* }}} int cna_init_host */
3008 static int cna_init(void) /* {{{ */
3010 char err[256] = {0};
3012 if (!na_startup(err, sizeof(err))) {
3013 err[sizeof(err) - 1] = 0;
3014 ERROR("netapp plugin: Error initializing netapp API: %s", err);
3019 } /* }}} cna_init */
3021 static int cna_read_internal(host_config_t *host) { /* {{{ */
3024 status = cna_query_wafl(host);
3028 status = cna_query_disk(host);
3032 status = cna_query_volume_perf(host);
3036 status = cna_query_volume_usage(host);
3040 status = cna_query_quota(host);
3044 status = cna_query_snapvault(host);
3048 status = cna_query_system(host);
3053 } /* }}} int cna_read_internal */
3055 static int cna_read(user_data_t *ud) { /* {{{ */
3056 host_config_t *host;
3059 if ((ud == NULL) || (ud->data == NULL))
3064 status = cna_init_host(host);
3068 status = cna_read_internal(host);
3070 if (host->srv != NULL)
3071 na_server_close(host->srv);
3076 } /* }}} int cna_read */
3078 static int cna_config(oconfig_item_t *ci) { /* {{{ */
3079 oconfig_item_t *item;
3081 for (int i = 0; i < ci->children_num; ++i) {
3082 item = ci->children + i;
3084 if (strcasecmp(item->key, "Host") == 0) {
3085 host_config_t *host;
3087 host = cna_alloc_host();
3089 ERROR("netapp plugin: Failed to allocate host object.");
3093 if (cna_config_host(host, item) != 0) {
3094 free_host_config(host);
3098 cna_register_host(host);
3099 } else /* if (item->key != "Host") */
3101 WARNING("netapp plugin: Ignoring unknown config option \"%s\".",
3106 } /* }}} int cna_config */
3108 static int cna_shutdown(void) /* {{{ */
3110 /* Clean up system resources and stuff. */
3114 } /* }}} int cna_shutdown */
3116 void module_register(void) {
3117 plugin_register_complex_config("netapp", cna_config);
3118 plugin_register_init("netapp", cna_init);
3119 plugin_register_shutdown("netapp", cna_shutdown);