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, &(value_t){
659 }, 1, timestamp, interval);
660 } /* }}} int submit_derive */
662 static int submit_two_gauge(const char *host, const char *plugin_inst, /* {{{ */
663 const char *type, const char *type_inst,
664 gauge_t val0, gauge_t val1, cdtime_t timestamp,
667 {.gauge = val0}, {.gauge = val1},
670 return submit_values(host, plugin_inst, type, type_inst, values,
671 STATIC_ARRAY_SIZE(values), timestamp, interval);
672 } /* }}} int submit_two_gauge */
674 static int submit_double(const char *host, const char *plugin_inst, /* {{{ */
675 const char *type, const char *type_inst, double d,
676 cdtime_t timestamp, cdtime_t interval) {
677 return submit_values(host, plugin_inst, type, type_inst, &(value_t){
679 }, 1, timestamp, interval);
680 } /* }}} int submit_uint64 */
682 /* Calculate hit ratio from old and new counters and submit the resulting
683 * percentage. Used by "submit_wafl_data". */
684 static int submit_cache_ratio(const char *host, /* {{{ */
685 const char *plugin_inst, const char *type_inst,
686 uint64_t new_hits, uint64_t new_misses,
687 uint64_t old_hits, uint64_t old_misses,
688 cdtime_t timestamp, cdtime_t interval) {
689 value_t v = {.gauge = NAN};
691 if ((new_hits >= old_hits) && (new_misses >= old_misses)) {
695 hits = new_hits - old_hits;
696 misses = new_misses - old_misses;
698 v.gauge = 100.0 * ((gauge_t)hits) / ((gauge_t)(hits + misses));
701 return submit_values(host, plugin_inst, "cache_ratio", type_inst, &v, 1,
702 timestamp, interval);
703 } /* }}} int submit_cache_ratio */
705 /* Submits all the caches used by WAFL. Uses "submit_cache_ratio". */
706 static int submit_wafl_data(const char *hostname,
707 const char *instance, /* {{{ */
708 cfg_wafl_t *old_data, const cfg_wafl_t *new_data,
710 /* Submit requested counters */
711 if (HAS_ALL_FLAGS(old_data->flags,
712 CFG_WAFL_NAME_CACHE | HAVE_WAFL_NAME_CACHE) &&
713 HAS_ALL_FLAGS(new_data->flags, HAVE_WAFL_NAME_CACHE))
714 submit_cache_ratio(hostname, instance, "name_cache_hit",
715 new_data->name_cache_hit, new_data->name_cache_miss,
716 old_data->name_cache_hit, old_data->name_cache_miss,
717 new_data->timestamp, interval);
719 if (HAS_ALL_FLAGS(old_data->flags, CFG_WAFL_DIR_CACHE | HAVE_WAFL_FIND_DIR) &&
720 HAS_ALL_FLAGS(new_data->flags, HAVE_WAFL_FIND_DIR))
721 submit_cache_ratio(hostname, instance, "find_dir_hit",
722 new_data->find_dir_hit, new_data->find_dir_miss,
723 old_data->find_dir_hit, old_data->find_dir_miss,
724 new_data->timestamp, interval);
726 if (HAS_ALL_FLAGS(old_data->flags, CFG_WAFL_BUF_CACHE | HAVE_WAFL_BUF_HASH) &&
727 HAS_ALL_FLAGS(new_data->flags, HAVE_WAFL_BUF_HASH))
728 submit_cache_ratio(hostname, instance, "buf_hash_hit",
729 new_data->buf_hash_hit, new_data->buf_hash_miss,
730 old_data->buf_hash_hit, old_data->buf_hash_miss,
731 new_data->timestamp, interval);
733 if (HAS_ALL_FLAGS(old_data->flags,
734 CFG_WAFL_INODE_CACHE | HAVE_WAFL_INODE_CACHE) &&
735 HAS_ALL_FLAGS(new_data->flags, HAVE_WAFL_INODE_CACHE))
736 submit_cache_ratio(hostname, instance, "inode_cache_hit",
737 new_data->inode_cache_hit, new_data->inode_cache_miss,
738 old_data->inode_cache_hit, old_data->inode_cache_miss,
739 new_data->timestamp, interval);
741 /* Clear old HAVE_* flags */
742 old_data->flags &= ~HAVE_WAFL_ALL;
744 /* Copy all counters */
745 old_data->timestamp = new_data->timestamp;
746 old_data->name_cache_hit = new_data->name_cache_hit;
747 old_data->name_cache_miss = new_data->name_cache_miss;
748 old_data->find_dir_hit = new_data->find_dir_hit;
749 old_data->find_dir_miss = new_data->find_dir_miss;
750 old_data->buf_hash_hit = new_data->buf_hash_hit;
751 old_data->buf_hash_miss = new_data->buf_hash_miss;
752 old_data->inode_cache_hit = new_data->inode_cache_hit;
753 old_data->inode_cache_miss = new_data->inode_cache_miss;
755 /* Copy HAVE_* flags */
756 old_data->flags |= (new_data->flags & HAVE_WAFL_ALL);
759 } /* }}} int submit_wafl_data */
761 /* Submits volume performance data to the daemon, taking care to honor and
762 * update flags appropriately. */
763 static int submit_volume_perf_data(const char *hostname, /* {{{ */
764 data_volume_perf_t *old_data,
765 const data_volume_perf_t *new_data,
767 char plugin_instance[DATA_MAX_NAME_LEN];
769 if ((hostname == NULL) || (old_data == NULL) || (new_data == NULL))
772 ssnprintf(plugin_instance, sizeof(plugin_instance), "volume-%s",
775 /* Check for and submit disk-octet values */
776 if (HAS_ALL_FLAGS(old_data->flags, CFG_VOLUME_PERF_IO) &&
777 HAS_ALL_FLAGS(new_data->flags, HAVE_VOLUME_PERF_BYTES_READ |
778 HAVE_VOLUME_PERF_BYTES_WRITE)) {
780 hostname, plugin_instance, "disk_octets", /* type instance = */ NULL,
781 (derive_t)new_data->read_bytes, (derive_t)new_data->write_bytes,
782 new_data->timestamp, interval);
785 /* Check for and submit disk-operations values */
786 if (HAS_ALL_FLAGS(old_data->flags, CFG_VOLUME_PERF_OPS) &&
787 HAS_ALL_FLAGS(new_data->flags,
788 HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE)) {
789 submit_two_derive(hostname, plugin_instance, "disk_ops",
790 /* type instance = */ NULL, (derive_t)new_data->read_ops,
791 (derive_t)new_data->write_ops, new_data->timestamp,
795 /* Check for, calculate and submit disk-latency values */
796 if (HAS_ALL_FLAGS(old_data->flags, CFG_VOLUME_PERF_LATENCY |
797 HAVE_VOLUME_PERF_OPS_READ |
798 HAVE_VOLUME_PERF_OPS_WRITE |
799 HAVE_VOLUME_PERF_LATENCY_READ |
800 HAVE_VOLUME_PERF_LATENCY_WRITE) &&
801 HAS_ALL_FLAGS(new_data->flags, HAVE_VOLUME_PERF_OPS_READ |
802 HAVE_VOLUME_PERF_OPS_WRITE |
803 HAVE_VOLUME_PERF_LATENCY_READ |
804 HAVE_VOLUME_PERF_LATENCY_WRITE)) {
805 gauge_t latency_per_op_read;
806 gauge_t latency_per_op_write;
808 latency_per_op_read = NAN;
809 latency_per_op_write = NAN;
811 /* Check if a counter wrapped around. */
812 if ((new_data->read_ops > old_data->read_ops) &&
813 (new_data->read_latency > old_data->read_latency)) {
814 uint64_t diff_ops_read;
815 uint64_t diff_latency_read;
817 diff_ops_read = new_data->read_ops - old_data->read_ops;
818 diff_latency_read = new_data->read_latency - old_data->read_latency;
820 if (diff_ops_read > 0)
821 latency_per_op_read =
822 ((gauge_t)diff_latency_read) / ((gauge_t)diff_ops_read);
825 if ((new_data->write_ops > old_data->write_ops) &&
826 (new_data->write_latency > old_data->write_latency)) {
827 uint64_t diff_ops_write;
828 uint64_t diff_latency_write;
830 diff_ops_write = new_data->write_ops - old_data->write_ops;
831 diff_latency_write = new_data->write_latency - old_data->write_latency;
833 if (diff_ops_write > 0)
834 latency_per_op_write =
835 ((gauge_t)diff_latency_write) / ((gauge_t)diff_ops_write);
838 submit_two_gauge(hostname, plugin_instance, "disk_latency",
839 /* type instance = */ NULL, latency_per_op_read,
840 latency_per_op_write, new_data->timestamp, interval);
843 /* Clear all HAVE_* flags. */
844 old_data->flags &= ~HAVE_VOLUME_PERF_ALL;
846 /* Copy all counters */
847 old_data->timestamp = new_data->timestamp;
848 old_data->read_bytes = new_data->read_bytes;
849 old_data->write_bytes = new_data->write_bytes;
850 old_data->read_ops = new_data->read_ops;
851 old_data->write_ops = new_data->write_ops;
852 old_data->read_latency = new_data->read_latency;
853 old_data->write_latency = new_data->write_latency;
855 /* Copy the HAVE_* flags */
856 old_data->flags |= (new_data->flags & HAVE_VOLUME_PERF_ALL);
859 } /* }}} int submit_volume_perf_data */
861 static cdtime_t cna_child_get_cdtime(na_elem_t *data) /* {{{ */
865 t = (time_t)na_child_get_uint64(data, "timestamp", /* default = */ 0);
867 return TIME_T_TO_CDTIME_T(t);
868 } /* }}} cdtime_t cna_child_get_cdtime */
873 * These functions are called with appropriate data returned by the libnetapp
874 * interface which is parsed and submitted with the above functions.
876 /* Data corresponding to <WAFL /> */
877 static int cna_handle_wafl_data(const char *hostname,
878 cfg_wafl_t *cfg_wafl, /* {{{ */
879 na_elem_t *data, cdtime_t interval) {
880 cfg_wafl_t perf_data = {0};
881 const char *plugin_inst;
883 na_elem_t *instances;
884 na_elem_iter_t counter_iter;
886 perf_data.timestamp = cna_child_get_cdtime(data);
888 instances = na_elem_child(na_elem_child(data, "instances"), "instance-data");
889 if (instances == NULL) {
890 ERROR("netapp plugin: cna_handle_wafl_data: "
891 "na_elem_child (\"instances\") failed "
897 plugin_inst = na_child_get_string(instances, "name");
898 if (plugin_inst == NULL) {
899 ERROR("netapp plugin: cna_handle_wafl_data: "
900 "na_child_get_string (\"name\") failed "
906 /* Iterate over all counters */
907 counter_iter = na_child_iterator(na_elem_child(instances, "counters"));
908 for (na_elem_t *counter = na_iterator_next(&counter_iter); counter != NULL;
909 counter = na_iterator_next(&counter_iter)) {
913 name = na_child_get_string(counter, "name");
917 value = na_child_get_uint64(counter, "value", UINT64_MAX);
918 if (value == UINT64_MAX)
921 if (!strcmp(name, "name_cache_hit")) {
922 perf_data.name_cache_hit = value;
923 perf_data.flags |= HAVE_WAFL_NAME_CACHE_HIT;
924 } else if (!strcmp(name, "name_cache_miss")) {
925 perf_data.name_cache_miss = value;
926 perf_data.flags |= HAVE_WAFL_NAME_CACHE_MISS;
927 } else if (!strcmp(name, "find_dir_hit")) {
928 perf_data.find_dir_hit = value;
929 perf_data.flags |= HAVE_WAFL_FIND_DIR_HIT;
930 } else if (!strcmp(name, "find_dir_miss")) {
931 perf_data.find_dir_miss = value;
932 perf_data.flags |= HAVE_WAFL_FIND_DIR_MISS;
933 } else if (!strcmp(name, "buf_hash_hit")) {
934 perf_data.buf_hash_hit = value;
935 perf_data.flags |= HAVE_WAFL_BUF_HASH_HIT;
936 } else if (!strcmp(name, "buf_hash_miss")) {
937 perf_data.buf_hash_miss = value;
938 perf_data.flags |= HAVE_WAFL_BUF_HASH_MISS;
939 } else if (!strcmp(name, "inode_cache_hit")) {
940 perf_data.inode_cache_hit = value;
941 perf_data.flags |= HAVE_WAFL_INODE_CACHE_HIT;
942 } else if (!strcmp(name, "inode_cache_miss")) {
943 perf_data.inode_cache_miss = value;
944 perf_data.flags |= HAVE_WAFL_INODE_CACHE_MISS;
946 DEBUG("netapp plugin: cna_handle_wafl_data: "
947 "Found unexpected child: %s "
953 return submit_wafl_data(hostname, plugin_inst, cfg_wafl, &perf_data,
955 } /* }}} void cna_handle_wafl_data */
957 static int cna_setup_wafl(cfg_wafl_t *cw) /* {{{ */
964 if (cw->query != NULL)
967 cw->query = na_elem_new("perf-object-get-instances");
968 if (cw->query == NULL) {
969 ERROR("netapp plugin: na_elem_new failed.");
972 na_child_add_string(cw->query, "objectname", "wafl");
974 e = na_elem_new("counters");
976 na_elem_free(cw->query);
978 ERROR("netapp plugin: na_elem_new failed.");
981 na_child_add_string(e, "counter", "name_cache_hit");
982 na_child_add_string(e, "counter", "name_cache_miss");
983 na_child_add_string(e, "counter", "find_dir_hit");
984 na_child_add_string(e, "counter", "find_dir_miss");
985 na_child_add_string(e, "counter", "buf_hash_hit");
986 na_child_add_string(e, "counter", "buf_hash_miss");
987 na_child_add_string(e, "counter", "inode_cache_hit");
988 na_child_add_string(e, "counter", "inode_cache_miss");
990 na_child_add(cw->query, e);
993 } /* }}} int cna_setup_wafl */
995 static int cna_query_wafl(host_config_t *host) /* {{{ */
1004 /* If WAFL was not configured, return without doing anything. */
1005 if (host->cfg_wafl == NULL)
1009 if ((host->cfg_wafl->interval.interval + host->cfg_wafl->interval.last_read) >
1013 status = cna_setup_wafl(host->cfg_wafl);
1016 assert(host->cfg_wafl->query != NULL);
1018 data = na_server_invoke_elem(host->srv, host->cfg_wafl->query);
1019 if (na_results_status(data) != NA_OK) {
1020 ERROR("netapp plugin: cna_query_wafl: na_server_invoke_elem failed for "
1022 host->name, na_results_reason(data));
1027 status = cna_handle_wafl_data(host->name, host->cfg_wafl, data,
1028 host->cfg_wafl->interval.interval);
1031 host->cfg_wafl->interval.last_read = now;
1035 } /* }}} int cna_query_wafl */
1037 /* Data corresponding to <Disks /> */
1038 static int cna_handle_disk_data(const char *hostname, /* {{{ */
1039 cfg_disk_t *cfg_disk, na_elem_t *data,
1040 cdtime_t interval) {
1042 na_elem_t *instances;
1043 na_elem_iter_t instance_iter;
1044 disk_t *worst_disk = NULL;
1046 if ((cfg_disk == NULL) || (data == NULL))
1049 timestamp = cna_child_get_cdtime(data);
1051 instances = na_elem_child(data, "instances");
1052 if (instances == NULL) {
1053 ERROR("netapp plugin: cna_handle_disk_data: "
1054 "na_elem_child (\"instances\") failed "
1060 /* Iterate over all children */
1061 instance_iter = na_child_iterator(instances);
1062 for (na_elem_t *instance = na_iterator_next(&instance_iter); instance != NULL;
1063 instance = na_iterator_next(&instance_iter)) {
1065 disk_t new_data = {0};
1067 na_elem_iter_t counter_iterator;
1069 new_data.timestamp = timestamp;
1070 new_data.disk_busy_percent = NAN;
1072 old_data = get_disk(cfg_disk, na_child_get_string(instance, "name"));
1073 if (old_data == NULL)
1076 /* Look for the "disk_busy" and "base_for_disk_busy" counters */
1077 counter_iterator = na_child_iterator(na_elem_child(instance, "counters"));
1078 for (na_elem_t *counter = na_iterator_next(&counter_iterator);
1079 counter != NULL; counter = na_iterator_next(&counter_iterator)) {
1083 name = na_child_get_string(counter, "name");
1087 value = na_child_get_uint64(counter, "value", UINT64_MAX);
1088 if (value == UINT64_MAX)
1091 if (strcmp(name, "disk_busy") == 0) {
1092 new_data.disk_busy = value;
1093 new_data.flags |= HAVE_DISK_BUSY;
1094 } else if (strcmp(name, "base_for_disk_busy") == 0) {
1095 new_data.base_for_disk_busy = value;
1096 new_data.flags |= HAVE_DISK_BASE;
1098 DEBUG("netapp plugin: cna_handle_disk_data: "
1099 "Counter not handled: %s = %" PRIu64,
1104 /* If all required counters are available and did not just wrap around,
1105 * calculate the busy percentage. Otherwise, the value is initialized to
1106 * NAN at the top of the for-loop. */
1107 if (HAS_ALL_FLAGS(old_data->flags, HAVE_DISK_BUSY | HAVE_DISK_BASE) &&
1108 HAS_ALL_FLAGS(new_data.flags, HAVE_DISK_BUSY | HAVE_DISK_BASE) &&
1109 (new_data.disk_busy >= old_data->disk_busy) &&
1110 (new_data.base_for_disk_busy > old_data->base_for_disk_busy)) {
1114 busy_diff = new_data.disk_busy - old_data->disk_busy;
1115 base_diff = new_data.base_for_disk_busy - old_data->base_for_disk_busy;
1117 new_data.disk_busy_percent =
1118 100.0 * ((gauge_t)busy_diff) / ((gauge_t)base_diff);
1121 /* Clear HAVE_* flags */
1122 old_data->flags &= ~HAVE_DISK_ALL;
1125 old_data->timestamp = new_data.timestamp;
1126 old_data->disk_busy = new_data.disk_busy;
1127 old_data->base_for_disk_busy = new_data.base_for_disk_busy;
1128 old_data->disk_busy_percent = new_data.disk_busy_percent;
1131 old_data->flags |= (new_data.flags & HAVE_DISK_ALL);
1133 if ((worst_disk == NULL) ||
1134 (worst_disk->disk_busy_percent < old_data->disk_busy_percent))
1135 worst_disk = old_data;
1136 } /* for (all disks) */
1138 if ((cfg_disk->flags & CFG_DISK_BUSIEST) && (worst_disk != NULL))
1139 submit_double(hostname, "system", "percent", "disk_busy",
1140 worst_disk->disk_busy_percent, timestamp, interval);
1143 } /* }}} int cna_handle_disk_data */
1145 static int cna_setup_disk(cfg_disk_t *cd) /* {{{ */
1152 if (cd->query != NULL)
1155 cd->query = na_elem_new("perf-object-get-instances");
1156 if (cd->query == NULL) {
1157 ERROR("netapp plugin: na_elem_new failed.");
1160 na_child_add_string(cd->query, "objectname", "disk");
1162 e = na_elem_new("counters");
1164 na_elem_free(cd->query);
1166 ERROR("netapp plugin: na_elem_new failed.");
1169 na_child_add_string(e, "counter", "disk_busy");
1170 na_child_add_string(e, "counter", "base_for_disk_busy");
1171 na_child_add(cd->query, e);
1174 } /* }}} int cna_setup_disk */
1176 static int cna_query_disk(host_config_t *host) /* {{{ */
1185 /* If the user did not configure disk statistics, return without doing
1187 if (host->cfg_disk == NULL)
1191 if ((host->cfg_disk->interval.interval + host->cfg_disk->interval.last_read) >
1195 status = cna_setup_disk(host->cfg_disk);
1198 assert(host->cfg_disk->query != NULL);
1200 data = na_server_invoke_elem(host->srv, host->cfg_disk->query);
1201 if (na_results_status(data) != NA_OK) {
1202 ERROR("netapp plugin: cna_query_disk: na_server_invoke_elem failed for "
1204 host->name, na_results_reason(data));
1209 status = cna_handle_disk_data(host->name, host->cfg_disk, data,
1210 host->cfg_disk->interval.interval);
1213 host->cfg_disk->interval.last_read = now;
1217 } /* }}} int cna_query_disk */
1219 /* Data corresponding to <VolumePerf /> */
1220 static int cna_handle_volume_perf_data(const char *hostname, /* {{{ */
1221 cfg_volume_perf_t *cvp, na_elem_t *data,
1222 cdtime_t interval) {
1224 na_elem_t *elem_instances;
1225 na_elem_iter_t iter_instances;
1227 timestamp = cna_child_get_cdtime(data);
1229 elem_instances = na_elem_child(data, "instances");
1230 if (elem_instances == NULL) {
1231 ERROR("netapp plugin: handle_volume_perf_data: "
1232 "na_elem_child (\"instances\") failed "
1238 iter_instances = na_child_iterator(elem_instances);
1239 for (na_elem_t *elem_instance = na_iterator_next(&iter_instances);
1240 elem_instance != NULL;
1241 elem_instance = na_iterator_next(&iter_instances)) {
1244 data_volume_perf_t perf_data = {0};
1245 data_volume_perf_t *v;
1247 na_elem_t *elem_counters;
1248 na_elem_iter_t iter_counters;
1250 perf_data.timestamp = timestamp;
1252 name = na_child_get_string(elem_instance, "name");
1256 /* get_volume_perf may return NULL if this volume is to be ignored. */
1257 v = get_volume_perf(cvp, name);
1261 elem_counters = na_elem_child(elem_instance, "counters");
1262 if (elem_counters == NULL)
1265 iter_counters = na_child_iterator(elem_counters);
1266 for (na_elem_t *elem_counter = na_iterator_next(&iter_counters);
1267 elem_counter != NULL;
1268 elem_counter = na_iterator_next(&iter_counters)) {
1272 name = na_child_get_string(elem_counter, "name");
1276 value = na_child_get_uint64(elem_counter, "value", UINT64_MAX);
1277 if (value == UINT64_MAX)
1280 if (!strcmp(name, "read_data")) {
1281 perf_data.read_bytes = value;
1282 perf_data.flags |= HAVE_VOLUME_PERF_BYTES_READ;
1283 } else if (!strcmp(name, "write_data")) {
1284 perf_data.write_bytes = value;
1285 perf_data.flags |= HAVE_VOLUME_PERF_BYTES_WRITE;
1286 } else if (!strcmp(name, "read_ops")) {
1287 perf_data.read_ops = value;
1288 perf_data.flags |= HAVE_VOLUME_PERF_OPS_READ;
1289 } else if (!strcmp(name, "write_ops")) {
1290 perf_data.write_ops = value;
1291 perf_data.flags |= HAVE_VOLUME_PERF_OPS_WRITE;
1292 } else if (!strcmp(name, "read_latency")) {
1293 perf_data.read_latency = value;
1294 perf_data.flags |= HAVE_VOLUME_PERF_LATENCY_READ;
1295 } else if (!strcmp(name, "write_latency")) {
1296 perf_data.write_latency = value;
1297 perf_data.flags |= HAVE_VOLUME_PERF_LATENCY_WRITE;
1299 } /* for (elem_counter) */
1301 submit_volume_perf_data(hostname, v, &perf_data, interval);
1302 } /* for (volume) */
1305 } /* }}} int cna_handle_volume_perf_data */
1307 static int cna_setup_volume_perf(cfg_volume_perf_t *cd) /* {{{ */
1314 if (cd->query != NULL)
1317 cd->query = na_elem_new("perf-object-get-instances");
1318 if (cd->query == NULL) {
1319 ERROR("netapp plugin: na_elem_new failed.");
1322 na_child_add_string(cd->query, "objectname", "volume");
1324 e = na_elem_new("counters");
1326 na_elem_free(cd->query);
1328 ERROR("netapp plugin: na_elem_new failed.");
1331 na_child_add_string(e, "counter", "read_ops");
1332 na_child_add_string(e, "counter", "write_ops");
1333 na_child_add_string(e, "counter", "read_data");
1334 na_child_add_string(e, "counter", "write_data");
1335 na_child_add_string(e, "counter", "read_latency");
1336 na_child_add_string(e, "counter", "write_latency");
1337 na_child_add(cd->query, e);
1340 } /* }}} int cna_setup_volume_perf */
1342 static int cna_query_volume_perf(host_config_t *host) /* {{{ */
1351 /* If the user did not configure volume performance statistics, return
1352 * without doing anything. */
1353 if (host->cfg_volume_perf == NULL)
1357 if ((host->cfg_volume_perf->interval.interval +
1358 host->cfg_volume_perf->interval.last_read) > now)
1361 status = cna_setup_volume_perf(host->cfg_volume_perf);
1364 assert(host->cfg_volume_perf->query != NULL);
1366 data = na_server_invoke_elem(host->srv, host->cfg_volume_perf->query);
1367 if (na_results_status(data) != NA_OK) {
1368 ERROR("netapp plugin: cna_query_volume_perf: na_server_invoke_elem failed "
1370 host->name, na_results_reason(data));
1376 cna_handle_volume_perf_data(host->name, host->cfg_volume_perf, data,
1377 host->cfg_volume_perf->interval.interval);
1380 host->cfg_volume_perf->interval.last_read = now;
1384 } /* }}} int cna_query_volume_perf */
1386 /* Data corresponding to <VolumeUsage /> */
1387 static int cna_submit_volume_usage_data(const char *hostname, /* {{{ */
1388 cfg_volume_usage_t *cfg_volume,
1390 for (data_volume_usage_t *v = cfg_volume->volumes; v != NULL; v = v->next) {
1391 char plugin_instance[DATA_MAX_NAME_LEN];
1393 uint64_t norm_used = v->norm_used;
1394 uint64_t norm_free = v->norm_free;
1395 uint64_t sis_saved = v->sis_saved;
1396 uint64_t compress_saved = v->compress_saved;
1397 uint64_t dedup_saved = v->dedup_saved;
1398 uint64_t snap_reserve_used = 0;
1399 uint64_t snap_reserve_free = v->snap_reserved;
1400 uint64_t snap_norm_used = v->snap_used;
1402 ssnprintf(plugin_instance, sizeof(plugin_instance), "volume-%s", v->name);
1404 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_USED |
1405 HAVE_VOLUME_USAGE_SNAP_RSVD)) {
1406 if (v->snap_reserved > v->snap_used) {
1407 snap_reserve_free = v->snap_reserved - v->snap_used;
1408 snap_reserve_used = v->snap_used;
1411 snap_reserve_free = 0;
1412 snap_reserve_used = v->snap_reserved;
1413 snap_norm_used = v->snap_used - v->snap_reserved;
1417 /* The space used by snapshots but not reserved for them is included in
1418 * both, norm_used and snap_norm_used. If possible, subtract this here. */
1419 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_NORM_USED |
1420 HAVE_VOLUME_USAGE_SNAP_USED)) {
1421 if (norm_used >= snap_norm_used)
1422 norm_used -= snap_norm_used;
1424 ERROR("netapp plugin: (norm_used = %" PRIu64 ") < (snap_norm_used = "
1425 "%" PRIu64 ") for host %s. Invalidating both.",
1426 norm_used, snap_norm_used, hostname);
1428 ~(HAVE_VOLUME_USAGE_NORM_USED | HAVE_VOLUME_USAGE_SNAP_USED);
1432 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_NORM_FREE))
1433 submit_double(hostname, /* plugin instance = */ plugin_instance,
1434 "df_complex", "free", (double)norm_free,
1435 /* timestamp = */ 0, interval);
1437 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SIS_SAVED))
1438 submit_double(hostname, /* plugin instance = */ plugin_instance,
1439 "df_complex", "sis_saved", (double)sis_saved,
1440 /* timestamp = */ 0, interval);
1442 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_COMPRESS_SAVED))
1443 submit_double(hostname, /* plugin instance = */ plugin_instance,
1444 "df_complex", "compression_saved", (double)compress_saved,
1445 /* timestamp = */ 0, interval);
1447 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_DEDUP_SAVED))
1448 submit_double(hostname, /* plugin instance = */ plugin_instance,
1449 "df_complex", "dedup_saved", (double)dedup_saved,
1450 /* timestamp = */ 0, interval);
1452 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_NORM_USED))
1453 submit_double(hostname, /* plugin instance = */ plugin_instance,
1454 "df_complex", "used", (double)norm_used,
1455 /* timestamp = */ 0, interval);
1457 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_RSVD))
1458 submit_double(hostname, /* plugin instance = */ plugin_instance,
1459 "df_complex", "snap_reserved", (double)snap_reserve_free,
1460 /* timestamp = */ 0, interval);
1462 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_USED |
1463 HAVE_VOLUME_USAGE_SNAP_RSVD))
1464 submit_double(hostname, /* plugin instance = */ plugin_instance,
1465 "df_complex", "snap_reserve_used",
1466 (double)snap_reserve_used, /* timestamp = */ 0, interval);
1468 if (HAS_ALL_FLAGS(v->flags, HAVE_VOLUME_USAGE_SNAP_USED))
1469 submit_double(hostname, /* plugin instance = */ plugin_instance,
1470 "df_complex", "snap_normal_used", (double)snap_norm_used,
1471 /* timestamp = */ 0, interval);
1473 /* Clear all the HAVE_* flags */
1474 v->flags &= ~HAVE_VOLUME_USAGE_ALL;
1475 } /* for (v = cfg_volume->volumes) */
1478 } /* }}} int cna_submit_volume_usage_data */
1480 /* Switch the state of a volume between online and offline and send out a
1482 static int cna_change_volume_status(const char *hostname, /* {{{ */
1483 data_volume_usage_t *v) {
1484 notification_t n = {0};
1487 sstrncpy(n.host, hostname, sizeof(n.host));
1488 sstrncpy(n.plugin, "netapp", sizeof(n.plugin));
1489 sstrncpy(n.plugin_instance, v->name, sizeof(n.plugin_instance));
1491 if ((v->flags & IS_VOLUME_USAGE_OFFLINE) != 0) {
1492 n.severity = NOTIF_OKAY;
1493 ssnprintf(n.message, sizeof(n.message), "Volume %s is now online.",
1495 v->flags &= ~IS_VOLUME_USAGE_OFFLINE;
1497 n.severity = NOTIF_WARNING;
1498 ssnprintf(n.message, sizeof(n.message), "Volume %s is now offline.",
1500 v->flags |= IS_VOLUME_USAGE_OFFLINE;
1503 return plugin_dispatch_notification(&n);
1504 } /* }}} int cna_change_volume_status */
1506 static void cna_handle_volume_snap_usage(const host_config_t *host, /* {{{ */
1507 data_volume_usage_t *v) {
1508 uint64_t snap_used = 0, value;
1509 na_elem_t *data, *elem_snapshots;
1510 na_elem_iter_t iter_snap;
1512 data = na_server_invoke_elem(host->srv, v->snap_query);
1513 if (na_results_status(data) != NA_OK) {
1514 if (na_results_errno(data) == EVOLUMEOFFLINE) {
1515 if ((v->flags & IS_VOLUME_USAGE_OFFLINE) == 0)
1516 cna_change_volume_status(host->name, v);
1518 ERROR("netapp plugin: cna_handle_volume_snap_usage: "
1519 "na_server_invoke_elem for "
1520 "volume \"%s\" on host %s failed with error %d: %s",
1521 v->name, host->name, na_results_errno(data),
1522 na_results_reason(data));
1528 if ((v->flags & IS_VOLUME_USAGE_OFFLINE) != 0)
1529 cna_change_volume_status(host->name, v);
1531 elem_snapshots = na_elem_child(data, "snapshots");
1532 if (elem_snapshots == NULL) {
1533 ERROR("netapp plugin: cna_handle_volume_snap_usage: "
1534 "na_elem_child (\"snapshots\") failed "
1541 iter_snap = na_child_iterator(elem_snapshots);
1542 for (na_elem_t *elem_snap = na_iterator_next(&iter_snap); elem_snap != NULL;
1543 elem_snap = na_iterator_next(&iter_snap)) {
1544 value = na_child_get_uint64(elem_snap, "cumulative-total", 0);
1545 /* "cumulative-total" is the total size of the oldest snapshot plus all
1546 * newer ones in blocks (1KB). We therefore are looking for the highest
1547 * number of all snapshots - that's the size required for the snapshots. */
1548 if (value > snap_used)
1552 /* snap_used is in 1024 byte blocks */
1553 v->snap_used = snap_used * 1024;
1554 v->flags |= HAVE_VOLUME_USAGE_SNAP_USED;
1555 } /* }}} void cna_handle_volume_snap_usage */
1557 static void cna_handle_volume_sis_data(const host_config_t *host, /* {{{ */
1558 data_volume_usage_t *v, na_elem_t *sis) {
1559 const char *sis_state;
1560 uint64_t sis_saved_reported;
1562 if (na_elem_child(sis, "sis-info"))
1563 sis = na_elem_child(sis, "sis-info");
1565 sis_state = na_child_get_string(sis, "state");
1566 if (sis_state == NULL)
1569 /* If SIS is not enabled, there's nothing left to do for this volume. */
1570 if (strcmp("enabled", sis_state) != 0)
1573 sis_saved_reported = na_child_get_uint64(sis, "size-saved", UINT64_MAX);
1574 if (sis_saved_reported == UINT64_MAX)
1577 /* size-saved is actually a 32 bit number, so ... time for some guesswork. */
1578 if ((sis_saved_reported >> 32) != 0) {
1579 /* In case they ever fix this bug. */
1580 v->sis_saved = sis_saved_reported;
1581 v->flags |= HAVE_VOLUME_USAGE_SIS_SAVED;
1582 } else { /* really hacky work-around code. {{{ */
1583 uint64_t sis_saved_percent;
1584 uint64_t sis_saved_guess;
1585 uint64_t overflow_guess;
1586 uint64_t guess1, guess2, guess3;
1588 /* Check if we have v->norm_used. Without it, we cannot calculate
1589 * sis_saved_guess. */
1590 if ((v->flags & HAVE_VOLUME_USAGE_NORM_USED) == 0)
1594 na_child_get_uint64(sis, "percentage-saved", UINT64_MAX);
1595 if (sis_saved_percent > 100)
1598 /* The "size-saved" value is a 32bit unsigned integer. This is a bug and
1599 * will hopefully be fixed in later versions. To work around the bug, try
1600 * to figure out how often the 32bit integer wrapped around by using the
1601 * "percentage-saved" value. Because the percentage is in the range
1602 * [0-100], this should work as long as the saved space does not exceed
1604 /* percentage-saved = size-saved / (size-saved + size-used) */
1605 if (sis_saved_percent < 100)
1607 v->norm_used * sis_saved_percent / (100 - sis_saved_percent);
1609 sis_saved_guess = v->norm_used;
1611 overflow_guess = sis_saved_guess >> 32;
1612 guess1 = overflow_guess ? ((overflow_guess - 1) << 32) + sis_saved_reported
1613 : sis_saved_reported;
1614 guess2 = (overflow_guess << 32) + sis_saved_reported;
1615 guess3 = ((overflow_guess + 1) << 32) + sis_saved_reported;
1617 if (sis_saved_guess < guess2) {
1618 if ((sis_saved_guess - guess1) < (guess2 - sis_saved_guess))
1619 v->sis_saved = guess1;
1621 v->sis_saved = guess2;
1623 if ((sis_saved_guess - guess2) < (guess3 - sis_saved_guess))
1624 v->sis_saved = guess2;
1626 v->sis_saved = guess3;
1628 v->flags |= HAVE_VOLUME_USAGE_SIS_SAVED;
1629 } /* }}} end of 32-bit workaround */
1630 } /* }}} void cna_handle_volume_sis_data */
1632 /* ONTAP >= 8.1 uses SIS for managing dedup and compression */
1633 static void cna_handle_volume_sis_saved(const host_config_t *host, /* {{{ */
1634 data_volume_usage_t *v,
1638 if (na_elem_child(sis, "sis-info"))
1639 sis = na_elem_child(sis, "sis-info");
1641 saved = na_child_get_uint64(sis, "compress-saved", UINT64_MAX);
1642 if (saved != UINT64_MAX) {
1643 v->compress_saved = saved;
1644 v->flags |= HAVE_VOLUME_USAGE_COMPRESS_SAVED;
1647 saved = na_child_get_uint64(sis, "dedup-saved", UINT64_MAX);
1648 if (saved != UINT64_MAX) {
1649 v->dedup_saved = saved;
1650 v->flags |= HAVE_VOLUME_USAGE_DEDUP_SAVED;
1652 } /* }}} void cna_handle_volume_sis_saved */
1654 static int cna_handle_volume_usage_data(const host_config_t *host, /* {{{ */
1655 cfg_volume_usage_t *cfg_volume,
1657 na_elem_t *elem_volumes;
1658 na_elem_iter_t iter_volume;
1660 elem_volumes = na_elem_child(data, "volumes");
1661 if (elem_volumes == NULL) {
1662 ERROR("netapp plugin: cna_handle_volume_usage_data: "
1663 "na_elem_child (\"volumes\") failed "
1669 iter_volume = na_child_iterator(elem_volumes);
1670 for (na_elem_t *elem_volume = na_iterator_next(&iter_volume);
1671 elem_volume != NULL; elem_volume = na_iterator_next(&iter_volume)) {
1672 const char *volume_name, *state;
1674 data_volume_usage_t *v;
1679 volume_name = na_child_get_string(elem_volume, "name");
1680 if (volume_name == NULL)
1683 state = na_child_get_string(elem_volume, "state");
1684 if ((state == NULL) || (strcmp(state, "online") != 0))
1687 /* get_volume_usage may return NULL if the volume is to be ignored. */
1688 v = get_volume_usage(cfg_volume, volume_name);
1692 if ((v->flags & CFG_VOLUME_USAGE_SNAP) != 0)
1693 cna_handle_volume_snap_usage(host, v);
1695 if ((v->flags & CFG_VOLUME_USAGE_DF) == 0)
1698 /* 2^4 exa-bytes? This will take a while ;) */
1699 value = na_child_get_uint64(elem_volume, "size-available", UINT64_MAX);
1700 if (value != UINT64_MAX) {
1701 v->norm_free = value;
1702 v->flags |= HAVE_VOLUME_USAGE_NORM_FREE;
1705 value = na_child_get_uint64(elem_volume, "size-used", UINT64_MAX);
1706 if (value != UINT64_MAX) {
1707 v->norm_used = value;
1708 v->flags |= HAVE_VOLUME_USAGE_NORM_USED;
1711 value = na_child_get_uint64(elem_volume, "snapshot-blocks-reserved",
1713 if (value != UINT64_MAX) {
1714 /* 1 block == 1024 bytes as per API docs */
1715 v->snap_reserved = 1024 * value;
1716 v->flags |= HAVE_VOLUME_USAGE_SNAP_RSVD;
1719 sis = na_elem_child(elem_volume, "sis");
1721 cna_handle_volume_sis_data(host, v, sis);
1722 cna_handle_volume_sis_saved(host, v, sis);
1724 } /* for (elem_volume) */
1726 return cna_submit_volume_usage_data(host->name, cfg_volume,
1727 host->cfg_volume_usage->interval.interval);
1728 } /* }}} int cna_handle_volume_usage_data */
1730 static int cna_setup_volume_usage(cfg_volume_usage_t *cvu) /* {{{ */
1735 if (cvu->query != NULL)
1738 cvu->query = na_elem_new("volume-list-info");
1739 if (cvu->query == NULL) {
1740 ERROR("netapp plugin: na_elem_new failed.");
1745 } /* }}} int cna_setup_volume_usage */
1747 static int cna_query_volume_usage(host_config_t *host) /* {{{ */
1756 /* If the user did not configure volume_usage statistics, return without
1757 * doing anything. */
1758 if (host->cfg_volume_usage == NULL)
1762 if ((host->cfg_volume_usage->interval.interval +
1763 host->cfg_volume_usage->interval.last_read) > now)
1766 status = cna_setup_volume_usage(host->cfg_volume_usage);
1769 assert(host->cfg_volume_usage->query != NULL);
1771 data = na_server_invoke_elem(host->srv, host->cfg_volume_usage->query);
1772 if (na_results_status(data) != NA_OK) {
1773 ERROR("netapp plugin: cna_query_volume_usage: na_server_invoke_elem failed "
1775 host->name, na_results_reason(data));
1780 status = cna_handle_volume_usage_data(host, host->cfg_volume_usage, data);
1783 host->cfg_volume_usage->interval.last_read = now;
1787 } /* }}} int cna_query_volume_usage */
1789 /* Data corresponding to <Quota /> */
1790 static int cna_handle_quota_data(const host_config_t *host, /* {{{ */
1791 cfg_quota_t *cfg_quota, na_elem_t *data) {
1792 na_elem_t *elem_quotas;
1793 na_elem_iter_t iter_quota;
1795 elem_quotas = na_elem_child(data, "quotas");
1796 if (elem_quotas == NULL) {
1797 ERROR("netapp plugin: cna_handle_quota_data: "
1798 "na_elem_child (\"quotas\") failed "
1804 iter_quota = na_child_iterator(elem_quotas);
1805 for (na_elem_t *elem_quota = na_iterator_next(&iter_quota);
1806 elem_quota != NULL; elem_quota = na_iterator_next(&iter_quota)) {
1807 const char *quota_type, *volume_name, *tree_name;
1810 char plugin_instance[DATA_MAX_NAME_LEN];
1812 quota_type = na_child_get_string(elem_quota, "quota-type");
1813 if (quota_type == NULL)
1816 /* possible TODO: support other types as well */
1817 if (strcmp(quota_type, "tree") != 0)
1820 tree_name = na_child_get_string(elem_quota, "tree");
1821 if ((tree_name == NULL) || (*tree_name == '\0'))
1824 volume_name = na_child_get_string(elem_quota, "volume");
1825 if (volume_name == NULL)
1828 ssnprintf(plugin_instance, sizeof(plugin_instance), "quota-%s-%s",
1829 volume_name, tree_name);
1831 value = na_child_get_uint64(elem_quota, "disk-used", UINT64_MAX);
1832 if (value != UINT64_MAX) {
1833 value *= 1024; /* disk-used reports kilobytes */
1834 submit_double(host->name, plugin_instance,
1835 /* type = */ "df_complex", /* type instance = */ NULL,
1836 (double)value, /* timestamp = */ 0,
1837 host->cfg_quota->interval.interval);
1840 value = na_child_get_uint64(elem_quota, "files-used", UINT64_MAX);
1841 if (value != UINT64_MAX) {
1842 submit_double(host->name, plugin_instance,
1843 /* type = */ "files", /* type instance = */ NULL,
1844 (double)value, /* timestamp = */ 0,
1845 host->cfg_quota->interval.interval);
1847 } /* for (elem_quota) */
1850 } /* }}} int cna_handle_volume_usage_data */
1852 static int cna_setup_quota(cfg_quota_t *cq) /* {{{ */
1857 if (cq->query != NULL)
1860 cq->query = na_elem_new("quota-report");
1861 if (cq->query == NULL) {
1862 ERROR("netapp plugin: na_elem_new failed.");
1867 } /* }}} int cna_setup_quota */
1869 static int cna_query_quota(host_config_t *host) /* {{{ */
1878 /* If the user did not configure quota statistics, return without
1879 * doing anything. */
1880 if (host->cfg_quota == NULL)
1884 if ((host->cfg_quota->interval.interval +
1885 host->cfg_quota->interval.last_read) > now)
1888 status = cna_setup_quota(host->cfg_quota);
1891 assert(host->cfg_quota->query != NULL);
1893 data = na_server_invoke_elem(host->srv, host->cfg_quota->query);
1894 if (na_results_status(data) != NA_OK) {
1895 ERROR("netapp plugin: cna_query_quota: na_server_invoke_elem failed for "
1897 host->name, na_results_reason(data));
1902 status = cna_handle_quota_data(host, host->cfg_quota, data);
1905 host->cfg_quota->interval.last_read = now;
1909 } /* }}} int cna_query_quota */
1911 /* Data corresponding to <SnapVault /> */
1912 static int cna_handle_snapvault_data(const char *hostname, /* {{{ */
1913 cfg_snapvault_t *cfg_snapvault,
1914 na_elem_t *data, cdtime_t interval) {
1915 na_elem_t *status_list = na_elem_child(data, "status-list");
1916 if (status_list == NULL) {
1917 ERROR("netapp plugin: SnapVault status record missing status-list");
1921 na_elem_iter_t status_iter = na_child_iterator(status_list);
1922 for (na_elem_t *status = na_iterator_next(&status_iter); status != NULL;
1923 status = na_iterator_next(&status_iter)) {
1924 const char *dest_sys, *dest_path, *src_sys, *src_path;
1925 char plugin_instance[DATA_MAX_NAME_LEN];
1928 dest_sys = na_child_get_string(status, "destination-system");
1929 dest_path = na_child_get_string(status, "destination-path");
1930 src_sys = na_child_get_string(status, "source-system");
1931 src_path = na_child_get_string(status, "source-path");
1933 if ((!dest_sys) || (!dest_path) || (!src_sys) || (!src_path))
1936 value = na_child_get_uint64(status, "lag-time", UINT64_MAX);
1937 if (value == UINT64_MAX) /* no successful baseline transfer yet */
1940 /* possible TODO: make plugin instance configurable */
1941 ssnprintf(plugin_instance, sizeof(plugin_instance), "snapvault-%s",
1943 submit_double(hostname, plugin_instance, /* type = */ "delay", NULL,
1944 (double)value, /* timestamp = */ 0, interval);
1946 value = na_child_get_uint64(status, "last-transfer-duration", UINT64_MAX);
1947 if (value != UINT64_MAX)
1948 submit_double(hostname, plugin_instance, /* type = */ "duration",
1949 "last_transfer", (double)value, /* timestamp = */ 0,
1952 value = na_child_get_uint64(status, "transfer-progress", UINT64_MAX);
1953 if (value == UINT64_MAX)
1954 value = na_child_get_uint64(status, "last-transfer-size", UINT64_MAX);
1955 if (value != UINT64_MAX) {
1956 value *= 1024; /* this is kilobytes */
1957 submit_derive(hostname, plugin_instance, /* type = */ "if_rx_octets",
1958 "transferred", value, /* timestamp = */ 0, interval);
1960 } /* for (status) */
1963 } /* }}} int cna_handle_snapvault_data */
1965 static int cna_handle_snapvault_iter(host_config_t *host, /* {{{ */
1969 uint32_t records_count;
1971 records_count = na_child_get_uint32(data, "records", UINT32_MAX);
1972 if (records_count == UINT32_MAX)
1975 tag = na_child_get_string(data, "tag");
1979 DEBUG("netapp plugin: Iterating %u SV records (tag = %s)", records_count,
1982 for (uint32_t i = 0; i < records_count; ++i) {
1985 elem = na_server_invoke(
1986 host->srv, "snapvault-secondary-relationship-status-list-iter-next",
1987 "maximum", "1", "tag", tag, NULL);
1989 if (na_results_status(elem) != NA_OK) {
1990 ERROR("netapp plugin: cna_handle_snapvault_iter: "
1991 "na_server_invoke failed for host %s: %s",
1992 host->name, na_results_reason(data));
1997 cna_handle_snapvault_data(host->name, host->cfg_snapvault, elem,
1998 host->cfg_snapvault->interval.interval);
2002 na_elem_free(na_server_invoke(
2003 host->srv, "snapvault-secondary-relationship-status-list-iter-end", "tag",
2006 } /* }}} int cna_handle_snapvault_iter */
2008 static int cna_setup_snapvault(cfg_snapvault_t *sv) /* {{{ */
2013 if (sv->query != NULL)
2017 na_elem_new("snapvault-secondary-relationship-status-list-iter-start");
2018 if (sv->query == NULL) {
2019 ERROR("netapp plugin: na_elem_new failed.");
2024 } /* }}} int cna_setup_snapvault */
2026 static int cna_query_snapvault(host_config_t *host) /* {{{ */
2035 if (host->cfg_snapvault == NULL)
2039 if ((host->cfg_snapvault->interval.interval +
2040 host->cfg_snapvault->interval.last_read) > now)
2043 status = cna_setup_snapvault(host->cfg_snapvault);
2046 assert(host->cfg_snapvault->query != NULL);
2048 data = na_server_invoke_elem(host->srv, host->cfg_snapvault->query);
2049 if (na_results_status(data) != NA_OK) {
2050 ERROR("netapp plugin: cna_query_snapvault: na_server_invoke_elem failed "
2052 host->name, na_results_reason(data));
2057 status = cna_handle_snapvault_iter(host, data);
2060 host->cfg_snapvault->interval.last_read = now;
2064 } /* }}} int cna_query_snapvault */
2066 /* Data corresponding to <System /> */
2067 static int cna_handle_system_data(const char *hostname, /* {{{ */
2068 cfg_system_t *cfg_system, na_elem_t *data,
2070 na_elem_t *instances;
2071 na_elem_iter_t counter_iter;
2073 derive_t disk_read = 0, disk_written = 0;
2074 derive_t net_recv = 0, net_sent = 0;
2075 derive_t cpu_busy = 0, cpu_total = 0;
2076 uint32_t counter_flags = 0;
2078 const char *instance;
2081 timestamp = cna_child_get_cdtime(data);
2083 instances = na_elem_child(na_elem_child(data, "instances"), "instance-data");
2084 if (instances == NULL) {
2085 ERROR("netapp plugin: cna_handle_system_data: "
2086 "na_elem_child (\"instances\") failed "
2092 instance = na_child_get_string(instances, "name");
2093 if (instance == NULL) {
2094 ERROR("netapp plugin: cna_handle_system_data: "
2095 "na_child_get_string (\"name\") failed "
2101 counter_iter = na_child_iterator(na_elem_child(instances, "counters"));
2102 for (na_elem_t *counter = na_iterator_next(&counter_iter); counter != NULL;
2103 counter = na_iterator_next(&counter_iter)) {
2107 name = na_child_get_string(counter, "name");
2111 value = na_child_get_uint64(counter, "value", UINT64_MAX);
2112 if (value == UINT64_MAX)
2115 if (!strcmp(name, "disk_data_read")) {
2116 disk_read = (derive_t)(value * 1024);
2117 counter_flags |= 0x01;
2118 } else if (!strcmp(name, "disk_data_written")) {
2119 disk_written = (derive_t)(value * 1024);
2120 counter_flags |= 0x02;
2121 } else if (!strcmp(name, "net_data_recv")) {
2122 net_recv = (derive_t)(value * 1024);
2123 counter_flags |= 0x04;
2124 } else if (!strcmp(name, "net_data_sent")) {
2125 net_sent = (derive_t)(value * 1024);
2126 counter_flags |= 0x08;
2127 } else if (!strcmp(name, "cpu_busy")) {
2128 cpu_busy = (derive_t)value;
2129 counter_flags |= 0x10;
2130 } else if (!strcmp(name, "cpu_elapsed_time")) {
2131 cpu_total = (derive_t)value;
2132 counter_flags |= 0x20;
2133 } else if ((cfg_system->flags & CFG_SYSTEM_OPS) && (value > 0) &&
2134 (strlen(name) > 4) &&
2135 (!strcmp(name + strlen(name) - 4, "_ops"))) {
2136 submit_derive(hostname, instance, "disk_ops_complex", name,
2137 (derive_t)value, timestamp, interval);
2139 } /* for (counter) */
2141 if ((cfg_system->flags & CFG_SYSTEM_DISK) &&
2142 (HAS_ALL_FLAGS(counter_flags, 0x01 | 0x02)))
2143 submit_two_derive(hostname, instance, "disk_octets", NULL, disk_read,
2144 disk_written, timestamp, interval);
2146 if ((cfg_system->flags & CFG_SYSTEM_NET) &&
2147 (HAS_ALL_FLAGS(counter_flags, 0x04 | 0x08)))
2148 submit_two_derive(hostname, instance, "if_octets", NULL, net_recv, net_sent,
2149 timestamp, interval);
2151 if ((cfg_system->flags & CFG_SYSTEM_CPU) &&
2152 (HAS_ALL_FLAGS(counter_flags, 0x10 | 0x20))) {
2153 submit_derive(hostname, instance, "cpu", "system", cpu_busy, timestamp,
2155 submit_derive(hostname, instance, "cpu", "idle", cpu_total - cpu_busy,
2156 timestamp, interval);
2160 } /* }}} int cna_handle_system_data */
2162 static int cna_setup_system(cfg_system_t *cs) /* {{{ */
2167 if (cs->query != NULL)
2170 cs->query = na_elem_new("perf-object-get-instances");
2171 if (cs->query == NULL) {
2172 ERROR("netapp plugin: na_elem_new failed.");
2175 na_child_add_string(cs->query, "objectname", "system");
2178 } /* }}} int cna_setup_system */
2180 static int cna_query_system(host_config_t *host) /* {{{ */
2189 /* If system statistics were not configured, return without doing anything. */
2190 if (host->cfg_system == NULL)
2194 if ((host->cfg_system->interval.interval +
2195 host->cfg_system->interval.last_read) > now)
2198 status = cna_setup_system(host->cfg_system);
2201 assert(host->cfg_system->query != NULL);
2203 data = na_server_invoke_elem(host->srv, host->cfg_system->query);
2204 if (na_results_status(data) != NA_OK) {
2205 ERROR("netapp plugin: cna_query_system: na_server_invoke_elem failed for "
2207 host->name, na_results_reason(data));
2212 status = cna_handle_system_data(host->name, host->cfg_system, data,
2213 host->cfg_system->interval.interval);
2216 host->cfg_system->interval.last_read = now;
2220 } /* }}} int cna_query_system */
2223 * Configuration handling
2225 /* Sets a given flag if the boolean argument is true and unsets the flag if it
2226 * is false. On error, the flag-field is not changed. */
2227 static int cna_config_bool_to_flag(const oconfig_item_t *ci, /* {{{ */
2228 uint32_t *flags, uint32_t flag) {
2229 if ((ci == NULL) || (flags == NULL))
2232 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
2233 WARNING("netapp plugin: The %s option needs exactly one boolean argument.",
2238 if (ci->values[0].value.boolean)
2244 } /* }}} int cna_config_bool_to_flag */
2246 /* Handling of the "Interval" option which is allowed in every block. */
2247 static int cna_config_get_interval(const oconfig_item_t *ci, /* {{{ */
2248 cna_interval_t *out_interval) {
2252 status = cf_util_get_cdtime(ci, &tmp);
2256 out_interval->interval = tmp;
2257 out_interval->last_read = 0;
2260 } /* }}} int cna_config_get_interval */
2262 /* Handling of the "GetIO", "GetOps" and "GetLatency" options within a
2263 * <VolumePerf /> block. */
2264 static void cna_config_volume_perf_option(cfg_volume_perf_t *cvp, /* {{{ */
2265 const oconfig_item_t *ci) {
2269 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2271 "netapp plugin: The %s option requires exactly one string argument.",
2276 name = ci->values[0].value.string;
2278 if (strcasecmp("GetIO", ci->key) == 0)
2279 il = cvp->il_octets;
2280 else if (strcasecmp("GetOps", ci->key) == 0)
2281 il = cvp->il_operations;
2282 else if (strcasecmp("GetLatency", ci->key) == 0)
2283 il = cvp->il_latency;
2287 ignorelist_add(il, name);
2288 } /* }}} void cna_config_volume_perf_option */
2290 /* Handling of the "IgnoreSelectedIO", "IgnoreSelectedOps" and
2291 * "IgnoreSelectedLatency" options within a <VolumePerf /> block. */
2292 static void cna_config_volume_perf_default(cfg_volume_perf_t *cvp, /* {{{ */
2293 const oconfig_item_t *ci) {
2296 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
2298 "netapp plugin: The %s option requires exactly one string argument.",
2303 if (strcasecmp("IgnoreSelectedIO", ci->key) == 0)
2304 il = cvp->il_octets;
2305 else if (strcasecmp("IgnoreSelectedOps", ci->key) == 0)
2306 il = cvp->il_operations;
2307 else if (strcasecmp("IgnoreSelectedLatency", ci->key) == 0)
2308 il = cvp->il_latency;
2312 if (ci->values[0].value.boolean)
2313 ignorelist_set_invert(il, /* invert = */ 0);
2315 ignorelist_set_invert(il, /* invert = */ 1);
2316 } /* }}} void cna_config_volume_perf_default */
2318 /* Corresponds to a <Disks /> block */
2323 * IgnoreSelectedIO false
2327 * IgnoreSelectedOps false
2331 * IgnoreSelectedLatency false
2334 /* Corresponds to a <VolumePerf /> block */
2335 static int cna_config_volume_performance(host_config_t *host, /* {{{ */
2336 const oconfig_item_t *ci) {
2337 cfg_volume_perf_t *cfg_volume_perf;
2339 if ((host == NULL) || (ci == NULL))
2342 if (host->cfg_volume_perf == NULL) {
2343 cfg_volume_perf = calloc(1, sizeof(*cfg_volume_perf));
2344 if (cfg_volume_perf == NULL)
2347 /* Set default flags */
2348 cfg_volume_perf->query = NULL;
2349 cfg_volume_perf->volumes = NULL;
2351 cfg_volume_perf->il_octets = ignorelist_create(/* invert = */ 1);
2352 if (cfg_volume_perf->il_octets == NULL) {
2353 sfree(cfg_volume_perf);
2357 cfg_volume_perf->il_operations = ignorelist_create(/* invert = */ 1);
2358 if (cfg_volume_perf->il_operations == NULL) {
2359 ignorelist_free(cfg_volume_perf->il_octets);
2360 sfree(cfg_volume_perf);
2364 cfg_volume_perf->il_latency = ignorelist_create(/* invert = */ 1);
2365 if (cfg_volume_perf->il_latency == NULL) {
2366 ignorelist_free(cfg_volume_perf->il_octets);
2367 ignorelist_free(cfg_volume_perf->il_operations);
2368 sfree(cfg_volume_perf);
2372 host->cfg_volume_perf = cfg_volume_perf;
2374 cfg_volume_perf = host->cfg_volume_perf;
2376 for (int i = 0; i < ci->children_num; ++i) {
2377 oconfig_item_t *item = ci->children + i;
2379 /* if (!item || !item->key || !*item->key) continue; */
2380 if (strcasecmp(item->key, "Interval") == 0)
2381 cna_config_get_interval(item, &cfg_volume_perf->interval);
2382 else if (!strcasecmp(item->key, "GetIO"))
2383 cna_config_volume_perf_option(cfg_volume_perf, item);
2384 else if (!strcasecmp(item->key, "GetOps"))
2385 cna_config_volume_perf_option(cfg_volume_perf, item);
2386 else if (!strcasecmp(item->key, "GetLatency"))
2387 cna_config_volume_perf_option(cfg_volume_perf, item);
2388 else if (!strcasecmp(item->key, "IgnoreSelectedIO"))
2389 cna_config_volume_perf_default(cfg_volume_perf, item);
2390 else if (!strcasecmp(item->key, "IgnoreSelectedOps"))
2391 cna_config_volume_perf_default(cfg_volume_perf, item);
2392 else if (!strcasecmp(item->key, "IgnoreSelectedLatency"))
2393 cna_config_volume_perf_default(cfg_volume_perf, item);
2395 WARNING("netapp plugin: The option %s is not allowed within "
2396 "`VolumePerf' blocks.",
2401 } /* }}} int cna_config_volume_performance */
2403 /* Handling of the "GetCapacity" and "GetSnapshot" options within a
2404 * <VolumeUsage /> block. */
2405 static void cna_config_volume_usage_option(cfg_volume_usage_t *cvu, /* {{{ */
2406 const oconfig_item_t *ci) {
2410 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2412 "netapp plugin: The %s option requires exactly one string argument.",
2417 name = ci->values[0].value.string;
2419 if (strcasecmp("GetCapacity", ci->key) == 0)
2420 il = cvu->il_capacity;
2421 else if (strcasecmp("GetSnapshot", ci->key) == 0)
2422 il = cvu->il_snapshot;
2426 ignorelist_add(il, name);
2427 } /* }}} void cna_config_volume_usage_option */
2429 /* Handling of the "IgnoreSelectedCapacity" and "IgnoreSelectedSnapshot"
2430 * options within a <VolumeUsage /> block. */
2431 static void cna_config_volume_usage_default(cfg_volume_usage_t *cvu, /* {{{ */
2432 const oconfig_item_t *ci) {
2435 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN)) {
2437 "netapp plugin: The %s option requires exactly one string argument.",
2442 if (strcasecmp("IgnoreSelectedCapacity", ci->key) == 0)
2443 il = cvu->il_capacity;
2444 else if (strcasecmp("IgnoreSelectedSnapshot", ci->key) == 0)
2445 il = cvu->il_snapshot;
2449 if (ci->values[0].value.boolean)
2450 ignorelist_set_invert(il, /* invert = */ 0);
2452 ignorelist_set_invert(il, /* invert = */ 1);
2453 } /* }}} void cna_config_volume_usage_default */
2455 /* Corresponds to a <Quota /> block */
2456 static int cna_config_quota(host_config_t *host, oconfig_item_t *ci) /* {{{ */
2458 cfg_quota_t *cfg_quota;
2460 if ((host == NULL) || (ci == NULL))
2463 if (host->cfg_quota == NULL) {
2464 cfg_quota = calloc(1, sizeof(*cfg_quota));
2465 if (cfg_quota == NULL)
2467 cfg_quota->query = NULL;
2469 host->cfg_quota = cfg_quota;
2471 cfg_quota = host->cfg_quota;
2473 for (int i = 0; i < ci->children_num; ++i) {
2474 oconfig_item_t *item = ci->children + i;
2476 if (strcasecmp(item->key, "Interval") == 0)
2477 cna_config_get_interval(item, &cfg_quota->interval);
2479 WARNING("netapp plugin: The option %s is not allowed within "
2485 } /* }}} int cna_config_quota */
2487 /* Corresponds to a <Disks /> block */
2488 static int cna_config_disk(host_config_t *host, oconfig_item_t *ci) { /* {{{ */
2489 cfg_disk_t *cfg_disk;
2491 if ((host == NULL) || (ci == NULL))
2494 if (host->cfg_disk == NULL) {
2495 cfg_disk = calloc(1, sizeof(*cfg_disk));
2496 if (cfg_disk == NULL)
2499 /* Set default flags */
2500 cfg_disk->flags = CFG_DISK_ALL;
2501 cfg_disk->query = NULL;
2502 cfg_disk->disks = NULL;
2504 host->cfg_disk = cfg_disk;
2506 cfg_disk = host->cfg_disk;
2508 for (int i = 0; i < ci->children_num; ++i) {
2509 oconfig_item_t *item = ci->children + i;
2511 /* if (!item || !item->key || !*item->key) continue; */
2512 if (strcasecmp(item->key, "Interval") == 0)
2513 cna_config_get_interval(item, &cfg_disk->interval);
2514 else if (strcasecmp(item->key, "GetBusy") == 0)
2515 cna_config_bool_to_flag(item, &cfg_disk->flags, CFG_DISK_BUSIEST);
2518 if ((cfg_disk->flags & CFG_DISK_ALL) == 0) {
2519 NOTICE("netapp plugin: All disk related values have been disabled. "
2520 "Collection of per-disk data will be disabled entirely.");
2521 free_cfg_disk(host->cfg_disk);
2522 host->cfg_disk = NULL;
2526 } /* }}} int cna_config_disk */
2528 /* Corresponds to a <WAFL /> block */
2529 static int cna_config_wafl(host_config_t *host, oconfig_item_t *ci) /* {{{ */
2531 cfg_wafl_t *cfg_wafl;
2533 if ((host == NULL) || (ci == NULL))
2536 if (host->cfg_wafl == NULL) {
2537 cfg_wafl = calloc(1, sizeof(*cfg_wafl));
2538 if (cfg_wafl == NULL)
2541 /* Set default flags */
2542 cfg_wafl->flags = CFG_WAFL_ALL;
2544 host->cfg_wafl = cfg_wafl;
2546 cfg_wafl = host->cfg_wafl;
2548 for (int i = 0; i < ci->children_num; ++i) {
2549 oconfig_item_t *item = ci->children + i;
2551 if (strcasecmp(item->key, "Interval") == 0)
2552 cna_config_get_interval(item, &cfg_wafl->interval);
2553 else if (!strcasecmp(item->key, "GetNameCache"))
2554 cna_config_bool_to_flag(item, &cfg_wafl->flags, CFG_WAFL_NAME_CACHE);
2555 else if (!strcasecmp(item->key, "GetDirCache"))
2556 cna_config_bool_to_flag(item, &cfg_wafl->flags, CFG_WAFL_DIR_CACHE);
2557 else if (!strcasecmp(item->key, "GetBufferCache"))
2558 cna_config_bool_to_flag(item, &cfg_wafl->flags, CFG_WAFL_BUF_CACHE);
2559 else if (!strcasecmp(item->key, "GetInodeCache"))
2560 cna_config_bool_to_flag(item, &cfg_wafl->flags, CFG_WAFL_INODE_CACHE);
2562 WARNING("netapp plugin: The %s config option is not allowed within "
2567 if ((cfg_wafl->flags & CFG_WAFL_ALL) == 0) {
2568 NOTICE("netapp plugin: All WAFL related values have been disabled. "
2569 "Collection of WAFL data will be disabled entirely.");
2570 free_cfg_wafl(host->cfg_wafl);
2571 host->cfg_wafl = NULL;
2575 } /* }}} int cna_config_wafl */
2579 * GetCapacity "vol0"
2580 * GetCapacity "vol1"
2581 * GetCapacity "vol2"
2582 * GetCapacity "vol3"
2583 * GetCapacity "vol4"
2584 * IgnoreSelectedCapacity false
2586 * GetSnapshot "vol0"
2587 * GetSnapshot "vol3"
2588 * GetSnapshot "vol4"
2589 * GetSnapshot "vol7"
2590 * IgnoreSelectedSnapshot false
2593 /* Corresponds to a <VolumeUsage /> block */
2594 static int cna_config_volume_usage(host_config_t *host, /* {{{ */
2595 const oconfig_item_t *ci) {
2596 cfg_volume_usage_t *cfg_volume_usage;
2598 if ((host == NULL) || (ci == NULL))
2601 if (host->cfg_volume_usage == NULL) {
2602 cfg_volume_usage = calloc(1, sizeof(*cfg_volume_usage));
2603 if (cfg_volume_usage == NULL)
2606 /* Set default flags */
2607 cfg_volume_usage->query = NULL;
2608 cfg_volume_usage->volumes = NULL;
2610 cfg_volume_usage->il_capacity = ignorelist_create(/* invert = */ 1);
2611 if (cfg_volume_usage->il_capacity == NULL) {
2612 sfree(cfg_volume_usage);
2616 cfg_volume_usage->il_snapshot = ignorelist_create(/* invert = */ 1);
2617 if (cfg_volume_usage->il_snapshot == NULL) {
2618 ignorelist_free(cfg_volume_usage->il_capacity);
2619 sfree(cfg_volume_usage);
2623 host->cfg_volume_usage = cfg_volume_usage;
2625 cfg_volume_usage = host->cfg_volume_usage;
2627 for (int i = 0; i < ci->children_num; ++i) {
2628 oconfig_item_t *item = ci->children + i;
2630 /* if (!item || !item->key || !*item->key) continue; */
2631 if (strcasecmp(item->key, "Interval") == 0)
2632 cna_config_get_interval(item, &cfg_volume_usage->interval);
2633 else if (!strcasecmp(item->key, "GetCapacity"))
2634 cna_config_volume_usage_option(cfg_volume_usage, item);
2635 else if (!strcasecmp(item->key, "GetSnapshot"))
2636 cna_config_volume_usage_option(cfg_volume_usage, item);
2637 else if (!strcasecmp(item->key, "IgnoreSelectedCapacity"))
2638 cna_config_volume_usage_default(cfg_volume_usage, item);
2639 else if (!strcasecmp(item->key, "IgnoreSelectedSnapshot"))
2640 cna_config_volume_usage_default(cfg_volume_usage, item);
2642 WARNING("netapp plugin: The option %s is not allowed within "
2643 "`VolumeUsage' blocks.",
2648 } /* }}} int cna_config_volume_usage */
2650 /* Corresponds to a <SnapVault /> block */
2651 static int cna_config_snapvault(host_config_t *host, /* {{{ */
2652 const oconfig_item_t *ci) {
2653 cfg_snapvault_t *cfg_snapvault;
2655 if ((host == NULL) || (ci == NULL))
2658 if (host->cfg_snapvault == NULL) {
2659 cfg_snapvault = calloc(1, sizeof(*cfg_snapvault));
2660 if (cfg_snapvault == NULL)
2662 cfg_snapvault->query = NULL;
2664 host->cfg_snapvault = cfg_snapvault;
2667 cfg_snapvault = host->cfg_snapvault;
2669 for (int i = 0; i < ci->children_num; ++i) {
2670 oconfig_item_t *item = ci->children + i;
2672 if (strcasecmp(item->key, "Interval") == 0)
2673 cna_config_get_interval(item, &cfg_snapvault->interval);
2675 WARNING("netapp plugin: The option %s is not allowed within "
2676 "`SnapVault' blocks.",
2681 } /* }}} int cna_config_snapvault */
2683 /* Corresponds to a <System /> block */
2684 static int cna_config_system(host_config_t *host, /* {{{ */
2685 oconfig_item_t *ci) {
2686 cfg_system_t *cfg_system;
2688 if ((host == NULL) || (ci == NULL))
2691 if (host->cfg_system == NULL) {
2692 cfg_system = calloc(1, sizeof(*cfg_system));
2693 if (cfg_system == NULL)
2696 /* Set default flags */
2697 cfg_system->flags = CFG_SYSTEM_ALL;
2698 cfg_system->query = NULL;
2700 host->cfg_system = cfg_system;
2702 cfg_system = host->cfg_system;
2704 for (int i = 0; i < ci->children_num; ++i) {
2705 oconfig_item_t *item = ci->children + i;
2707 if (strcasecmp(item->key, "Interval") == 0) {
2708 cna_config_get_interval(item, &cfg_system->interval);
2709 } else if (!strcasecmp(item->key, "GetCPULoad")) {
2710 cna_config_bool_to_flag(item, &cfg_system->flags, CFG_SYSTEM_CPU);
2711 } else if (!strcasecmp(item->key, "GetInterfaces")) {
2712 cna_config_bool_to_flag(item, &cfg_system->flags, CFG_SYSTEM_NET);
2713 } else if (!strcasecmp(item->key, "GetDiskOps")) {
2714 cna_config_bool_to_flag(item, &cfg_system->flags, CFG_SYSTEM_OPS);
2715 } else if (!strcasecmp(item->key, "GetDiskIO")) {
2716 cna_config_bool_to_flag(item, &cfg_system->flags, CFG_SYSTEM_DISK);
2718 WARNING("netapp plugin: The %s config option is not allowed within "
2724 if ((cfg_system->flags & CFG_SYSTEM_ALL) == 0) {
2725 NOTICE("netapp plugin: All system related values have been disabled. "
2726 "Collection of system data will be disabled entirely.");
2727 free_cfg_system(host->cfg_system);
2728 host->cfg_system = NULL;
2732 } /* }}} int cna_config_system */
2734 /* Corresponds to a <Host /> block. */
2735 static host_config_t *cna_alloc_host(void) /* {{{ */
2737 host_config_t *host;
2739 host = calloc(1, sizeof(*host));
2744 host->protocol = NA_SERVER_TRANSPORT_HTTPS;
2746 host->username = NULL;
2747 host->password = NULL;
2748 host->vfiler = NULL;
2750 host->cfg_wafl = NULL;
2751 host->cfg_disk = NULL;
2752 host->cfg_volume_perf = NULL;
2753 host->cfg_volume_usage = NULL;
2754 host->cfg_quota = NULL;
2755 host->cfg_snapvault = NULL;
2756 host->cfg_system = NULL;
2759 } /* }}} host_config_t *cna_alloc_host */
2761 static host_config_t *cna_shallow_clone_host(host_config_t *host) /* {{{ */
2763 host_config_t *clone;
2768 clone = cna_alloc_host();
2772 if (host->name != NULL) {
2773 clone->name = strdup(host->name);
2774 if (clone->name == NULL) {
2775 free_host_config(clone);
2780 clone->protocol = host->protocol;
2782 if (host->host != NULL) {
2783 clone->host = strdup(host->host);
2784 if (clone->host == NULL) {
2785 free_host_config(clone);
2790 clone->port = host->port;
2792 if (host->username != NULL) {
2793 clone->username = strdup(host->username);
2794 if (clone->username == NULL) {
2795 free_host_config(clone);
2799 if (host->password != NULL) {
2800 clone->password = strdup(host->password);
2801 if (clone->password == NULL) {
2802 free_host_config(clone);
2807 clone->interval = host->interval;
2810 } /* }}} host_config_t *cna_shallow_clone_host */
2812 static int cna_read(user_data_t *ud);
2814 static int cna_register_host(host_config_t *host) /* {{{ */
2819 ssnprintf(cb_name, sizeof(cb_name), "netapp-%s-%s", host->name,
2822 ssnprintf(cb_name, sizeof(cb_name), "netapp-%s", host->name);
2824 plugin_register_complex_read(
2825 /* group = */ NULL, cb_name,
2826 /* callback = */ cna_read,
2827 /* interval = */ host->interval,
2829 .data = host, .free_func = (void *)free_host_config,
2833 } /* }}} int cna_register_host */
2835 static int cna_config_host(host_config_t *host, /* {{{ */
2836 const oconfig_item_t *ci) {
2837 oconfig_item_t *item;
2838 _Bool is_vfiler = 0;
2841 if (!strcasecmp(ci->key, "VFiler"))
2844 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2845 WARNING("netapp plugin: \"%s\" needs exactly one string argument. Ignoring "
2851 status = cf_util_get_string(ci, &host->name);
2855 for (int i = 0; i < ci->children_num; ++i) {
2856 item = ci->children + i;
2860 if (!strcasecmp(item->key, "Address")) {
2861 status = cf_util_get_string(item, &host->host);
2862 } else if (!strcasecmp(item->key, "Port")) {
2865 tmp = cf_util_get_port_number(item);
2868 } else if (!strcasecmp(item->key, "Protocol")) {
2869 if ((item->values_num != 1) ||
2870 (item->values[0].type != OCONFIG_TYPE_STRING) ||
2871 (strcasecmp(item->values[0].value.string, "http") &&
2872 strcasecmp(item->values[0].value.string, "https"))) {
2873 WARNING("netapp plugin: \"Protocol\" needs to be either \"http\" or "
2874 "\"https\". Ignoring host block \"%s\".",
2875 ci->values[0].value.string);
2878 if (!strcasecmp(item->values[0].value.string, "http"))
2879 host->protocol = NA_SERVER_TRANSPORT_HTTP;
2881 host->protocol = NA_SERVER_TRANSPORT_HTTPS;
2882 } else if (!strcasecmp(item->key, "User")) {
2883 status = cf_util_get_string(item, &host->username);
2884 } else if (!strcasecmp(item->key, "Password")) {
2885 status = cf_util_get_string(item, &host->password);
2886 } else if (!strcasecmp(item->key, "Interval")) {
2887 status = cf_util_get_cdtime(item, &host->interval);
2888 } else if (!strcasecmp(item->key, "WAFL")) {
2889 cna_config_wafl(host, item);
2890 } else if (!strcasecmp(item->key, "Disks")) {
2891 cna_config_disk(host, item);
2892 } else if (!strcasecmp(item->key, "VolumePerf")) {
2893 cna_config_volume_performance(host, item);
2894 } else if (!strcasecmp(item->key, "VolumeUsage")) {
2895 cna_config_volume_usage(host, item);
2896 } else if (!strcasecmp(item->key, "Quota")) {
2897 cna_config_quota(host, item);
2898 } else if (!strcasecmp(item->key, "SnapVault")) {
2899 cna_config_snapvault(host, item);
2900 } else if (!strcasecmp(item->key, "System")) {
2901 cna_config_system(host, item);
2902 } else if ((!strcasecmp(item->key, "VFiler")) && (!is_vfiler)) {
2903 host_config_t *vfiler;
2905 vfiler = cna_shallow_clone_host(host);
2907 ERROR("netapp plugin: Failed to allocate host object for vfiler.");
2911 if (cna_config_host(vfiler, item)) {
2912 free_host_config(vfiler);
2916 cna_register_host(vfiler);
2917 } else if ((!strcasecmp(item->key, "VFilerName")) && is_vfiler) {
2918 status = cf_util_get_string(item, &host->vfiler);
2920 WARNING("netapp plugin: Ignoring unknown config option \"%s\" in %s "
2922 item->key, is_vfiler ? "vfiler" : "host",
2923 ci->values[0].value.string);
2930 if (host->host == NULL)
2931 host->host = strdup(host->name);
2933 if (is_vfiler && (!host->vfiler))
2934 host->vfiler = strdup(host->name);
2936 if (host->host == NULL)
2939 if (host->port <= 0)
2940 host->port = (host->protocol == NA_SERVER_TRANSPORT_HTTP) ? 80 : 443;
2942 if ((host->username == NULL) || (host->password == NULL)) {
2943 WARNING("netapp plugin: Please supply login information for host \"%s\". "
2944 "Ignoring host block.",
2953 } /* }}} host_config_t *cna_config_host */
2956 * Callbacks registered with the daemon
2958 * Pretty standard stuff here.
2960 static int cna_init_host(host_config_t *host) /* {{{ */
2962 /* Request version 1.1 of the ONTAP API */
2963 int major_version = 1, minor_version = 1;
2968 if (host->srv != NULL)
2971 if (host->vfiler != NULL) /* Request version 1.7 of the ONTAP API */
2974 host->srv = na_server_open(host->host, major_version, minor_version);
2975 if (host->srv == NULL) {
2976 ERROR("netapp plugin: na_server_open (%s) failed.", host->host);
2980 na_server_set_transport_type(host->srv, host->protocol,
2981 /* transportarg = */ NULL);
2982 na_server_set_port(host->srv, host->port);
2983 na_server_style(host->srv, NA_STYLE_LOGIN_PASSWORD);
2984 na_server_adminuser(host->srv, host->username, host->password);
2985 na_server_set_timeout(host->srv, 5 /* seconds */);
2987 if (host->vfiler != NULL) {
2988 if (!na_server_set_vfiler(host->srv, host->vfiler)) {
2989 ERROR("netapp plugin: Failed to connect to VFiler '%s' on host '%s'.",
2990 host->vfiler, host->host);
2993 INFO("netapp plugin: Connected to VFiler '%s' on host '%s'.",
2994 host->vfiler, host->host);
2999 } /* }}} int cna_init_host */
3001 static int cna_init(void) /* {{{ */
3003 char err[256] = {0};
3005 if (!na_startup(err, sizeof(err))) {
3006 err[sizeof(err) - 1] = 0;
3007 ERROR("netapp plugin: Error initializing netapp API: %s", err);
3012 } /* }}} cna_init */
3014 static int cna_read_internal(host_config_t *host) { /* {{{ */
3017 status = cna_query_wafl(host);
3021 status = cna_query_disk(host);
3025 status = cna_query_volume_perf(host);
3029 status = cna_query_volume_usage(host);
3033 status = cna_query_quota(host);
3037 status = cna_query_snapvault(host);
3041 status = cna_query_system(host);
3046 } /* }}} int cna_read_internal */
3048 static int cna_read(user_data_t *ud) { /* {{{ */
3049 host_config_t *host;
3052 if ((ud == NULL) || (ud->data == NULL))
3057 status = cna_init_host(host);
3061 status = cna_read_internal(host);
3063 if (host->srv != NULL)
3064 na_server_close(host->srv);
3069 } /* }}} int cna_read */
3071 static int cna_config(oconfig_item_t *ci) { /* {{{ */
3072 oconfig_item_t *item;
3074 for (int i = 0; i < ci->children_num; ++i) {
3075 item = ci->children + i;
3077 if (strcasecmp(item->key, "Host") == 0) {
3078 host_config_t *host;
3080 host = cna_alloc_host();
3082 ERROR("netapp plugin: Failed to allocate host object.");
3086 if (cna_config_host(host, item) != 0) {
3087 free_host_config(host);
3091 cna_register_host(host);
3092 } else /* if (item->key != "Host") */
3094 WARNING("netapp plugin: Ignoring unknown config option \"%s\".",
3099 } /* }}} int cna_config */
3101 static int cna_shutdown(void) /* {{{ */
3103 /* Clean up system resources and stuff. */
3107 } /* }}} int cna_shutdown */
3109 void module_register(void) {
3110 plugin_register_complex_config("netapp", cna_config);
3111 plugin_register_init("netapp", cna_init);
3112 plugin_register_shutdown("netapp", cna_shutdown);