2 * collectd - src/netapp.c
3 * Copyright (C) 2009 Sven Trenkel
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 * Sven Trenkel <collectd at semidefinite.de>
29 #include "utils_ignorelist.h"
31 #include <netapp_api.h>
33 #define HAS_ALL_FLAGS(has,needs) (((has) & (needs)) == (needs))
35 typedef struct host_config_s host_config_t;
36 typedef void service_handler_t(host_config_t *host, na_elem_t *result, void *data);
43 typedef struct cna_interval_s cna_interval_t;
45 /*! Data types for WAFL statistics {{{
47 * \brief Persistent data for WAFL performance counters. (a.k.a. cache performance)
49 * The cache counters use old counter values to calculate a hit ratio for each
50 * counter. The "cfg_wafl_t" struct therefore contains old counter values along
51 * with flags, which are set if the counter is valid.
53 * The function "cna_handle_wafl_data" will fill a new structure of this kind
54 * with new values, then pass both, new and old data, to "submit_wafl_data".
55 * That function calculates the hit ratios, submits the calculated values and
56 * updates the old counter values for the next iteration.
58 #define CFG_WAFL_NAME_CACHE 0x0001
59 #define CFG_WAFL_DIR_CACHE 0x0002
60 #define CFG_WAFL_BUF_CACHE 0x0004
61 #define CFG_WAFL_INODE_CACHE 0x0008
62 #define CFG_WAFL_ALL 0x000F
63 #define HAVE_WAFL_NAME_CACHE_HIT 0x0100
64 #define HAVE_WAFL_NAME_CACHE_MISS 0x0200
65 #define HAVE_WAFL_NAME_CACHE (HAVE_WAFL_NAME_CACHE_HIT | HAVE_WAFL_NAME_CACHE_MISS)
66 #define HAVE_WAFL_FIND_DIR_HIT 0x0400
67 #define HAVE_WAFL_FIND_DIR_MISS 0x0800
68 #define HAVE_WAFL_FIND_DIR (HAVE_WAFL_FIND_DIR_HIT | HAVE_WAFL_FIND_DIR_MISS)
69 #define HAVE_WAFL_BUF_HASH_HIT 0x1000
70 #define HAVE_WAFL_BUF_HASH_MISS 0x2000
71 #define HAVE_WAFL_BUF_HASH (HAVE_WAFL_BUF_HASH_HIT | HAVE_WAFL_BUF_HASH_MISS)
72 #define HAVE_WAFL_INODE_CACHE_HIT 0x4000
73 #define HAVE_WAFL_INODE_CACHE_MISS 0x8000
74 #define HAVE_WAFL_INODE_CACHE (HAVE_WAFL_INODE_CACHE_HIT | HAVE_WAFL_INODE_CACHE_MISS)
75 #define HAVE_WAFL_ALL 0xff00
78 cna_interval_t interval;
82 uint64_t name_cache_hit;
83 uint64_t name_cache_miss;
84 uint64_t find_dir_hit;
85 uint64_t find_dir_miss;
86 uint64_t buf_hash_hit;
87 uint64_t buf_hash_miss;
88 uint64_t inode_cache_hit;
89 uint64_t inode_cache_miss;
93 /*! Data types for disk statistics {{{
95 * \brief A disk in the NetApp.
97 * A disk doesn't have any more information than its name at the moment.
98 * The name includes the "disk_" prefix.
100 #define HAVE_DISK_BUSY 0x10
101 #define HAVE_DISK_BASE 0x20
102 #define HAVE_DISK_ALL 0x30
103 typedef struct disk_s {
108 uint64_t base_for_disk_busy;
109 double disk_busy_percent;
113 #define CFG_DISK_BUSIEST 0x01
114 #define CFG_DISK_ALL 0x01
117 cna_interval_t interval;
123 /*! Data types for volume performance statistics {{{
125 * \brief Persistent data for volume performance data.
127 * The code below uses the difference of the operations and latency counters to
128 * calculate an average per-operation latency. For this, old counters need to
129 * be stored in the "data_volume_perf_t" structure. The byte-counters are just
130 * kept for completeness sake. The "flags" member indicates if each counter is
133 * The "query_volume_perf_data" function will fill a new struct of this type
134 * and pass both, old and new data, to "submit_volume_perf_data". In that
135 * function, the per-operation latency is calculated and dispatched, then the
136 * old counters are updated.
138 #define CFG_VOLUME_PERF_INIT 0x0001
139 #define CFG_VOLUME_PERF_IO 0x0002
140 #define CFG_VOLUME_PERF_OPS 0x0003
141 #define CFG_VOLUME_PERF_LATENCY 0x0008
142 #define CFG_VOLUME_PERF_ALL 0x000F
143 #define HAVE_VOLUME_PERF_BYTES_READ 0x0010
144 #define HAVE_VOLUME_PERF_BYTES_WRITE 0x0020
145 #define HAVE_VOLUME_PERF_OPS_READ 0x0040
146 #define HAVE_VOLUME_PERF_OPS_WRITE 0x0080
147 #define HAVE_VOLUME_PERF_LATENCY_READ 0x0100
148 #define HAVE_VOLUME_PERF_LATENCY_WRITE 0x0200
149 #define HAVE_VOLUME_PERF_ALL 0x03F0
158 uint64_t write_bytes;
161 uint64_t read_latency;
162 uint64_t write_latency;
163 } data_volume_perf_t;
164 /* }}} data_volume_perf_t */
166 /*! Data types for volume usage statistics {{{
168 * \brief Configuration struct for volume usage data (free / used).
170 #define CFG_VOLUME_USAGE_DF 0x0002
171 #define CFG_VOLUME_USAGE_SNAP 0x0004
172 #define CFG_VOLUME_USAGE_ALL 0x0006
173 #define HAVE_VOLUME_USAGE_NORM_FREE 0x0010
174 #define HAVE_VOLUME_USAGE_NORM_USED 0x0020
175 #define HAVE_VOLUME_USAGE_SNAP_RSVD 0x0040
176 #define HAVE_VOLUME_USAGE_SNAP_USED 0x0080
177 #define HAVE_VOLUME_USAGE_SIS_SAVED 0x0100
178 #define HAVE_VOLUME_USAGE_ALL 0x01f0
179 struct data_volume_usage_s;
180 typedef struct data_volume_usage_s data_volume_usage_t;
181 struct data_volume_usage_s {
187 uint64_t snap_reserved;
191 data_volume_usage_t *next;
195 cna_interval_t interval;
198 ignorelist_t *il_capacity;
199 ignorelist_t *il_snapshot;
201 data_volume_usage_t *volumes;
202 } cfg_volume_usage_t;
203 /* }}} cfg_volume_usage_t */
205 /*! Data types for system statistics {{{
207 * \brief Persistent data for system performance counters
209 #define CFG_SYSTEM_CPU 0x01
210 #define CFG_SYSTEM_NET 0x02
211 #define CFG_SYSTEM_OPS 0x04
212 #define CFG_SYSTEM_DISK 0x08
213 #define CFG_SYSTEM_ALL 0x0F
216 cna_interval_t interval;
219 /* }}} cfg_system_t */
221 typedef struct service_config_s {
223 service_handler_t *handler;
228 struct service_config_s *next;
230 #define SERVICE_INIT {0, 0, 1, 1, 0, 0, 0}
233 * \brief Struct representing a volume.
235 * A volume currently has a name and two sets of values:
237 * - Performance data, such as bytes read/written, number of operations
238 * performed and average time per operation.
240 * - Usage data, i. e. amount of used and free space in the volume.
242 typedef struct volume_s {
244 data_volume_perf_t perf_data;
245 struct volume_s *next;
248 struct host_config_s {
250 na_server_transport_t protocol;
258 cfg_service_t *services;
259 cfg_wafl_t *cfg_wafl;
260 cfg_disk_t *cfg_disk;
261 cfg_volume_usage_t *cfg_volume_usage;
262 cfg_system_t *cfg_system;
265 struct host_config_s *next;
267 #define HOST_INIT { NULL, NA_SERVER_TRANSPORT_HTTPS, NULL, 0, NULL, NULL, 0, \
268 NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
271 static host_config_t *global_host_config;
276 * Used to free the various structures above.
278 static void free_volume (volume_t *volume) /* {{{ */
287 sfree (volume->name);
291 } /* }}} void free_volume */
293 static void free_disk (disk_t *disk) /* {{{ */
306 } /* }}} void free_disk */
308 static void free_cfg_wafl (cfg_wafl_t *cw) /* {{{ */
313 if (cw->query != NULL)
314 na_elem_free (cw->query);
317 } /* }}} void free_cfg_wafl */
319 static void free_cfg_disk (cfg_disk_t *cfg_disk) /* {{{ */
321 if (cfg_disk == NULL)
324 if (cfg_disk->query != NULL)
325 na_elem_free (cfg_disk->query);
327 free_disk (cfg_disk->disks);
329 } /* }}} void free_cfg_disk */
331 static void free_cfg_volume_usage (cfg_volume_usage_t *cvu) /* {{{ */
333 data_volume_usage_t *data;
338 /* Free the ignorelists */
339 ignorelist_free (cvu->il_capacity);
340 ignorelist_free (cvu->il_snapshot);
342 /* Free the linked list of volumes */
346 data_volume_usage_t *next = data->next;
352 if (cvu->query != NULL)
353 na_elem_free (cvu->query);
356 } /* }}} void free_cfg_volume_usage */
358 static void free_cfg_system (cfg_system_t *cs) /* {{{ */
363 if (cs->query != NULL)
364 na_elem_free (cs->query);
367 } /* }}} void free_cfg_system */
369 static void free_cfg_service (cfg_service_t *service) /* {{{ */
376 next = service->next;
378 /* FIXME: Free service->data? */
379 na_elem_free(service->query);
383 free_cfg_service (next);
384 } /* }}} void free_cfg_service */
386 static void free_host_config (host_config_t *hc) /* {{{ */
397 sfree (hc->username);
398 sfree (hc->password);
400 free_cfg_service (hc->services);
401 free_cfg_disk (hc->cfg_disk);
402 free_cfg_wafl (hc->cfg_wafl);
403 free_cfg_volume_usage (hc->cfg_volume_usage);
404 free_cfg_system (hc->cfg_system);
405 free_volume (hc->volumes);
409 free_host_config (next);
410 } /* }}} void free_host_config */
413 * Auxiliary functions
415 * Used to look up volumes and disks or to handle flags.
417 static volume_t *get_volume (host_config_t *host, const char *name, /* {{{ */
418 uint32_t vol_perf_flags)
425 /* Make sure the default flags include the init-bit. */
426 if (vol_perf_flags != 0)
427 vol_perf_flags |= CFG_VOLUME_PERF_INIT;
429 for (v = host->volumes; v; v = v->next) {
430 if (strcmp(v->name, name) != 0)
433 /* Check if the flags have been initialized. */
434 if (((v->perf_data.flags & CFG_VOLUME_PERF_INIT) == 0)
435 && (vol_perf_flags != 0))
436 v->perf_data.flags = vol_perf_flags;
441 DEBUG ("netapp plugin: Allocating new entry for volume %s.", name);
442 v = malloc(sizeof(*v));
445 memset (v, 0, sizeof (*v));
447 v->perf_data.flags = vol_perf_flags;
449 v->name = strdup(name);
450 if (v->name == NULL) {
455 v->next = host->volumes;
459 } /* }}} volume_t *get_volume */
461 static disk_t *get_disk(cfg_disk_t *cd, const char *name) /* {{{ */
465 if ((cd == NULL) || (name == NULL))
468 for (d = cd->disks; d != NULL; d = d->next) {
469 if (strcmp(d->name, name) == 0)
473 d = malloc(sizeof(*d));
476 memset (d, 0, sizeof (*d));
479 d->name = strdup(name);
480 if (d->name == NULL) {
489 } /* }}} disk_t *get_disk */
491 static data_volume_usage_t *get_volume_usage (cfg_volume_usage_t *cvu, /* {{{ */
494 data_volume_usage_t *last;
495 data_volume_usage_t *new;
497 int ignore_capacity = 0;
498 int ignore_snapshot = 0;
500 if ((cvu == NULL) || (name == NULL))
506 if (strcmp (last->name, name) == 0)
509 if (last->next == NULL)
515 /* Check the ignorelists. If *both* tell us to ignore a volume, return NULL. */
516 ignore_capacity = ignorelist_match (cvu->il_capacity, name);
517 ignore_snapshot = ignorelist_match (cvu->il_snapshot, name);
518 if ((ignore_capacity != 0) && (ignore_snapshot != 0))
521 /* Not found: allocate. */
522 new = malloc (sizeof (*new));
525 memset (new, 0, sizeof (*new));
528 new->name = strdup (name);
529 if (new->name == NULL)
535 if (ignore_capacity == 0)
536 new->flags |= CFG_VOLUME_USAGE_DF;
537 if (ignore_snapshot == 0)
538 new->flags |= CFG_VOLUME_USAGE_SNAP;
540 /* Add to end of list. */
547 } /* }}} data_volume_usage_t *get_volume_usage */
549 static void host_set_all_perf_data_flags(const host_config_t *host, /* {{{ */
550 uint32_t flag, _Bool set)
554 for (v = host->volumes; v; v = v->next) {
556 v->perf_data.flags |= flag;
558 v->perf_data.flags &= ~flag;
560 } /* }}} void host_set_all_perf_data_flags */
563 * Various submit functions.
565 * They all eventually call "submit_values" which creates a value_list_t and
566 * dispatches it to the daemon.
568 static int submit_values (const char *host, /* {{{ */
569 const char *plugin_inst,
570 const char *type, const char *type_inst,
571 value_t *values, int values_len,
574 value_list_t vl = VALUE_LIST_INIT;
577 vl.values_len = values_len;
583 sstrncpy (vl.host, host, sizeof (vl.host));
585 sstrncpy (vl.host, hostname_g, sizeof (vl.host));
586 sstrncpy (vl.plugin, "netapp", sizeof (vl.plugin));
587 if (plugin_inst != NULL)
588 sstrncpy (vl.plugin_instance, plugin_inst, sizeof (vl.plugin_instance));
589 sstrncpy (vl.type, type, sizeof (vl.type));
590 if (type_inst != NULL)
591 sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
593 return (plugin_dispatch_values (&vl));
594 } /* }}} int submit_uint64 */
596 static int submit_two_counters (const char *host, const char *plugin_inst, /* {{{ */
597 const char *type, const char *type_inst, counter_t val0, counter_t val1,
602 values[0].counter = val0;
603 values[1].counter = val1;
605 return (submit_values (host, plugin_inst, type, type_inst,
606 values, 2, timestamp));
607 } /* }}} int submit_two_counters */
609 static int submit_counter (const char *host, const char *plugin_inst, /* {{{ */
610 const char *type, const char *type_inst, counter_t counter, time_t timestamp)
616 return (submit_values (host, plugin_inst, type, type_inst,
618 } /* }}} int submit_counter */
620 static int submit_two_gauge (const char *host, const char *plugin_inst, /* {{{ */
621 const char *type, const char *type_inst, gauge_t val0, gauge_t val1,
626 values[0].gauge = val0;
627 values[1].gauge = val1;
629 return (submit_values (host, plugin_inst, type, type_inst,
630 values, 2, timestamp));
631 } /* }}} int submit_two_gauge */
633 static int submit_double (const char *host, const char *plugin_inst, /* {{{ */
634 const char *type, const char *type_inst, double d, time_t timestamp)
638 v.gauge = (gauge_t) d;
640 return (submit_values (host, plugin_inst, type, type_inst,
642 } /* }}} int submit_uint64 */
644 /* Calculate hit ratio from old and new counters and submit the resulting
645 * percentage. Used by "submit_wafl_data". */
646 static int submit_cache_ratio (const char *host, /* {{{ */
647 const char *plugin_inst,
648 const char *type_inst,
657 if ((new_hits >= old_hits) && (new_misses >= old_misses)) {
661 hits = new_hits - old_hits;
662 misses = new_misses - old_misses;
664 v.gauge = 100.0 * ((gauge_t) hits) / ((gauge_t) (hits + misses));
669 return (submit_values (host, plugin_inst, "cache_ratio", type_inst,
671 } /* }}} int submit_cache_ratio */
673 /* Submits all the caches used by WAFL. Uses "submit_cache_ratio". */
674 static int submit_wafl_data (const char *hostname, const char *instance, /* {{{ */
675 cfg_wafl_t *old_data, const cfg_wafl_t *new_data)
677 /* Submit requested counters */
678 if (HAS_ALL_FLAGS (old_data->flags, CFG_WAFL_NAME_CACHE | HAVE_WAFL_NAME_CACHE)
679 && HAS_ALL_FLAGS (new_data->flags, HAVE_WAFL_NAME_CACHE))
680 submit_cache_ratio (hostname, instance, "name_cache_hit",
681 new_data->name_cache_hit, new_data->name_cache_miss,
682 old_data->name_cache_hit, old_data->name_cache_miss,
683 new_data->timestamp);
685 if (HAS_ALL_FLAGS (old_data->flags, CFG_WAFL_DIR_CACHE | HAVE_WAFL_FIND_DIR)
686 && HAS_ALL_FLAGS (new_data->flags, HAVE_WAFL_FIND_DIR))
687 submit_cache_ratio (hostname, instance, "find_dir_hit",
688 new_data->find_dir_hit, new_data->find_dir_miss,
689 old_data->find_dir_hit, old_data->find_dir_miss,
690 new_data->timestamp);
692 if (HAS_ALL_FLAGS (old_data->flags, CFG_WAFL_BUF_CACHE | HAVE_WAFL_BUF_HASH)
693 && HAS_ALL_FLAGS (new_data->flags, HAVE_WAFL_BUF_HASH))
694 submit_cache_ratio (hostname, instance, "buf_hash_hit",
695 new_data->buf_hash_hit, new_data->buf_hash_miss,
696 old_data->buf_hash_hit, old_data->buf_hash_miss,
697 new_data->timestamp);
699 if (HAS_ALL_FLAGS (old_data->flags, CFG_WAFL_INODE_CACHE | HAVE_WAFL_INODE_CACHE)
700 && HAS_ALL_FLAGS (new_data->flags, HAVE_WAFL_INODE_CACHE))
701 submit_cache_ratio (hostname, instance, "inode_cache_hit",
702 new_data->inode_cache_hit, new_data->inode_cache_miss,
703 old_data->inode_cache_hit, old_data->inode_cache_miss,
704 new_data->timestamp);
706 /* Clear old HAVE_* flags */
707 old_data->flags &= ~HAVE_WAFL_ALL;
709 /* Copy all counters */
710 old_data->timestamp = new_data->timestamp;
711 old_data->name_cache_hit = new_data->name_cache_hit;
712 old_data->name_cache_miss = new_data->name_cache_miss;
713 old_data->find_dir_hit = new_data->find_dir_hit;
714 old_data->find_dir_miss = new_data->find_dir_miss;
715 old_data->buf_hash_hit = new_data->buf_hash_hit;
716 old_data->buf_hash_miss = new_data->buf_hash_miss;
717 old_data->inode_cache_hit = new_data->inode_cache_hit;
718 old_data->inode_cache_miss = new_data->inode_cache_miss;
720 /* Copy HAVE_* flags */
721 old_data->flags |= (new_data->flags & HAVE_WAFL_ALL);
724 } /* }}} int submit_wafl_data */
726 /* Submits volume performance data to the daemon, taking care to honor and
727 * update flags appropriately. */
728 static int submit_volume_perf_data (const host_config_t *host, /* {{{ */
730 const data_volume_perf_t *new_data)
732 /* Check for and submit disk-octet values */
733 if (HAS_ALL_FLAGS (volume->perf_data.flags, CFG_VOLUME_PERF_IO)
734 && HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_BYTES_READ | HAVE_VOLUME_PERF_BYTES_WRITE))
736 submit_two_counters (host->name, volume->name, "disk_octets", /* type instance = */ NULL,
737 (counter_t) new_data->read_bytes, (counter_t) new_data->write_bytes, new_data->timestamp);
740 /* Check for and submit disk-operations values */
741 if (HAS_ALL_FLAGS (volume->perf_data.flags, CFG_VOLUME_PERF_OPS)
742 && HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE))
744 submit_two_counters (host->name, volume->name, "disk_ops", /* type instance = */ NULL,
745 (counter_t) new_data->read_ops, (counter_t) new_data->write_ops, new_data->timestamp);
748 /* Check for, calculate and submit disk-latency values */
749 if (HAS_ALL_FLAGS (volume->perf_data.flags, CFG_VOLUME_PERF_LATENCY
750 | HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE
751 | HAVE_VOLUME_PERF_LATENCY_READ | HAVE_VOLUME_PERF_LATENCY_WRITE)
752 && HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE
753 | HAVE_VOLUME_PERF_LATENCY_READ | HAVE_VOLUME_PERF_LATENCY_WRITE))
755 gauge_t latency_per_op_read;
756 gauge_t latency_per_op_write;
758 latency_per_op_read = NAN;
759 latency_per_op_write = NAN;
761 /* Check if a counter wrapped around. */
762 if ((new_data->read_ops > volume->perf_data.read_ops)
763 && (new_data->read_latency > volume->perf_data.read_latency))
765 uint64_t diff_ops_read;
766 uint64_t diff_latency_read;
768 diff_ops_read = new_data->read_ops - volume->perf_data.read_ops;
769 diff_latency_read = new_data->read_latency - volume->perf_data.read_latency;
771 if (diff_ops_read > 0)
772 latency_per_op_read = ((gauge_t) diff_latency_read) / ((gauge_t) diff_ops_read);
775 if ((new_data->write_ops > volume->perf_data.write_ops)
776 && (new_data->write_latency > volume->perf_data.write_latency))
778 uint64_t diff_ops_write;
779 uint64_t diff_latency_write;
781 diff_ops_write = new_data->write_ops - volume->perf_data.write_ops;
782 diff_latency_write = new_data->write_latency - volume->perf_data.write_latency;
784 if (diff_ops_write > 0)
785 latency_per_op_write = ((gauge_t) diff_latency_write) / ((gauge_t) diff_ops_write);
788 submit_two_gauge (host->name, volume->name, "disk_latency", /* type instance = */ NULL,
789 latency_per_op_read, latency_per_op_write, new_data->timestamp);
792 /* Clear all HAVE_* flags. */
793 volume->perf_data.flags &= ~HAVE_VOLUME_PERF_ALL;
795 /* Copy all counters */
796 volume->perf_data.timestamp = new_data->timestamp;
797 volume->perf_data.read_bytes = new_data->read_bytes;
798 volume->perf_data.write_bytes = new_data->write_bytes;
799 volume->perf_data.read_ops = new_data->read_ops;
800 volume->perf_data.write_ops = new_data->write_ops;
801 volume->perf_data.read_latency = new_data->read_latency;
802 volume->perf_data.write_latency = new_data->write_latency;
804 /* Copy the HAVE_* flags */
805 volume->perf_data.flags |= (new_data->flags & HAVE_VOLUME_PERF_ALL);
808 } /* }}} int submit_volume_perf_data */
813 * These functions are called with appropriate data returned by the libnetapp
814 * interface which is parsed and submitted with the above functions.
816 /* Data corresponding to <WAFL /> */
817 static int cna_handle_wafl_data (const char *hostname, cfg_wafl_t *cfg_wafl, /* {{{ */
820 cfg_wafl_t perf_data;
821 const char *plugin_inst;
823 na_elem_t *instances;
825 na_elem_iter_t counter_iter;
827 memset (&perf_data, 0, sizeof (perf_data));
829 perf_data.timestamp = (time_t) na_child_get_uint64 (data, "timestamp", 0);
831 instances = na_elem_child(na_elem_child (data, "instances"), "instance-data");
832 if (instances == NULL)
834 ERROR ("netapp plugin: cna_handle_wafl_data: "
835 "na_elem_child (\"instances\") failed.");
839 plugin_inst = na_child_get_string(instances, "name");
840 if (plugin_inst == NULL)
842 ERROR ("netapp plugin: cna_handle_wafl_data: "
843 "na_child_get_string (\"name\") failed.");
847 /* Iterate over all counters */
848 counter_iter = na_child_iterator (na_elem_child (instances, "counters"));
849 for (counter = na_iterator_next (&counter_iter);
851 counter = na_iterator_next (&counter_iter))
856 name = na_child_get_string(counter, "name");
860 value = na_child_get_uint64(counter, "value", UINT64_MAX);
861 if (value == UINT64_MAX)
864 if (!strcmp(name, "name_cache_hit")) {
865 perf_data.name_cache_hit = value;
866 perf_data.flags |= HAVE_WAFL_NAME_CACHE_HIT;
867 } else if (!strcmp(name, "name_cache_miss")) {
868 perf_data.name_cache_miss = value;
869 perf_data.flags |= HAVE_WAFL_NAME_CACHE_MISS;
870 } else if (!strcmp(name, "find_dir_hit")) {
871 perf_data.find_dir_hit = value;
872 perf_data.flags |= HAVE_WAFL_FIND_DIR_HIT;
873 } else if (!strcmp(name, "find_dir_miss")) {
874 perf_data.find_dir_miss = value;
875 perf_data.flags |= HAVE_WAFL_FIND_DIR_MISS;
876 } else if (!strcmp(name, "buf_hash_hit")) {
877 perf_data.buf_hash_hit = value;
878 perf_data.flags |= HAVE_WAFL_BUF_HASH_HIT;
879 } else if (!strcmp(name, "buf_hash_miss")) {
880 perf_data.buf_hash_miss = value;
881 perf_data.flags |= HAVE_WAFL_BUF_HASH_MISS;
882 } else if (!strcmp(name, "inode_cache_hit")) {
883 perf_data.inode_cache_hit = value;
884 perf_data.flags |= HAVE_WAFL_INODE_CACHE_HIT;
885 } else if (!strcmp(name, "inode_cache_miss")) {
886 perf_data.inode_cache_miss = value;
887 perf_data.flags |= HAVE_WAFL_INODE_CACHE_MISS;
889 DEBUG("netapp plugin: cna_handle_wafl_data: "
890 "Found unexpected child: %s", name);
894 return (submit_wafl_data (hostname, plugin_inst, cfg_wafl, &perf_data));
895 } /* }}} void cna_handle_wafl_data */
897 static int cna_setup_wafl (cfg_wafl_t *cw) /* {{{ */
904 if (cw->query != NULL)
907 cw->query = na_elem_new("perf-object-get-instances");
908 if (cw->query == NULL)
910 ERROR ("netapp plugin: na_elem_new failed.");
913 na_child_add_string (cw->query, "objectname", "wafl");
915 e = na_elem_new("counters");
918 na_elem_free (cw->query);
920 ERROR ("netapp plugin: na_elem_new failed.");
923 na_child_add_string(e, "foo", "name_cache_hit");
924 na_child_add_string(e, "foo", "name_cache_miss");
925 na_child_add_string(e, "foo", "find_dir_hit");
926 na_child_add_string(e, "foo", "find_dir_miss");
927 na_child_add_string(e, "foo", "buf_hash_hit");
928 na_child_add_string(e, "foo", "buf_hash_miss");
929 na_child_add_string(e, "foo", "inode_cache_hit");
930 na_child_add_string(e, "foo", "inode_cache_miss");
932 na_child_add(cw->query, e);
935 } /* }}} int cna_setup_wafl */
937 static int cna_query_wafl (host_config_t *host) /* {{{ */
946 /* If WAFL was not configured, return without doing anything. */
947 if (host->cfg_wafl == NULL)
951 if ((host->cfg_wafl->interval.interval + host->cfg_wafl->interval.last_read) > now)
954 status = cna_setup_wafl (host->cfg_wafl);
957 assert (host->cfg_wafl->query != NULL);
959 data = na_server_invoke_elem(host->srv, host->cfg_wafl->query);
960 if (na_results_status (data) != NA_OK)
962 ERROR ("netapp plugin: cna_query_wafl: na_server_invoke_elem failed: %s",
963 na_results_reason (data));
968 status = cna_handle_wafl_data (host->name, host->cfg_wafl, data);
971 host->cfg_wafl->interval.last_read = now;
975 } /* }}} int cna_query_wafl */
977 /* Data corresponding to <Disks /> */
978 static int cna_handle_disk_data (const char *hostname, /* {{{ */
979 cfg_disk_t *cfg_disk, na_elem_t *data)
982 na_elem_t *instances;
984 na_elem_iter_t instance_iter;
985 disk_t *worst_disk = NULL;
987 if ((cfg_disk == NULL) || (data == NULL))
990 timestamp = (time_t) na_child_get_uint64(data, "timestamp", 0);
992 instances = na_elem_child (data, "instances");
993 if (instances == NULL)
995 ERROR ("netapp plugin: cna_handle_disk_data: "
996 "na_elem_child (\"instances\") failed.");
1000 /* Iterate over all children */
1001 instance_iter = na_child_iterator (instances);
1002 for (instance = na_iterator_next (&instance_iter);
1004 instance = na_iterator_next(&instance_iter))
1009 na_elem_iter_t counter_iterator;
1012 memset (&new_data, 0, sizeof (new_data));
1013 new_data.timestamp = timestamp;
1014 new_data.disk_busy_percent = NAN;
1016 old_data = get_disk(cfg_disk, na_child_get_string (instance, "name"));
1017 if (old_data == NULL)
1020 /* Look for the "disk_busy" and "base_for_disk_busy" counters */
1021 counter_iterator = na_child_iterator(na_elem_child(instance, "counters"));
1022 for (counter = na_iterator_next(&counter_iterator);
1024 counter = na_iterator_next(&counter_iterator))
1029 name = na_child_get_string(counter, "name");
1033 value = na_child_get_uint64(counter, "value", UINT64_MAX);
1034 if (value == UINT64_MAX)
1037 if (strcmp(name, "disk_busy") == 0)
1039 new_data.disk_busy = value;
1040 new_data.flags |= HAVE_DISK_BUSY;
1042 else if (strcmp(name, "base_for_disk_busy") == 0)
1044 new_data.base_for_disk_busy = value;
1045 new_data.flags |= HAVE_DISK_BASE;
1049 DEBUG ("netapp plugin: cna_handle_disk_data: "
1050 "Counter not handled: %s = %"PRIu64,
1055 /* If all required counters are available and did not just wrap around,
1056 * calculate the busy percentage. Otherwise, the value is initialized to
1057 * NAN at the top of the for-loop. */
1058 if (HAS_ALL_FLAGS (old_data->flags, HAVE_DISK_BUSY | HAVE_DISK_BASE)
1059 && HAS_ALL_FLAGS (new_data.flags, HAVE_DISK_BUSY | HAVE_DISK_BASE)
1060 && (new_data.disk_busy >= old_data->disk_busy)
1061 && (new_data.base_for_disk_busy > old_data->base_for_disk_busy))
1066 busy_diff = new_data.disk_busy - old_data->disk_busy;
1067 base_diff = new_data.base_for_disk_busy - old_data->base_for_disk_busy;
1069 new_data.disk_busy_percent = 100.0
1070 * ((gauge_t) busy_diff) / ((gauge_t) base_diff);
1073 /* Clear HAVE_* flags */
1074 old_data->flags &= ~HAVE_DISK_ALL;
1077 old_data->timestamp = new_data.timestamp;
1078 old_data->disk_busy = new_data.disk_busy;
1079 old_data->base_for_disk_busy = new_data.base_for_disk_busy;
1080 old_data->disk_busy_percent = new_data.disk_busy_percent;
1083 old_data->flags |= (new_data.flags & HAVE_DISK_ALL);
1085 if ((worst_disk == NULL)
1086 || (worst_disk->disk_busy_percent < old_data->disk_busy_percent))
1087 worst_disk = old_data;
1088 } /* for (all disks) */
1090 if ((cfg_disk->flags & CFG_DISK_BUSIEST) && (worst_disk != NULL))
1091 submit_double (hostname, "system", "percent", "disk_busy",
1092 worst_disk->disk_busy_percent, timestamp);
1095 } /* }}} int cna_handle_disk_data */
1097 static int cna_setup_disk (cfg_disk_t *cd) /* {{{ */
1104 if (cd->query != NULL)
1107 cd->query = na_elem_new ("perf-object-get-instances");
1108 if (cd->query == NULL)
1110 ERROR ("netapp plugin: na_elem_new failed.");
1113 na_child_add_string (cd->query, "objectname", "disk");
1115 e = na_elem_new("counters");
1118 na_elem_free (cd->query);
1120 ERROR ("netapp plugin: na_elem_new failed.");
1123 na_child_add_string(e, "foo", "disk_busy");
1124 na_child_add_string(e, "foo", "base_for_disk_busy");
1125 na_child_add(cd->query, e);
1128 } /* }}} int cna_setup_disk */
1130 static int cna_query_disk (host_config_t *host) /* {{{ */
1139 /* If the user did not configure disk statistics, return without doing
1141 if (host->cfg_disk == NULL)
1145 if ((host->cfg_disk->interval.interval + host->cfg_disk->interval.last_read) > now)
1148 status = cna_setup_disk (host->cfg_disk);
1151 assert (host->cfg_disk->query != NULL);
1153 data = na_server_invoke_elem(host->srv, host->cfg_disk->query);
1154 if (na_results_status (data) != NA_OK)
1156 ERROR ("netapp plugin: cna_query_disk: na_server_invoke_elem failed: %s",
1157 na_results_reason (data));
1158 na_elem_free (data);
1162 status = cna_handle_disk_data (host->name, host->cfg_disk, data);
1165 host->cfg_disk->interval.last_read = now;
1167 na_elem_free (data);
1169 } /* }}} int cna_query_disk */
1171 /* Data corresponding to <VolumeUsage /> */
1172 static int cna_submit_volume_usage_data (const char *hostname, /* {{{ */
1173 cfg_volume_usage_t *cfg_volume)
1175 data_volume_usage_t *v;
1177 for (v = cfg_volume->volumes; v != NULL; v = v->next)
1179 if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_NORM_FREE))
1180 submit_double (hostname, /* plugin instance = */ v->name,
1181 "df_complex", "free",
1182 (double) v->norm_free, /* timestamp = */ 0);
1184 if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_NORM_USED))
1185 submit_double (hostname, /* plugin instance = */ v->name,
1186 "df_complex", "used",
1187 (double) v->norm_used, /* timestamp = */ 0);
1189 if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_SNAP_RSVD))
1190 submit_double (hostname, /* plugin instance = */ v->name,
1191 "df_complex", "snap_reserved",
1192 (double) v->snap_reserved, /* timestamp = */ 0);
1194 if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_SNAP_USED))
1195 submit_double (hostname, /* plugin instance = */ v->name,
1196 "df_complex", "snap_used",
1197 (double) v->snap_used, /* timestamp = */ 0);
1199 if (HAS_ALL_FLAGS (v->flags, HAVE_VOLUME_USAGE_SIS_SAVED))
1200 submit_double (hostname, /* plugin instance = */ v->name,
1201 "df_complex", "sis_saved",
1202 (double) v->sis_saved, /* timestamp = */ 0);
1204 /* Clear all the HAVE_* flags */
1205 v->flags &= ~HAVE_VOLUME_USAGE_ALL;
1206 } /* for (v = cfg_volume->volumes) */
1209 } /* }}} int cna_submit_volume_usage_data */
1211 static int cna_handle_volume_usage_data (const char *hostname, /* {{{ */
1212 cfg_volume_usage_t *cfg_volume, na_elem_t *data)
1214 na_elem_t *elem_volume;
1215 na_elem_t *elem_volumes;
1216 na_elem_iter_t iter_volume;
1218 elem_volumes = na_elem_child (data, "volumes");
1219 if (elem_volumes == NULL)
1221 ERROR ("netapp plugin: cna_handle_volume_usage_data: "
1222 "na_elem_child (\"volumes\") failed.");
1226 iter_volume = na_child_iterator (elem_volumes);
1227 for (elem_volume = na_iterator_next (&iter_volume);
1228 elem_volume != NULL;
1229 elem_volume = na_iterator_next (&iter_volume))
1231 const char *volume_name;
1233 data_volume_usage_t *v;
1237 const char *sis_state;
1238 uint64_t sis_saved_reported;
1241 volume_name = na_child_get_string (elem_volume, "name");
1242 if (volume_name == NULL)
1245 /* get_volume_usage may return NULL if the volume is to be ignored. */
1246 v = get_volume_usage (cfg_volume, volume_name);
1250 if ((v->flags & CFG_VOLUME_USAGE_DF) == 0)
1253 /* 2^4 exa-bytes? This will take a while ;) */
1254 value = na_child_get_uint64(elem_volume, "size-available", UINT64_MAX);
1255 if (value != UINT64_MAX) {
1256 v->norm_free = value;
1257 v->flags |= HAVE_VOLUME_USAGE_NORM_FREE;
1260 value = na_child_get_uint64(elem_volume, "size-used", UINT64_MAX);
1261 if (value != UINT64_MAX) {
1262 v->norm_used = value;
1263 v->flags |= HAVE_VOLUME_USAGE_NORM_USED;
1266 value = na_child_get_uint64(elem_volume, "snapshot-blocks-reserved", UINT64_MAX);
1267 if (value != UINT64_MAX) {
1268 /* 1 block == 1024 bytes as per API docs */
1269 v->norm_used = 1024 * value;
1270 v->flags |= HAVE_VOLUME_USAGE_SNAP_RSVD;
1273 sis = na_elem_child(elem_volume, "sis");
1277 sis_state = na_child_get_string(sis, "state");
1278 if (sis_state == NULL)
1281 /* If SIS is not enabled, set the HAVE_VOLUME_USAGE_SIS_SAVED flag and set
1282 * sis_saved to UINT64_MAX to signal this condition to the submit function. */
1283 if (strcmp ("enabled", sis_state) != 0) {
1284 v->sis_saved = UINT64_MAX;
1285 v->flags |= HAVE_VOLUME_USAGE_SIS_SAVED;
1289 sis_saved_reported = na_child_get_uint64(sis, "size-saved", UINT64_MAX);
1290 if (sis_saved_reported == UINT64_MAX)
1293 /* size-saved is actually a 32 bit number, so ... time for some guesswork. */
1294 if ((sis_saved_reported >> 32) != 0) {
1295 /* In case they ever fix this bug. */
1296 sis_saved = sis_saved_reported;
1297 } else { /* really hacky work-around code. {{{ */
1298 uint64_t sis_saved_percent;
1299 uint64_t sis_saved_guess;
1300 uint64_t overflow_guess;
1301 uint64_t guess1, guess2, guess3;
1303 /* Check if we have v->norm_used. Without it, we cannot calculate
1304 * sis_saved_guess. */
1305 if ((v->flags & HAVE_VOLUME_USAGE_NORM_USED) == 0)
1308 sis_saved_percent = na_child_get_uint64(sis, "percentage-saved", UINT64_MAX);
1309 if (sis_saved_percent > 100)
1312 /* The "size-saved" value is a 32bit unsigned integer. This is a bug and
1313 * will hopefully be fixed in later versions. To work around the bug, try
1314 * to figure out how often the 32bit integer wrapped around by using the
1315 * "percentage-saved" value. Because the percentage is in the range
1316 * [0-100], this should work as long as the saved space does not exceed
1318 /* percentage-saved = size-saved / (size-saved + size-used) */
1319 if (sis_saved_percent < 100)
1320 sis_saved_guess = v->norm_used * sis_saved_percent / (100 - sis_saved_percent);
1322 sis_saved_guess = v->norm_used;
1324 overflow_guess = sis_saved_guess >> 32;
1325 guess1 = overflow_guess ? ((overflow_guess - 1) << 32) + sis_saved_reported : sis_saved_reported;
1326 guess2 = (overflow_guess << 32) + sis_saved_reported;
1327 guess3 = ((overflow_guess + 1) << 32) + sis_saved_reported;
1329 if (sis_saved_guess < guess2) {
1330 if ((sis_saved_guess - guess1) < (guess2 - sis_saved_guess))
1335 if ((sis_saved_guess - guess2) < (guess3 - sis_saved_guess))
1340 } /* }}} end of 32-bit workaround */
1341 } /* for (elem_volume) */
1343 return (cna_submit_volume_usage_data (hostname, cfg_volume));
1344 } /* }}} int cna_handle_volume_usage_data */
1346 static int cna_setup_volume_usage (cfg_volume_usage_t *cvu) /* {{{ */
1351 if (cvu->query != NULL)
1354 cvu->query = na_elem_new ("volume-list-info");
1355 if (cvu->query == NULL)
1357 ERROR ("netapp plugin: na_elem_new failed.");
1361 /* TODO: cvu->snap_query = na_elem_new("snapshot-list-info"); */
1364 } /* }}} int cna_setup_volume_usage */
1366 static int cna_query_volume_usage (host_config_t *host) /* {{{ */
1375 /* If the user did not configure volume_usage statistics, return without
1376 * doing anything. */
1377 if (host->cfg_volume_usage == NULL)
1381 if ((host->cfg_volume_usage->interval.interval + host->cfg_volume_usage->interval.last_read) > now)
1384 status = cna_setup_volume_usage (host->cfg_volume_usage);
1387 assert (host->cfg_volume_usage->query != NULL);
1389 data = na_server_invoke_elem(host->srv, host->cfg_volume_usage->query);
1390 if (na_results_status (data) != NA_OK)
1392 ERROR ("netapp plugin: cna_query_volume_usage: na_server_invoke_elem failed: %s",
1393 na_results_reason (data));
1394 na_elem_free (data);
1398 status = cna_handle_volume_usage_data (host->name, host->cfg_volume_usage, data);
1401 host->cfg_volume_usage->interval.last_read = now;
1403 na_elem_free (data);
1405 } /* }}} int cna_query_volume_usage */
1407 /* Data corresponding to <GetVolumePerfData /> */
1408 static void query_volume_perf_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
1409 cfg_volume_perf_t *cfg_volume_perf = data;
1411 na_elem_t *counter, *inst;
1413 timestamp = (time_t) na_child_get_uint64(out, "timestamp", 0);
1415 out = na_elem_child(out, "instances");
1416 na_elem_iter_t inst_iter = na_child_iterator(out);
1417 for (inst = na_iterator_next(&inst_iter); inst; inst = na_iterator_next(&inst_iter)) {
1418 data_volume_perf_t perf_data;
1421 memset (&perf_data, 0, sizeof (perf_data));
1422 perf_data.timestamp = timestamp;
1424 volume = get_volume(host, na_child_get_string(inst, "name"),
1425 cfg_volume_perf->flags);
1429 na_elem_iter_t count_iter = na_child_iterator(na_elem_child(inst, "counters"));
1430 for (counter = na_iterator_next(&count_iter); counter; counter = na_iterator_next(&count_iter)) {
1434 name = na_child_get_string(counter, "name");
1438 value = na_child_get_uint64(counter, "value", UINT64_MAX);
1439 if (value == UINT64_MAX)
1442 if (!strcmp(name, "read_data")) {
1443 perf_data.read_bytes = value;
1444 perf_data.flags |= HAVE_VOLUME_PERF_BYTES_READ;
1445 } else if (!strcmp(name, "write_data")) {
1446 perf_data.write_bytes = value;
1447 perf_data.flags |= HAVE_VOLUME_PERF_BYTES_WRITE;
1448 } else if (!strcmp(name, "read_ops")) {
1449 perf_data.read_ops = value;
1450 perf_data.flags |= HAVE_VOLUME_PERF_OPS_READ;
1451 } else if (!strcmp(name, "write_ops")) {
1452 perf_data.write_ops = value;
1453 perf_data.flags |= HAVE_VOLUME_PERF_OPS_WRITE;
1454 } else if (!strcmp(name, "read_latency")) {
1455 perf_data.read_latency = value;
1456 perf_data.flags |= HAVE_VOLUME_PERF_LATENCY_READ;
1457 } else if (!strcmp(name, "write_latency")) {
1458 perf_data.write_latency = value;
1459 perf_data.flags |= HAVE_VOLUME_PERF_LATENCY_WRITE;
1463 submit_volume_perf_data (host, volume, &perf_data);
1464 } /* for (volume) */
1465 } /* }}} void query_volume_perf_data */
1467 /* Data corresponding to <System /> */
1468 static int cna_handle_system_data (const char *hostname, /* {{{ */
1469 cfg_system_t *cfg_system, na_elem_t *data)
1471 na_elem_t *instances;
1473 na_elem_iter_t counter_iter;
1475 counter_t disk_read = 0, disk_written = 0;
1476 counter_t net_recv = 0, net_sent = 0;
1477 counter_t cpu_busy = 0, cpu_total = 0;
1478 uint32_t counter_flags = 0;
1480 const char *instance;
1483 timestamp = (time_t) na_child_get_uint64 (data, "timestamp", 0);
1485 instances = na_elem_child(na_elem_child (data, "instances"), "instance-data");
1486 if (instances == NULL)
1488 ERROR ("netapp plugin: cna_handle_system_data: "
1489 "na_elem_child (\"instances\") failed.");
1493 instance = na_child_get_string (instances, "name");
1494 if (instance == NULL)
1496 ERROR ("netapp plugin: cna_handle_system_data: "
1497 "na_child_get_string (\"name\") failed.");
1501 counter_iter = na_child_iterator (na_elem_child (instances, "counters"));
1502 for (counter = na_iterator_next (&counter_iter);
1504 counter = na_iterator_next (&counter_iter))
1509 name = na_child_get_string(counter, "name");
1513 value = na_child_get_uint64(counter, "value", UINT64_MAX);
1514 if (value == UINT64_MAX)
1517 if (!strcmp(name, "disk_data_read")) {
1518 disk_read = (counter_t) (value * 1024);
1519 counter_flags |= 0x01;
1520 } else if (!strcmp(name, "disk_data_written")) {
1521 disk_written = (counter_t) (value * 1024);
1522 counter_flags |= 0x02;
1523 } else if (!strcmp(name, "net_data_recv")) {
1524 net_recv = (counter_t) (value * 1024);
1525 counter_flags |= 0x04;
1526 } else if (!strcmp(name, "net_data_sent")) {
1527 net_sent = (counter_t) (value * 1024);
1528 counter_flags |= 0x08;
1529 } else if (!strcmp(name, "cpu_busy")) {
1530 cpu_busy = (counter_t) value;
1531 counter_flags |= 0x10;
1532 } else if (!strcmp(name, "cpu_elapsed_time")) {
1533 cpu_total = (counter_t) value;
1534 counter_flags |= 0x20;
1535 } else if ((cfg_system->flags & CFG_SYSTEM_OPS)
1536 && (value > 0) && (strlen(name) > 4)
1537 && (!strcmp(name + strlen(name) - 4, "_ops"))) {
1538 submit_counter (hostname, instance, "disk_ops_complex", name,
1539 (counter_t) value, timestamp);
1541 } /* for (counter) */
1543 if ((cfg_system->flags & CFG_SYSTEM_DISK)
1544 && (HAS_ALL_FLAGS (counter_flags, 0x01 | 0x02)))
1545 submit_two_counters (hostname, instance, "disk_octets", NULL,
1546 disk_read, disk_written, timestamp);
1548 if ((cfg_system->flags & CFG_SYSTEM_NET)
1549 && (HAS_ALL_FLAGS (counter_flags, 0x04 | 0x08)))
1550 submit_two_counters (hostname, instance, "if_octets", NULL,
1551 net_recv, net_sent, timestamp);
1553 if ((cfg_system->flags & CFG_SYSTEM_CPU)
1554 && (HAS_ALL_FLAGS (counter_flags, 0x10 | 0x20)))
1556 submit_counter (hostname, instance, "cpu", "system",
1557 cpu_busy, timestamp);
1558 submit_counter (hostname, instance, "cpu", "idle",
1559 cpu_total - cpu_busy, timestamp);
1563 } /* }}} int cna_handle_system_data */
1565 static int cna_setup_system (cfg_system_t *cs) /* {{{ */
1570 if (cs->query != NULL)
1573 cs->query = na_elem_new ("perf-object-get-instances");
1574 if (cs->query == NULL)
1576 ERROR ("netapp plugin: na_elem_new failed.");
1579 na_child_add_string (cs->query, "objectname", "system");
1582 } /* }}} int cna_setup_system */
1584 static int cna_query_system (host_config_t *host) /* {{{ */
1593 /* If system statistics were not configured, return without doing anything. */
1594 if (host->cfg_system == NULL)
1598 if ((host->cfg_system->interval.interval + host->cfg_system->interval.last_read) > now)
1601 status = cna_setup_system (host->cfg_system);
1604 assert (host->cfg_system->query != NULL);
1606 data = na_server_invoke_elem(host->srv, host->cfg_system->query);
1607 if (na_results_status (data) != NA_OK)
1609 ERROR ("netapp plugin: cna_query_system: na_server_invoke_elem failed: %s",
1610 na_results_reason (data));
1611 na_elem_free (data);
1615 status = cna_handle_system_data (host->name, host->cfg_system, data);
1618 host->cfg_system->interval.last_read = now;
1620 na_elem_free (data);
1622 } /* }}} int cna_query_system */
1625 * Configuration handling
1627 /* Sets a given flag if the boolean argument is true and unsets the flag if it
1628 * is false. On error, the flag-field is not changed. */
1629 static int cna_config_bool_to_flag (const oconfig_item_t *ci, /* {{{ */
1630 uint32_t *flags, uint32_t flag)
1632 if ((ci == NULL) || (flags == NULL))
1635 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
1637 WARNING ("netapp plugin: The %s option needs exactly one boolean argument.",
1642 if (ci->values[0].value.boolean)
1648 } /* }}} int cna_config_bool_to_flag */
1650 /* Handling of the "Multiplier" option which is allowed in every block. */
1651 static int cna_config_get_multiplier (const oconfig_item_t *ci, /* {{{ */
1652 cfg_service_t *service)
1656 if ((ci == NULL) || (service == NULL))
1659 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
1661 WARNING ("netapp plugin: The `Multiplier' option needs exactly one numeric argument.");
1665 tmp = (int) (ci->values[0].value.number + .5);
1668 WARNING ("netapp plugin: The `Multiplier' option needs a positive integer argument.");
1672 service->multiplier = tmp;
1673 service->skip_countdown = tmp;
1676 } /* }}} int cna_config_get_multiplier */
1678 /* Handling of the "Interval" option which is allowed in every block. */
1679 static int cna_config_get_interval (const oconfig_item_t *ci, /* {{{ */
1680 cna_interval_t *out_interval)
1684 if ((ci == NULL) || (out_interval == NULL))
1687 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
1689 WARNING ("netapp plugin: The `Multiplier' option needs exactly one numeric argument.");
1693 tmp = (time_t) (ci->values[0].value.number + .5);
1696 WARNING ("netapp plugin: The `Multiplier' option needs a positive integer argument.");
1700 out_interval->interval = tmp;
1701 out_interval->last_read = 0;
1704 } /* }}} int cna_config_get_interval */
1706 /* Handling of the "GetIO", "GetOps" and "GetLatency" options within a
1707 * <GetVolumePerfData /> block. */
1708 static void cna_config_volume_performance_option (host_config_t *host, /* {{{ */
1709 cfg_volume_perf_t *perf_volume, const oconfig_item_t *item,
1714 for (i = 0; i < item->values_num; ++i) {
1719 if (item->values[i].type != OCONFIG_TYPE_STRING) {
1720 WARNING("netapp plugin: Ignoring non-string argument in "
1721 "\"GetVolumePerfData\" block for host %s", host->name);
1725 name = item->values[i].value.string;
1726 if (name[0] == '+') {
1729 } else if (name[0] == '-') {
1736 perf_volume->flags |= flag;
1737 else /* if (!set) */
1738 perf_volume->flags &= ~flag;
1740 host_set_all_perf_data_flags(host, flag, set);
1744 v = get_volume (host, name, perf_volume->flags);
1749 v->perf_data.flags |= flag;
1750 else /* if (!set) */
1751 v->perf_data.flags &= ~flag;
1752 } /* for (i = 0 .. item->values_num) */
1753 } /* }}} void cna_config_volume_performance_option */
1755 /* Corresponds to a <GetVolumePerfData /> block */
1756 static void cna_config_volume_performance(host_config_t *host, const oconfig_item_t *ci) { /* {{{ */
1757 int i, had_io = 0, had_ops = 0, had_latency = 0;
1758 cfg_service_t *service;
1759 cfg_volume_perf_t *perf_volume;
1761 service = malloc(sizeof(*service));
1763 service->handler = query_volume_perf_data;
1764 perf_volume = service->data = malloc(sizeof(*perf_volume));
1765 perf_volume->flags = CFG_VOLUME_PERF_INIT;
1766 service->next = host->services;
1767 host->services = service;
1768 for (i = 0; i < ci->children_num; ++i) {
1769 oconfig_item_t *item = ci->children + i;
1771 /* if (!item || !item->key || !*item->key) continue; */
1772 if (!strcasecmp(item->key, "Multiplier")) {
1773 cna_config_get_multiplier (item, service);
1774 } else if (!strcasecmp(item->key, "GetIO")) {
1776 cna_config_volume_performance_option(host, perf_volume, item, CFG_VOLUME_PERF_IO);
1777 } else if (!strcasecmp(item->key, "GetOps")) {
1779 cna_config_volume_performance_option(host, perf_volume, item, CFG_VOLUME_PERF_OPS);
1780 } else if (!strcasecmp(item->key, "GetLatency")) {
1782 cna_config_volume_performance_option(host, perf_volume, item, CFG_VOLUME_PERF_LATENCY);
1786 perf_volume->flags |= CFG_VOLUME_PERF_IO;
1787 host_set_all_perf_data_flags(host, CFG_VOLUME_PERF_IO, /* set = */ true);
1790 perf_volume->flags |= CFG_VOLUME_PERF_OPS;
1791 host_set_all_perf_data_flags(host, CFG_VOLUME_PERF_OPS, /* set = */ true);
1794 perf_volume->flags |= CFG_VOLUME_PERF_LATENCY;
1795 host_set_all_perf_data_flags(host, CFG_VOLUME_PERF_LATENCY, /* set = */ true);
1797 } /* }}} void cna_config_volume_performance */
1799 /* Handling of the "Capacity" and "Snapshot" options within a <VolumeUsage />
1801 static void cna_config_volume_usage_option (cfg_volume_usage_t *cvu, /* {{{ */
1802 const oconfig_item_t *ci)
1807 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
1809 WARNING ("netapp plugin: The %s option requires exactly one string argument.",
1814 name = ci->values[0].value.string;
1816 if (strcasecmp ("Capacity", ci->key) == 0)
1817 il = cvu->il_capacity;
1818 else if (strcasecmp ("Snapshot", ci->key) == 0)
1819 il = cvu->il_snapshot;
1823 ignorelist_add (il, name);
1824 } /* }}} void cna_config_volume_usage_option */
1826 /* Handling of the "IgnoreSelectedCapacity" and "IgnoreSelectedSnapshot"
1827 * options within a <VolumeUsage /> block. */
1828 static void cna_config_volume_usage_default (cfg_volume_usage_t *cvu, /* {{{ */
1829 const oconfig_item_t *ci)
1833 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
1835 WARNING ("netapp plugin: The %s option requires exactly one string argument.",
1840 if (strcasecmp ("IgnoreSelectedCapacity", ci->key) == 0)
1841 il = cvu->il_capacity;
1842 else if (strcasecmp ("IgnoreSelectedSnapshot", ci->key) == 0)
1843 il = cvu->il_snapshot;
1847 if (ci->values[0].value.boolean)
1848 ignorelist_set_invert (il, /* invert = */ 0);
1850 ignorelist_set_invert (il, /* invert = */ 1);
1851 } /* }}} void cna_config_volume_usage_default */
1853 /* Corresponds to a <Disks /> block */
1854 static int cna_config_disk(host_config_t *host, oconfig_item_t *ci) { /* {{{ */
1855 cfg_disk_t *cfg_disk;
1858 if ((host == NULL) || (ci == NULL))
1861 if (host->cfg_disk == NULL)
1863 cfg_disk = malloc (sizeof (*cfg_disk));
1864 if (cfg_disk == NULL)
1866 memset (cfg_disk, 0, sizeof (*cfg_disk));
1868 /* Set default flags */
1869 cfg_disk->flags = CFG_DISK_ALL;
1870 cfg_disk->query = NULL;
1871 cfg_disk->disks = NULL;
1873 host->cfg_disk = cfg_disk;
1875 cfg_disk = host->cfg_disk;
1877 for (i = 0; i < ci->children_num; ++i) {
1878 oconfig_item_t *item = ci->children + i;
1880 /* if (!item || !item->key || !*item->key) continue; */
1881 if (strcasecmp(item->key, "Interval") == 0)
1882 cna_config_get_interval (item, &cfg_disk->interval);
1883 else if (strcasecmp(item->key, "GetBusy") == 0)
1884 cna_config_bool_to_flag (item, &cfg_disk->flags, CFG_DISK_BUSIEST);
1887 if ((cfg_disk->flags & CFG_DISK_ALL) == 0)
1889 NOTICE ("netapp plugin: All disk related values have been disabled. "
1890 "Collection of per-disk data will be disabled entirely.");
1891 free_cfg_disk (host->cfg_disk);
1892 host->cfg_disk = NULL;
1896 } /* }}} int cna_config_disk */
1898 /* Corresponds to a <WAFL /> block */
1899 static int cna_config_wafl(host_config_t *host, oconfig_item_t *ci) /* {{{ */
1901 cfg_wafl_t *cfg_wafl;
1904 if ((host == NULL) || (ci == NULL))
1907 if (host->cfg_wafl == NULL)
1909 cfg_wafl = malloc (sizeof (*cfg_wafl));
1910 if (cfg_wafl == NULL)
1912 memset (cfg_wafl, 0, sizeof (*cfg_wafl));
1914 /* Set default flags */
1915 cfg_wafl->flags = CFG_WAFL_ALL;
1917 host->cfg_wafl = cfg_wafl;
1919 cfg_wafl = host->cfg_wafl;
1921 for (i = 0; i < ci->children_num; ++i) {
1922 oconfig_item_t *item = ci->children + i;
1924 if (strcasecmp(item->key, "Interval") == 0)
1925 cna_config_get_interval (item, &cfg_wafl->interval);
1926 else if (!strcasecmp(item->key, "GetNameCache"))
1927 cna_config_bool_to_flag (item, &cfg_wafl->flags, CFG_WAFL_NAME_CACHE);
1928 else if (!strcasecmp(item->key, "GetDirCache"))
1929 cna_config_bool_to_flag (item, &cfg_wafl->flags, CFG_WAFL_DIR_CACHE);
1930 else if (!strcasecmp(item->key, "GetBufferCache"))
1931 cna_config_bool_to_flag (item, &cfg_wafl->flags, CFG_WAFL_BUF_CACHE);
1932 else if (!strcasecmp(item->key, "GetInodeCache"))
1933 cna_config_bool_to_flag (item, &cfg_wafl->flags, CFG_WAFL_INODE_CACHE);
1935 WARNING ("netapp plugin: The %s config option is not allowed within "
1936 "`WAFL' blocks.", item->key);
1939 if ((cfg_wafl->flags & CFG_WAFL_ALL) == 0)
1941 NOTICE ("netapp plugin: All WAFL related values have been disabled. "
1942 "Collection of WAFL data will be disabled entirely.");
1943 free_cfg_wafl (host->cfg_wafl);
1944 host->cfg_wafl = NULL;
1948 } /* }}} int cna_config_wafl */
1957 * IgnoreSelectedCapacity false
1963 * IgnoreSelectedSnapshot false
1966 /* Corresponds to a <VolumeUsage /> block */
1967 static int cna_config_volume_usage(host_config_t *host, oconfig_item_t *ci) { /* {{{ */
1968 cfg_volume_usage_t *cfg_volume_usage;
1971 if ((host == NULL) || (ci == NULL))
1974 if (host->cfg_volume_usage == NULL)
1976 cfg_volume_usage = malloc (sizeof (*cfg_volume_usage));
1977 if (cfg_volume_usage == NULL)
1979 memset (cfg_volume_usage, 0, sizeof (*cfg_volume_usage));
1981 /* Set default flags */
1982 cfg_volume_usage->query = NULL;
1983 cfg_volume_usage->volumes = NULL;
1985 cfg_volume_usage->il_capacity = ignorelist_create (/* invert = */ 1);
1986 if (cfg_volume_usage->il_capacity == NULL)
1988 sfree (cfg_volume_usage);
1992 cfg_volume_usage->il_snapshot = ignorelist_create (/* invert = */ 1);
1993 if (cfg_volume_usage->il_snapshot == NULL)
1995 ignorelist_free (cfg_volume_usage->il_capacity);
1996 sfree (cfg_volume_usage);
2000 host->cfg_volume_usage = cfg_volume_usage;
2002 cfg_volume_usage = host->cfg_volume_usage;
2004 for (i = 0; i < ci->children_num; ++i) {
2005 oconfig_item_t *item = ci->children + i;
2007 /* if (!item || !item->key || !*item->key) continue; */
2008 if (strcasecmp(item->key, "Interval") == 0)
2009 cna_config_get_interval (item, &cfg_volume_usage->interval);
2010 else if (!strcasecmp(item->key, "Capacity"))
2011 cna_config_volume_usage_option (cfg_volume_usage, item);
2012 else if (!strcasecmp(item->key, "Snapshot"))
2013 cna_config_volume_usage_option (cfg_volume_usage, item);
2014 else if (!strcasecmp(item->key, "IgnoreSelectedCapacity"))
2015 cna_config_volume_usage_default (cfg_volume_usage, item);
2016 else if (!strcasecmp(item->key, "IgnoreSelectedSnapshot"))
2017 cna_config_volume_usage_default (cfg_volume_usage, item);
2021 } /* }}} int cna_config_volume_usage */
2023 /* Corresponds to a <System /> block */
2024 static int cna_config_system (host_config_t *host, /* {{{ */
2025 oconfig_item_t *ci, const cfg_service_t *default_service)
2027 cfg_system_t *cfg_system;
2030 if ((host == NULL) || (ci == NULL))
2033 if (host->cfg_system == NULL)
2035 cfg_system = malloc (sizeof (*cfg_system));
2036 if (cfg_system == NULL)
2038 memset (cfg_system, 0, sizeof (*cfg_system));
2040 /* Set default flags */
2041 cfg_system->flags = CFG_SYSTEM_ALL;
2042 cfg_system->query = NULL;
2044 host->cfg_system = cfg_system;
2046 cfg_system = host->cfg_system;
2048 for (i = 0; i < ci->children_num; ++i) {
2049 oconfig_item_t *item = ci->children + i;
2051 if (strcasecmp(item->key, "Interval") == 0) {
2052 cna_config_get_interval (item, &cfg_system->interval);
2053 } else if (!strcasecmp(item->key, "GetCPULoad")) {
2054 cna_config_bool_to_flag (item, &cfg_system->flags, CFG_SYSTEM_CPU);
2055 } else if (!strcasecmp(item->key, "GetInterfaces")) {
2056 cna_config_bool_to_flag (item, &cfg_system->flags, CFG_SYSTEM_NET);
2057 } else if (!strcasecmp(item->key, "GetDiskOps")) {
2058 cna_config_bool_to_flag (item, &cfg_system->flags, CFG_SYSTEM_OPS);
2059 } else if (!strcasecmp(item->key, "GetDiskIO")) {
2060 cna_config_bool_to_flag (item, &cfg_system->flags, CFG_SYSTEM_DISK);
2062 WARNING ("netapp plugin: The %s config option is not allowed within "
2063 "`System' blocks.", item->key);
2067 if ((cfg_system->flags & CFG_SYSTEM_ALL) == 0)
2069 NOTICE ("netapp plugin: All system related values have been disabled. "
2070 "Collection of system data will be disabled entirely.");
2071 free_cfg_system (host->cfg_system);
2072 host->cfg_system = NULL;
2076 } /* }}} int cna_config_system */
2078 /* Corresponds to a <Host /> block. */
2079 static host_config_t *cna_config_host (const oconfig_item_t *ci, /* {{{ */
2080 const host_config_t *default_host, const cfg_service_t *def_def_service)
2082 oconfig_item_t *item;
2083 host_config_t *host;
2084 cfg_service_t default_service = *def_def_service;
2088 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
2089 WARNING("netapp plugin: \"Host\" needs exactly one string argument. Ignoring host block.");
2093 host = malloc(sizeof(*host));
2094 memcpy (host, default_host, sizeof (*host));
2096 status = cf_util_get_string (ci, &host->name);
2103 for (i = 0; i < ci->children_num; ++i) {
2104 item = ci->children + i;
2108 if (!strcasecmp(item->key, "Address")) {
2109 status = cf_util_get_string (item, &host->host);
2110 } else if (!strcasecmp(item->key, "Port")) {
2113 tmp = cf_util_get_port_number (item);
2116 } else if (!strcasecmp(item->key, "Protocol")) {
2117 if ((item->values_num != 1) || (item->values[0].type != OCONFIG_TYPE_STRING) || (strcasecmp(item->values[0].value.string, "http") && strcasecmp(item->values[0].value.string, "https"))) {
2118 WARNING("netapp plugin: \"Protocol\" needs to be either \"http\" or \"https\". Ignoring host block \"%s\".", ci->values[0].value.string);
2121 if (!strcasecmp(item->values[0].value.string, "http")) host->protocol = NA_SERVER_TRANSPORT_HTTP;
2122 else host->protocol = NA_SERVER_TRANSPORT_HTTPS;
2123 } else if (!strcasecmp(item->key, "User")) {
2124 status = cf_util_get_string (item, &host->username);
2125 } else if (!strcasecmp(item->key, "Password")) {
2126 status = cf_util_get_string (item, &host->password);
2127 } else if (!strcasecmp(item->key, "Interval")) {
2128 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_NUMBER || item->values[0].value.number != (int) item->values[0].value.number || item->values[0].value.number < 2) {
2129 WARNING("netapp plugin: \"Interval\" of host %s needs exactly one integer argument.", ci->values[0].value.string);
2132 host->interval = item->values[0].value.number;
2133 } else if (!strcasecmp(item->key, "WAFL")) {
2134 cna_config_wafl(host, item);
2135 } else if (!strcasecmp(item->key, "Disks")) {
2136 cna_config_disk(host, item);
2137 } else if (!strcasecmp(item->key, "GetVolumePerfData")) {
2138 cna_config_volume_performance(host, item);
2139 } else if (!strcasecmp(item->key, "VolumeUsage")) {
2140 cna_config_volume_usage(host, item);
2141 } else if (!strcasecmp(item->key, "System")) {
2142 cna_config_system(host, item, &default_service);
2144 WARNING("netapp plugin: Ignoring unknown config option \"%s\" in host block \"%s\".",
2145 item->key, ci->values[0].value.string);
2152 if (host->host == NULL)
2153 host->host = strdup (host->name);
2155 if (host->host == NULL)
2158 if (host->port <= 0)
2159 host->port = (host->protocol == NA_SERVER_TRANSPORT_HTTP) ? 80 : 443;
2161 if ((host->username == NULL) || (host->password == NULL)) {
2162 WARNING("netapp plugin: Please supply login information for host \"%s\". "
2163 "Ignoring host block.", host->name);
2169 free_host_config (host);
2174 } /* }}} host_config_t *cna_config_host */
2177 * Callbacks registered with the daemon
2179 * Pretty standard stuff here.
2181 static int cna_init(void) { /* {{{ */
2184 host_config_t *host;
2185 cfg_service_t *service;
2187 if (!global_host_config) {
2188 WARNING("netapp plugin: Plugin loaded but no hosts defined.");
2192 memset (err, 0, sizeof (err));
2193 if (!na_startup(err, sizeof(err))) {
2194 err[sizeof (err) - 1] = 0;
2195 ERROR("netapp plugin: Error initializing netapp API: %s", err);
2199 for (host = global_host_config; host; host = host->next) {
2200 /* Request version 1.1 of the ONTAP API */
2201 host->srv = na_server_open(host->host,
2202 /* major version = */ 1, /* minor version = */ 1);
2203 if (host->srv == NULL) {
2204 ERROR ("netapp plugin: na_server_open (%s) failed.", host->host);
2208 if (host->interval < interval_g)
2209 host->interval = interval_g;
2211 na_server_set_transport_type(host->srv, host->protocol,
2212 /* transportarg = */ NULL);
2213 na_server_set_port(host->srv, host->port);
2214 na_server_style(host->srv, NA_STYLE_LOGIN_PASSWORD);
2215 na_server_adminuser(host->srv, host->username, host->password);
2216 na_server_set_timeout(host->srv, 5 /* seconds */);
2218 for (service = host->services; service; service = service->next) {
2219 service->interval = host->interval * service->multiplier;
2221 if (service->handler == query_volume_perf_data) {
2222 service->query = na_elem_new("perf-object-get-instances");
2223 na_child_add_string(service->query, "objectname", "volume");
2224 e = na_elem_new("counters");
2225 /* "foo" means: This string has to be here but
2226 the content doesn't matter. */
2227 na_child_add_string(e, "foo", "read_ops");
2228 na_child_add_string(e, "foo", "write_ops");
2229 na_child_add_string(e, "foo", "read_data");
2230 na_child_add_string(e, "foo", "write_data");
2231 na_child_add_string(e, "foo", "read_latency");
2232 na_child_add_string(e, "foo", "write_latency");
2233 na_child_add(service->query, e);
2235 } /* for (host->services) */
2238 } /* }}} int cna_init */
2240 static int cna_config (oconfig_item_t *ci) { /* {{{ */
2242 oconfig_item_t *item;
2243 host_config_t default_host = HOST_INIT;
2244 cfg_service_t default_service = SERVICE_INIT;
2246 for (i = 0; i < ci->children_num; ++i) {
2247 item = ci->children + i;
2249 if (!strcasecmp(item->key, "Host")) {
2250 host_config_t *host;
2253 host = cna_config_host(item, &default_host, &default_service);
2257 for (tmp = global_host_config; tmp != NULL; tmp = tmp->next)
2259 if (strcasecmp (host->name, tmp->name) == 0)
2260 WARNING ("netapp plugin: Duplicate definition of host `%s'. "
2261 "This is probably a bad idea.",
2264 if (tmp->next == NULL)
2270 global_host_config = host;
2274 WARNING("netapp plugin: Ignoring unknown config option \"%s\".", item->key);
2278 } /* }}} int cna_config */
2280 static int cna_read(void) { /* {{{ */
2282 host_config_t *host;
2283 cfg_service_t *service;
2285 for (host = global_host_config; host; host = host->next) {
2286 for (service = host->services; service; service = service->next) {
2287 if (--service->skip_countdown > 0) continue;
2288 service->skip_countdown = service->multiplier;
2289 out = na_server_invoke_elem(host->srv, service->query);
2290 if (na_results_status(out) != NA_OK) {
2291 int netapp_errno = na_results_errno(out);
2292 ERROR("netapp plugin: Error %d from host %s: %s", netapp_errno, host->name, na_results_reason(out));
2294 if (netapp_errno == EIO || netapp_errno == ETIMEDOUT) {
2295 /* Network problems. Just give up on all other services on this host. */
2300 service->handler(host, out, service->data);
2302 } /* for (host->services) */
2304 cna_query_wafl (host);
2305 cna_query_disk (host);
2306 cna_query_volume_usage (host);
2307 cna_query_system (host);
2310 } /* }}} int cna_read */
2312 void module_register(void) {
2313 plugin_register_complex_config("netapp", cna_config);
2314 plugin_register_init("netapp", cna_init);
2315 plugin_register_read("netapp", cna_read);
2318 /* vim: set sw=2 ts=2 noet fdm=marker : */