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 <sven.trenkel at noris.net>
30 #include <netapp_api.h>
32 #define HAS_ALL_FLAGS(has,needs) (((has) & (needs)) == (needs))
34 typedef struct host_config_s host_config_t;
35 typedef void service_handler_t(host_config_t *host, na_elem_t *result, void *data);
37 #define PERF_SYSTEM_CPU 0x01
38 #define PERF_SYSTEM_NET 0x02
39 #define PERF_SYSTEM_OPS 0x04
40 #define PERF_SYSTEM_DISK 0x08
41 #define PERF_SYSTEM_ALL 0x0F
44 * \brief Persistent data for system performence counters
52 * \brief Persistent data for WAFL performence counters. (a.k.a. cache performence)
55 #define PERF_WAFL_NAME_CACHE 0x01
56 #define PERF_WAFL_DIR_CACHE 0x02
57 #define PERF_WAFL_BUF_CACHE 0x04
58 #define PERF_WAFL_INODE_CACHE 0x08
59 #define PERF_WAFL_ALL 0x0F
63 uint64_t last_name_cache_hit;
64 uint64_t last_name_cache_miss;
65 uint64_t last_find_dir_hit;
66 uint64_t last_find_dir_miss;
67 uint64_t last_buf_hash_hit;
68 uint64_t last_buf_hash_miss;
69 uint64_t last_inode_cache_hit;
70 uint64_t last_inode_cache_miss;
73 #define CFG_VOLUME_PERF_INIT 0x0001
74 #define CFG_VOLUME_PERF_IO 0x0002
75 #define CFG_VOLUME_PERF_OPS 0x0003
76 #define CFG_VOLUME_PERF_LATENCY 0x0008
77 #define CFG_VOLUME_PERF_ALL 0x000F
87 #define PERF_DISK_BUSIEST 0x01
88 #define PERF_DISK_ALL 0x01
94 #define HAVE_VOLUME_PERF_BYTES_READ 0x0010
95 #define HAVE_VOLUME_PERF_BYTES_WRITE 0x0020
96 #define HAVE_VOLUME_PERF_OPS_READ 0x0040
97 #define HAVE_VOLUME_PERF_OPS_WRITE 0x0080
98 #define HAVE_VOLUME_PERF_LATENCY_READ 0x0100
99 #define HAVE_VOLUME_PERF_LATENCY_WRITE 0x0200
100 #define HAVE_VOLUME_PERF_ALL 0x03F0
105 uint64_t write_bytes;
108 uint64_t read_latency;
109 uint64_t write_latency;
110 } per_volume_perf_data_t;
112 #define VOLUME_INIT 0x01
113 #define VOLUME_DF 0x02
114 #define VOLUME_SNAP 0x04
122 double last_disk_busy_percent;
123 uint64_t last_disk_busy;
124 uint64_t last_base_for_disk_busy;
125 } per_disk_perf_data_t;
127 typedef struct service_config_s {
129 service_handler_t *handler;
134 struct service_config_s *next;
137 #define SERVICE_INIT {0, 0, 1, 1, 0, 0, 0}
139 typedef struct volume_s {
141 per_volume_perf_data_t perf_data;
142 per_volume_data_t volume_data;
143 struct volume_s *next;
147 * \brief A disk in the netapp.
149 * A disk doesn't have any more information than its name atm.
150 * The name includes the "disk_" prefix.
153 typedef struct disk_s {
155 per_disk_perf_data_t perf_data;
159 #define DISK_INIT {0, {0, 0, 0, 0}, 0}
161 struct host_config_s {
164 na_server_transport_t protocol;
170 service_config_t *services;
173 struct host_config_s *next;
176 #define HOST_INIT {0, 0, NA_SERVER_TRANSPORT_HTTPS, 0, 0, 0, 0, 10, 0, 0, 0}
178 static host_config_t *host_config;
180 static volume_t *get_volume (host_config_t *host, const char *name, /* {{{ */
181 uint32_t vol_data_flags, uint32_t vol_perf_flags)
188 /* Make sure the default flags include the init-bit. */
189 if (vol_data_flags != 0)
190 vol_data_flags |= VOLUME_INIT;
191 if (vol_perf_flags != 0)
192 vol_perf_flags |= CFG_VOLUME_PERF_INIT;
194 for (v = host->volumes; v; v = v->next) {
195 if (strcmp(v->name, name) != 0)
198 /* Check if the flags have been initialized. */
199 if (((v->volume_data.flags & VOLUME_INIT) == 0)
200 && (vol_data_flags != 0))
201 v->volume_data.flags = vol_data_flags;
202 if (((v->perf_data.flags & CFG_VOLUME_PERF_INIT) == 0)
203 && (vol_perf_flags != 0))
204 v->perf_data.flags = vol_perf_flags;
209 DEBUG ("netapp plugin: Allocating new entry for volume %s.", name);
210 v = malloc(sizeof(*v));
213 memset (v, 0, sizeof (*v));
215 v->volume_data.flags = vol_data_flags;
216 v->perf_data.flags = vol_perf_flags;
218 v->name = strdup(name);
219 if (v->name == NULL) {
224 v->next = host->volumes;
228 } /* }}} volume_t *get_volume */
230 static disk_t *get_disk(host_config_t *host, const char *name) /* {{{ */
232 disk_t *v, init = DISK_INIT;
237 for (v = host->disks; v; v = v->next) {
238 if (strcmp(v->name, name) == 0)
241 v = malloc(sizeof(*v));
246 v->name = strdup(name);
247 if (v->name == NULL) {
252 v->next = host->disks;
256 } /* }}} disk_t *get_disk */
258 static int submit_values (const char *host, /* {{{ */
259 const char *plugin_inst,
260 const char *type, const char *type_inst,
261 value_t *values, int values_len,
264 value_list_t vl = VALUE_LIST_INIT;
267 vl.values_len = values_len;
273 sstrncpy (vl.host, host, sizeof (vl.host));
275 sstrncpy (vl.host, hostname_g, sizeof (vl.host));
276 sstrncpy (vl.plugin, "netapp", sizeof (vl.plugin));
277 if (plugin_inst != NULL)
278 sstrncpy (vl.plugin_instance, plugin_inst, sizeof (vl.plugin_instance));
279 sstrncpy (vl.type, type, sizeof (vl.type));
280 if (type_inst != NULL)
281 sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
283 return (plugin_dispatch_values (&vl));
284 } /* }}} int submit_uint64 */
286 static int submit_two_counters (const char *host, const char *plugin_inst, /* {{{ */
287 const char *type, const char *type_inst, counter_t val0, counter_t val1,
292 values[0].counter = val0;
293 values[1].counter = val1;
295 return (submit_values (host, plugin_inst, type, type_inst,
296 values, 2, timestamp));
297 } /* }}} int submit_two_counters */
299 static int submit_counter (const char *host, const char *plugin_inst, /* {{{ */
300 const char *type, const char *type_inst, counter_t counter, time_t timestamp)
306 return (submit_values (host, plugin_inst, type, type_inst,
308 } /* }}} int submit_counter */
310 static int submit_two_gauge (const char *host, const char *plugin_inst, /* {{{ */
311 const char *type, const char *type_inst, gauge_t val0, gauge_t val1,
316 values[0].gauge = val0;
317 values[1].gauge = val1;
319 return (submit_values (host, plugin_inst, type, type_inst,
320 values, 2, timestamp));
321 } /* }}} int submit_two_gauge */
323 static int submit_double (const char *host, const char *plugin_inst, /* {{{ */
324 const char *type, const char *type_inst, double d, time_t timestamp)
328 v.gauge = (gauge_t) d;
330 return (submit_values (host, plugin_inst, type, type_inst,
332 } /* }}} int submit_uint64 */
334 static int submit_cache_ratio (const char *host, /* {{{ */
335 const char *plugin_inst,
336 const char *type_inst,
340 uint64_t *old_misses,
345 if ((new_hits >= (*old_hits)) && (new_misses >= (*old_misses))) {
349 hits = new_hits - (*old_hits);
350 misses = new_misses - (*old_misses);
352 v.gauge = 100.0 * ((gauge_t) hits) / ((gauge_t) (hits + misses));
357 *old_hits = new_hits;
358 *old_misses = new_misses;
360 return (submit_values (host, plugin_inst, "cache_ratio", type_inst,
362 } /* }}} int submit_cache_ratio */
364 static int submit_volume_perf_data (const host_config_t *host, /* {{{ */
366 const per_volume_perf_data_t *new_data)
368 /* Check for and submit disk-octet values */
369 if (HAS_ALL_FLAGS (volume->perf_data.flags, CFG_VOLUME_PERF_IO)
370 && HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_BYTES_READ | HAVE_VOLUME_PERF_BYTES_WRITE))
372 submit_two_counters (host->name, volume->name, "disk_octets", /* type instance = */ NULL,
373 (counter_t) new_data->read_bytes, (counter_t) new_data->write_bytes, new_data->timestamp);
376 /* Check for and submit disk-operations values */
377 if (HAS_ALL_FLAGS (volume->perf_data.flags, CFG_VOLUME_PERF_OPS)
378 && HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE))
380 submit_two_counters (host->name, volume->name, "disk_ops", /* type instance = */ NULL,
381 (counter_t) new_data->read_ops, (counter_t) new_data->write_ops, new_data->timestamp);
384 /* Check for, calculate and submit disk-latency values */
385 if (HAS_ALL_FLAGS (volume->perf_data.flags, CFG_VOLUME_PERF_LATENCY
386 | HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE
387 | HAVE_VOLUME_PERF_LATENCY_READ | HAVE_VOLUME_PERF_LATENCY_WRITE)
388 && HAS_ALL_FLAGS (new_data->flags, HAVE_VOLUME_PERF_OPS_READ | HAVE_VOLUME_PERF_OPS_WRITE
389 | HAVE_VOLUME_PERF_LATENCY_READ | HAVE_VOLUME_PERF_LATENCY_WRITE))
391 gauge_t latency_per_op_read;
392 gauge_t latency_per_op_write;
394 latency_per_op_read = NAN;
395 latency_per_op_write = NAN;
397 /* Check if a counter wrapped around. */
398 if ((new_data->read_ops > volume->perf_data.read_ops)
399 && (new_data->read_latency > volume->perf_data.read_latency))
401 uint64_t diff_ops_read;
402 uint64_t diff_latency_read;
404 diff_ops_read = new_data->read_ops - volume->perf_data.read_ops;
405 diff_latency_read = new_data->read_latency - volume->perf_data.read_latency;
407 if (diff_ops_read > 0)
408 latency_per_op_read = ((gauge_t) diff_latency_read) / ((gauge_t) diff_ops_read);
411 if ((new_data->write_ops > volume->perf_data.write_ops)
412 && (new_data->write_latency > volume->perf_data.write_latency))
414 uint64_t diff_ops_write;
415 uint64_t diff_latency_write;
417 diff_ops_write = new_data->write_ops - volume->perf_data.write_ops;
418 diff_latency_write = new_data->write_latency - volume->perf_data.write_latency;
420 if (diff_ops_write > 0)
421 latency_per_op_write = ((gauge_t) diff_latency_write) / ((gauge_t) diff_ops_write);
424 submit_two_gauge (host->name, volume->name, "disk_latency", /* type instance = */ NULL,
425 latency_per_op_read, latency_per_op_write, new_data->timestamp);
428 /* Clear all HAVE_* flags. */
429 volume->perf_data.flags &= ~HAVE_VOLUME_PERF_ALL;
431 /* Copy all counters */
432 volume->perf_data.timestamp = new_data->timestamp;
433 volume->perf_data.read_bytes = new_data->read_bytes;
434 volume->perf_data.write_bytes = new_data->write_bytes;
435 volume->perf_data.read_ops = new_data->read_ops;
436 volume->perf_data.write_ops = new_data->write_ops;
437 volume->perf_data.read_latency = new_data->read_latency;
438 volume->perf_data.write_latency = new_data->write_latency;
440 /* Copy the HAVE_* flags */
441 volume->perf_data.flags |= (new_data->flags & HAVE_VOLUME_PERF_ALL);
444 } /* }}} int submit_volume_perf_data */
446 static void collect_perf_wafl_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
447 perf_wafl_data_t *wafl = data;
448 uint64_t name_cache_hit = 0, name_cache_miss = 0;
449 uint64_t find_dir_hit = 0, find_dir_miss = 0;
450 uint64_t buf_hash_hit = 0, buf_hash_miss = 0;
451 uint64_t inode_cache_hit = 0, inode_cache_miss = 0;
452 const char *plugin_inst;
456 timestamp = (time_t) na_child_get_uint64(out, "timestamp", 0);
457 out = na_elem_child(na_elem_child(out, "instances"), "instance-data");
458 plugin_inst = na_child_get_string(out, "name");
460 /* Iterate over all counters */
461 na_elem_iter_t iter = na_child_iterator(na_elem_child(out, "counters"));
462 for (counter = na_iterator_next(&iter); counter; counter = na_iterator_next(&iter)) {
465 name = na_child_get_string(counter, "name");
466 if (!strcmp(name, "name_cache_hit"))
467 name_cache_hit = na_child_get_uint64(counter, "value", UINT64_MAX);
468 else if (!strcmp(name, "name_cache_miss"))
469 name_cache_miss = na_child_get_uint64(counter, "value", UINT64_MAX);
470 else if (!strcmp(name, "find_dir_hit"))
471 find_dir_hit = na_child_get_uint64(counter, "value", UINT64_MAX);
472 else if (!strcmp(name, "find_dir_miss"))
473 find_dir_miss = na_child_get_uint64(counter, "value", UINT64_MAX);
474 else if (!strcmp(name, "buf_hash_hit"))
475 buf_hash_hit = na_child_get_uint64(counter, "value", UINT64_MAX);
476 else if (!strcmp(name, "buf_hash_miss"))
477 buf_hash_miss = na_child_get_uint64(counter, "value", UINT64_MAX);
478 else if (!strcmp(name, "inode_cache_hit"))
479 inode_cache_hit = na_child_get_uint64(counter, "value", UINT64_MAX);
480 else if (!strcmp(name, "inode_cache_miss"))
481 inode_cache_miss = na_child_get_uint64(counter, "value", UINT64_MAX);
483 DEBUG("netapp plugin: Found unexpected child: %s", name);
486 /* Submit requested counters */
487 if ((wafl->flags & PERF_WAFL_NAME_CACHE)
488 && (name_cache_hit != UINT64_MAX) && (name_cache_miss != UINT64_MAX))
489 submit_cache_ratio (host->name, plugin_inst, "name_cache_hit",
490 name_cache_hit, name_cache_miss,
491 &wafl->last_name_cache_hit, &wafl->last_name_cache_miss,
494 if ((wafl->flags & PERF_WAFL_DIR_CACHE)
495 && (find_dir_hit != UINT64_MAX) && (find_dir_miss != UINT64_MAX))
496 submit_cache_ratio (host->name, plugin_inst, "find_dir_hit",
497 find_dir_hit, find_dir_miss,
498 &wafl->last_find_dir_hit, &wafl->last_find_dir_miss,
501 if ((wafl->flags & PERF_WAFL_BUF_CACHE)
502 && (buf_hash_hit != UINT64_MAX) && (buf_hash_miss != UINT64_MAX))
503 submit_cache_ratio (host->name, plugin_inst, "buf_hash_hit",
504 buf_hash_hit, buf_hash_miss,
505 &wafl->last_buf_hash_hit, &wafl->last_buf_hash_miss,
508 if ((wafl->flags & PERF_WAFL_INODE_CACHE)
509 && (inode_cache_hit != UINT64_MAX) && (inode_cache_miss != UINT64_MAX))
510 submit_cache_ratio (host->name, plugin_inst, "inode_cache_hit",
511 inode_cache_hit, inode_cache_miss,
512 &wafl->last_inode_cache_hit, &wafl->last_inode_cache_miss,
514 } /* }}} void collect_perf_wafl_data */
516 static void collect_perf_disk_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
517 perf_disk_data_t *perf = data;
520 na_elem_t *counter, *inst;
521 disk_t *disk, *worst_disk = 0;
523 timestamp = (time_t) na_child_get_uint64(out, "timestamp", 0);
524 out = na_elem_child(out, "instances");
526 /* Iterate over all children */
527 na_elem_iter_t inst_iter = na_child_iterator(out);
528 for (inst = na_iterator_next(&inst_iter); inst; inst = na_iterator_next(&inst_iter)) {
529 uint64_t disk_busy = 0;
530 uint64_t base_for_disk_busy = 0;
532 disk = get_disk(host, na_child_get_string(inst, "name"));
536 /* Look for the "disk_busy" and "base_for_disk_busy" counters */
537 na_elem_iter_t count_iter = na_child_iterator(na_elem_child(inst, "counters"));
538 for (counter = na_iterator_next(&count_iter); counter; counter = na_iterator_next(&count_iter)) {
539 name = na_child_get_string(counter, "name");
543 if (strcmp(name, "disk_busy") == 0)
544 disk_busy = na_child_get_uint64(counter, "value", UINT64_MAX);
545 else if (strcmp(name, "base_for_disk_busy") == 0)
546 base_for_disk_busy = na_child_get_uint64(counter, "value", UINT64_MAX);
549 if ((disk_busy == UINT64_MAX) || (base_for_disk_busy == UINT64_MAX))
551 disk->perf_data.last_disk_busy = 0;
552 disk->perf_data.last_base_for_disk_busy = 0;
556 disk->perf_data.last_update = timestamp;
557 if ((disk_busy >= disk->perf_data.last_disk_busy)
558 && (base_for_disk_busy >= disk->perf_data.last_base_for_disk_busy))
560 uint64_t disk_busy_diff;
563 disk_busy_diff = disk_busy - disk->perf_data.last_disk_busy;
564 base_diff = base_for_disk_busy - disk->perf_data.last_base_for_disk_busy;
567 disk->perf_data.last_disk_busy_percent = NAN;
569 disk->perf_data.last_disk_busy_percent = 100.0
570 * ((gauge_t) disk_busy_diff) / ((gauge_t) base_diff);
574 disk->perf_data.last_disk_busy_percent = NAN;
577 disk->perf_data.last_disk_busy = disk_busy;
578 disk->perf_data.last_base_for_disk_busy = base_for_disk_busy;
580 if ((worst_disk == NULL)
581 || (worst_disk->perf_data.last_disk_busy_percent < disk->perf_data.last_disk_busy_percent))
585 if ((perf->flags & PERF_DISK_BUSIEST) && (worst_disk != NULL))
586 submit_double (host->name, "system", "percent", "disk_busy",
587 worst_disk->perf_data.last_disk_busy_percent, timestamp);
588 } /* }}} void collect_perf_disk_data */
590 static void collect_volume_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
593 cfg_volume_data_t *cfg_volume_data = data;
595 out = na_elem_child(out, "volumes");
596 na_elem_iter_t inst_iter = na_child_iterator(out);
597 for (inst = na_iterator_next(&inst_iter); inst; inst = na_iterator_next(&inst_iter)) {
598 uint64_t size_free = 0, size_used = 0, snap_reserved = 0;
601 const char *sis_state;
602 uint64_t sis_saved_reported;
605 volume = get_volume(host, na_child_get_string(inst, "name"),
606 cfg_volume_data->flags, /* perf_flags = */ 0);
610 if (!(volume->volume_data.flags & VOLUME_DF))
613 /* 2^4 exa-bytes? This will take a while ;) */
614 size_free = na_child_get_uint64(inst, "size-available", UINT64_MAX);
615 if (size_free != UINT64_MAX)
616 submit_double (host->name, volume->name, "df_complex", "used",
617 (double) size_used, /* time = */ 0);
619 size_used = na_child_get_uint64(inst, "size-used", UINT64_MAX);
620 if (size_free != UINT64_MAX)
621 submit_double (host->name, volume->name, "df_complex", "free",
622 (double) size_free, /* time = */ 0);
624 snap_reserved = na_child_get_uint64(inst, "snapshot-blocks-reserved", UINT64_MAX);
625 if (snap_reserved != UINT64_MAX)
626 /* 1 block == 1024 bytes as per API docs */
627 submit_double (host->name, volume->name, "df_complex", "snap_reserved",
628 (double) (1024 * snap_reserved), /* time = */ 0);
630 sis = na_elem_child(inst, "sis");
634 sis_state = na_child_get_string(sis, "state");
635 if ((sis_state == NULL)
636 || (strcmp ("enabled", sis_state) != 0))
639 sis_saved_reported = na_child_get_uint64(sis, "size-saved", UINT64_MAX);
640 if (sis_saved_reported == UINT64_MAX)
643 /* size-saved is actually a 32 bit number, so ... time for some guesswork. */
644 if ((sis_saved_reported >> 32) != 0) {
645 /* In case they ever fix this bug. */
646 sis_saved = sis_saved_reported;
648 uint64_t sis_saved_percent;
649 uint64_t sis_saved_guess;
650 uint64_t overflow_guess;
651 uint64_t guess1, guess2, guess3;
653 sis_saved_percent = na_child_get_uint64(sis, "percentage-saved", UINT64_MAX);
654 if (sis_saved_percent > 100)
657 /* The "size-saved" value is a 32bit unsigned integer. This is a bug and
658 * will hopefully be fixed in later versions. To work around the bug, try
659 * to figure out how often the 32bit integer wrapped around by using the
660 * "percentage-saved" value. Because the percentage is in the range
661 * [0-100], this should work as long as the saved space does not exceed
663 /* percentage-saved = size-saved / (size-saved + size-used) */
664 if (sis_saved_percent < 100)
665 sis_saved_guess = size_used * sis_saved_percent / (100 - sis_saved_percent);
667 sis_saved_guess = size_used;
669 overflow_guess = sis_saved_guess >> 32;
670 guess1 = overflow_guess ? ((overflow_guess - 1) << 32) + sis_saved_reported : sis_saved_reported;
671 guess2 = (overflow_guess << 32) + sis_saved_reported;
672 guess3 = ((overflow_guess + 1) << 32) + sis_saved_reported;
674 if (sis_saved_guess < guess2) {
675 if ((sis_saved_guess - guess1) < (guess2 - sis_saved_guess))
680 if ((sis_saved_guess - guess2) < (guess3 - sis_saved_guess))
685 } /* end of 32-bit workaround */
687 submit_double (host->name, volume->name, "df_complex", "sis_saved",
688 (double) sis_saved, /* time = */ 0);
690 } /* }}} void collect_volume_data */
692 static void query_volume_perf_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
693 cfg_volume_perf_t *perf = data;
695 na_elem_t *counter, *inst;
697 timestamp = (time_t) na_child_get_uint64(out, "timestamp", 0);
699 out = na_elem_child(out, "instances");
700 na_elem_iter_t inst_iter = na_child_iterator(out);
701 for (inst = na_iterator_next(&inst_iter); inst; inst = na_iterator_next(&inst_iter)) {
702 per_volume_perf_data_t perf_data;
705 memset (&perf_data, 0, sizeof (perf_data));
706 perf_data.timestamp = timestamp;
708 volume = get_volume(host, na_child_get_string(inst, "name"),
709 /* data_flags = */ 0, perf->flags);
713 na_elem_iter_t count_iter = na_child_iterator(na_elem_child(inst, "counters"));
714 for (counter = na_iterator_next(&count_iter); counter; counter = na_iterator_next(&count_iter)) {
718 name = na_child_get_string(counter, "name");
722 value = na_child_get_uint64(counter, "value", UINT64_MAX);
723 if (value == UINT64_MAX)
726 if (!strcmp(name, "read_data")) {
727 perf_data.read_bytes = value;
728 perf_data.flags |= HAVE_VOLUME_PERF_BYTES_READ;
729 } else if (!strcmp(name, "write_data")) {
730 perf_data.write_bytes = value;
731 perf_data.flags |= HAVE_VOLUME_PERF_BYTES_WRITE;
732 } else if (!strcmp(name, "read_ops")) {
733 perf_data.read_ops = value;
734 perf_data.flags |= HAVE_VOLUME_PERF_OPS_READ;
735 } else if (!strcmp(name, "write_ops")) {
736 perf_data.write_ops = value;
737 perf_data.flags |= HAVE_VOLUME_PERF_OPS_WRITE;
738 } else if (!strcmp(name, "read_latency")) {
739 perf_data.read_latency = value;
740 perf_data.flags |= HAVE_VOLUME_PERF_LATENCY_READ;
741 } else if (!strcmp(name, "write_latency")) {
742 perf_data.write_latency = value;
743 perf_data.flags |= HAVE_VOLUME_PERF_LATENCY_WRITE;
747 submit_volume_perf_data (host, volume, &perf_data);
749 } /* }}} void query_volume_perf_data */
751 static void collect_perf_system_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
752 counter_t disk_read = 0, disk_written = 0;
753 counter_t net_recv = 0, net_sent = 0;
754 counter_t cpu_busy = 0, cpu_total = 0;
755 unsigned int counter_flags = 0;
757 perf_system_data_t *perf = data;
758 const char *instance;
762 timestamp = (time_t) na_child_get_uint64(out, "timestamp", 0);
763 out = na_elem_child(na_elem_child(out, "instances"), "instance-data");
764 instance = na_child_get_string(out, "name");
766 na_elem_iter_t iter = na_child_iterator(na_elem_child(out, "counters"));
767 for (counter = na_iterator_next(&iter); counter; counter = na_iterator_next(&iter)) {
771 name = na_child_get_string(counter, "name");
775 value = na_child_get_uint64(counter, "value", UINT64_MAX);
776 if (value == UINT64_MAX)
779 if (!strcmp(name, "disk_data_read")) {
780 disk_read = (counter_t) (value * 1024);
781 counter_flags |= 0x01;
782 } else if (!strcmp(name, "disk_data_written")) {
783 disk_written = (counter_t) (value * 1024);
784 counter_flags |= 0x02;
785 } else if (!strcmp(name, "net_data_recv")) {
786 net_recv = (counter_t) (value * 1024);
787 counter_flags |= 0x04;
788 } else if (!strcmp(name, "net_data_sent")) {
789 net_sent = (counter_t) (value * 1024);
790 counter_flags |= 0x08;
791 } else if (!strcmp(name, "cpu_busy")) {
792 cpu_busy = (counter_t) value;
793 counter_flags |= 0x10;
794 } else if (!strcmp(name, "cpu_elapsed_time")) {
795 cpu_total = (counter_t) value;
796 counter_flags |= 0x20;
797 } else if ((perf->flags & PERF_SYSTEM_OPS)
798 && (strlen(name) > 4)
799 && (!strcmp(name + strlen(name) - 4, "_ops"))) {
800 submit_counter (host->name, instance, "disk_ops_complex", name,
801 (counter_t) value, timestamp);
803 } /* for (counter) */
805 if ((perf->flags & PERF_SYSTEM_DISK)
806 && ((counter_flags & 0x03) == 0x03))
807 submit_two_counters (host->name, instance, "disk_octets", NULL,
808 disk_read, disk_written, timestamp);
810 if ((perf->flags & PERF_SYSTEM_NET)
811 && ((counter_flags & 0x0c) == 0x0c))
812 submit_two_counters (host->name, instance, "if_octets", NULL,
813 net_recv, net_sent, timestamp);
815 if ((perf->flags & PERF_SYSTEM_CPU)
816 && ((counter_flags & 0x30) == 0x30)) {
817 submit_counter (host->name, instance, "cpu", "system",
818 cpu_busy, timestamp);
819 submit_counter (host->name, instance, "cpu", "idle",
820 cpu_total - cpu_busy, timestamp);
822 } /* }}} void collect_perf_system_data */
824 static int config_init(void) { /* {{{ */
828 service_config_t *service;
831 WARNING("netapp plugin: Plugin loaded but no hosts defined.");
835 if (!na_startup(err, sizeof(err))) {
836 ERROR("netapp plugin: Error initializing netapp API: %s", err);
840 for (host = host_config; host; host = host->next) {
841 host->srv = na_server_open(host->host, 1, 1);
842 na_server_set_transport_type(host->srv, host->protocol, 0);
843 na_server_set_port(host->srv, host->port);
844 na_server_style(host->srv, NA_STYLE_LOGIN_PASSWORD);
845 na_server_adminuser(host->srv, host->username, host->password);
846 na_server_set_timeout(host->srv, 5);
847 for (service = host->services; service; service = service->next) {
848 service->interval = host->interval * service->multiplier;
849 if (service->handler == collect_perf_system_data) {
850 service->query = na_elem_new("perf-object-get-instances");
851 na_child_add_string(service->query, "objectname", "system");
852 } else if (service->handler == query_volume_perf_data) {
853 service->query = na_elem_new("perf-object-get-instances");
854 na_child_add_string(service->query, "objectname", "volume");
855 /* e = na_elem_new("instances");
856 na_child_add_string(e, "foo", "system");
857 na_child_add(root, e);*/
858 e = na_elem_new("counters");
859 na_child_add_string(e, "foo", "read_ops");
860 na_child_add_string(e, "foo", "write_ops");
861 na_child_add_string(e, "foo", "read_data");
862 na_child_add_string(e, "foo", "write_data");
863 na_child_add_string(e, "foo", "read_latency");
864 na_child_add_string(e, "foo", "write_latency");
865 na_child_add(service->query, e);
866 } else if (service->handler == collect_perf_wafl_data) {
867 service->query = na_elem_new("perf-object-get-instances");
868 na_child_add_string(service->query, "objectname", "wafl");
869 /* e = na_elem_new("instances");
870 na_child_add_string(e, "foo", "system");
871 na_child_add(root, e);*/
872 e = na_elem_new("counters");
873 na_child_add_string(e, "foo", "name_cache_hit");
874 na_child_add_string(e, "foo", "name_cache_miss");
875 na_child_add_string(e, "foo", "find_dir_hit");
876 na_child_add_string(e, "foo", "find_dir_miss");
877 na_child_add_string(e, "foo", "buf_hash_hit");
878 na_child_add_string(e, "foo", "buf_hash_miss");
879 na_child_add_string(e, "foo", "inode_cache_hit");
880 na_child_add_string(e, "foo", "inode_cache_miss");
881 /* na_child_add_string(e, "foo", "inode_eject_time"); */
882 /* na_child_add_string(e, "foo", "buf_eject_time"); */
883 na_child_add(service->query, e);
884 } else if (service->handler == collect_perf_disk_data) {
885 service->query = na_elem_new("perf-object-get-instances");
886 na_child_add_string(service->query, "objectname", "disk");
887 e = na_elem_new("counters");
888 na_child_add_string(e, "foo", "disk_busy");
889 na_child_add_string(e, "foo", "base_for_disk_busy");
890 na_child_add(service->query, e);
891 } else if (service->handler == collect_volume_data) {
892 service->query = na_elem_new("volume-list-info");
893 /* na_child_add_string(service->query, "objectname", "volume"); */
894 /* } else if (service->handler == collect_snapshot_data) { */
895 /* service->query = na_elem_new("snapshot-list-info"); */
900 } /* }}} int config_init */
902 static int config_bool_to_flag (const oconfig_item_t *ci, /* {{{ */
903 uint32_t *flags, uint32_t flag)
905 if ((ci == NULL) || (flags == NULL))
908 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_BOOLEAN))
910 WARNING ("netapp plugin: The %s option needs exactly one boolean argument.",
915 if (ci->values[0].value.boolean)
921 } /* }}} int config_bool_to_flag */
923 static int config_get_multiplier (const oconfig_item_t *ci, /* {{{ */
924 service_config_t *service)
928 if ((ci == NULL) || (service == NULL))
931 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_NUMBER))
933 WARNING ("netapp plugin: The `Multiplier' option needs exactly one numeric argument.");
937 tmp = (int) (ci->values[0].value.number + .5);
940 WARNING ("netapp plugin: The `Multiplier' option needs a positive integer argument.");
944 service->multiplier = tmp;
945 service->skip_countdown = tmp;
948 } /* }}} int config_get_multiplier */
950 static void set_global_perf_vol_flag(const host_config_t *host, /* {{{ */
951 uint32_t flag, _Bool set)
955 for (v = host->volumes; v; v = v->next) {
957 v->perf_data.flags |= flag;
959 v->perf_data.flags &= ~flag;
961 } /* }}} void set_global_perf_vol_flag */
963 static void set_global_vol_flag(const host_config_t *host, /* {{{ */
964 uint32_t flag, _Bool set) {
967 for (v = host->volumes; v; v = v->next) {
969 v->volume_data.flags |= flag;
971 v->volume_data.flags &= ~flag;
973 } /* }}} void set_global_vol_flag */
975 static void process_perf_volume_flag (host_config_t *host, /* {{{ */
976 cfg_volume_perf_t *perf_volume, const oconfig_item_t *item,
981 for (i = 0; i < item->values_num; ++i) {
986 if (item->values[i].type != OCONFIG_TYPE_STRING) {
987 WARNING("netapp plugin: Ignoring non-string argument in "
988 "\"GetVolumePerfData\" block for host %s", host->name);
992 name = item->values[i].value.string;
993 if (name[0] == '+') {
996 } else if (name[0] == '-') {
1003 perf_volume->flags |= flag;
1004 else /* if (!set) */
1005 perf_volume->flags &= ~flag;
1007 set_global_perf_vol_flag(host, flag, set);
1011 v = get_volume (host, name, /* data_flags = */ 0, perf_volume->flags);
1016 v->perf_data.flags |= flag;
1017 else /* if (!set) */
1018 v->perf_data.flags &= ~flag;
1019 } /* for (i = 0 .. item->values_num) */
1020 } /* }}} void process_perf_volume_flag */
1022 static void process_volume_flag (host_config_t *host, /* {{{ */
1023 cfg_volume_data_t *cfg_volume_data, const oconfig_item_t *item, uint32_t flag)
1027 for (i = 0; i < item->values_num; ++i) {
1032 if (item->values[i].type != OCONFIG_TYPE_STRING) {
1033 WARNING("netapp plugin: Ignoring non-string argument in \"GetVolData\""
1034 "block for host %s", host->name);
1038 name = item->values[i].value.string;
1039 if (name[0] == '+') {
1042 } else if (name[0] == '-') {
1049 cfg_volume_data->flags |= flag;
1050 else /* if (!set) */
1051 cfg_volume_data->flags &= ~flag;
1053 set_global_vol_flag(host, flag, set);
1057 v = get_volume(host, name, cfg_volume_data->flags, /* perf_flags = */ 0);
1061 if (!v->volume_data.flags)
1062 v->volume_data.flags = cfg_volume_data->flags;
1065 v->volume_data.flags |= flag;
1066 else /* if (!set) */
1067 v->volume_data.flags &= ~flag;
1069 } /* }}} void process_volume_flag */
1071 static void build_perf_vol_config(host_config_t *host, const oconfig_item_t *ci) {
1072 int i, had_io = 0, had_ops = 0, had_latency = 0;
1073 service_config_t *service;
1074 cfg_volume_perf_t *perf_volume;
1076 service = malloc(sizeof(*service));
1078 service->handler = query_volume_perf_data;
1079 perf_volume = service->data = malloc(sizeof(*perf_volume));
1080 perf_volume->flags = CFG_VOLUME_PERF_INIT;
1081 service->next = host->services;
1082 host->services = service;
1083 for (i = 0; i < ci->children_num; ++i) {
1084 oconfig_item_t *item = ci->children + i;
1086 /* if (!item || !item->key || !*item->key) continue; */
1087 if (!strcasecmp(item->key, "Multiplier")) {
1088 config_get_multiplier (item, service);
1089 } else if (!strcasecmp(item->key, "GetIO")) {
1091 process_perf_volume_flag(host, perf_volume, item, CFG_VOLUME_PERF_IO);
1092 } else if (!strcasecmp(item->key, "GetOps")) {
1094 process_perf_volume_flag(host, perf_volume, item, CFG_VOLUME_PERF_OPS);
1095 } else if (!strcasecmp(item->key, "GetLatency")) {
1097 process_perf_volume_flag(host, perf_volume, item, CFG_VOLUME_PERF_LATENCY);
1101 perf_volume->flags |= CFG_VOLUME_PERF_IO;
1102 set_global_perf_vol_flag(host, CFG_VOLUME_PERF_IO, /* set = */ true);
1105 perf_volume->flags |= CFG_VOLUME_PERF_OPS;
1106 set_global_perf_vol_flag(host, CFG_VOLUME_PERF_OPS, /* set = */ true);
1109 perf_volume->flags |= CFG_VOLUME_PERF_LATENCY;
1110 set_global_perf_vol_flag(host, CFG_VOLUME_PERF_LATENCY, /* set = */ true);
1114 static void build_volume_config(host_config_t *host, oconfig_item_t *ci) {
1116 service_config_t *service;
1117 cfg_volume_data_t *cfg_volume_data;
1119 service = malloc(sizeof(*service));
1121 service->handler = collect_volume_data;
1122 cfg_volume_data = service->data = malloc(sizeof(*cfg_volume_data));
1123 cfg_volume_data->flags = VOLUME_INIT;
1124 service->next = host->services;
1125 host->services = service;
1126 for (i = 0; i < ci->children_num; ++i) {
1127 oconfig_item_t *item = ci->children + i;
1129 /* if (!item || !item->key || !*item->key) continue; */
1130 if (!strcasecmp(item->key, "Multiplier")) {
1131 config_get_multiplier (item, service);
1132 } else if (!strcasecmp(item->key, "GetDiskUtil")) {
1134 process_volume_flag(host, cfg_volume_data, item, VOLUME_DF);
1138 cfg_volume_data->flags |= VOLUME_DF;
1139 set_global_vol_flag(host, VOLUME_DF, /* set = */ true);
1143 static void build_perf_disk_config(host_config_t *temp, oconfig_item_t *ci) {
1145 service_config_t *service;
1146 perf_disk_data_t *perf_disk;
1148 service = malloc(sizeof(*service));
1150 service->handler = collect_perf_disk_data;
1151 perf_disk = service->data = malloc(sizeof(*perf_disk));
1152 perf_disk->flags = PERF_DISK_ALL;
1153 service->next = temp->services;
1154 temp->services = service;
1155 for (i = 0; i < ci->children_num; ++i) {
1156 oconfig_item_t *item = ci->children + i;
1158 /* if (!item || !item->key || !*item->key) continue; */
1159 if (!strcasecmp(item->key, "Multiplier")) {
1160 config_get_multiplier (item, service);
1161 } else if (!strcasecmp(item->key, "GetBusy")) {
1162 config_bool_to_flag (item, &perf_disk->flags, PERF_SYSTEM_CPU);
1167 static void build_perf_wafl_config(host_config_t *temp, oconfig_item_t *ci) {
1169 service_config_t *service;
1170 perf_wafl_data_t *perf_wafl;
1172 service = malloc(sizeof(*service));
1174 service->handler = collect_perf_wafl_data;
1175 perf_wafl = service->data = malloc(sizeof(*perf_wafl));
1176 perf_wafl->flags = PERF_WAFL_ALL;
1177 perf_wafl->last_name_cache_hit = 0;
1178 perf_wafl->last_name_cache_miss = 0;
1179 perf_wafl->last_find_dir_hit = 0;
1180 perf_wafl->last_find_dir_miss = 0;
1181 perf_wafl->last_buf_hash_hit = 0;
1182 perf_wafl->last_buf_hash_miss = 0;
1183 perf_wafl->last_inode_cache_hit = 0;
1184 perf_wafl->last_inode_cache_miss = 0;
1185 service->next = temp->services;
1186 temp->services = service;
1187 for (i = 0; i < ci->children_num; ++i) {
1188 oconfig_item_t *item = ci->children + i;
1190 /* if (!item || !item->key || !*item->key) continue; */
1191 if (!strcasecmp(item->key, "Multiplier")) {
1192 config_get_multiplier (item, service);
1193 } else if (!strcasecmp(item->key, "GetNameCache")) {
1194 config_bool_to_flag (item, &perf_wafl->flags, PERF_WAFL_NAME_CACHE);
1195 } else if (!strcasecmp(item->key, "GetDirCache")) {
1196 config_bool_to_flag (item, &perf_wafl->flags, PERF_WAFL_DIR_CACHE);
1197 } else if (!strcasecmp(item->key, "GetBufCache")) {
1198 config_bool_to_flag (item, &perf_wafl->flags, PERF_WAFL_BUF_CACHE);
1199 } else if (!strcasecmp(item->key, "GetInodeCache")) {
1200 config_bool_to_flag (item, &perf_wafl->flags, PERF_WAFL_INODE_CACHE);
1202 WARNING ("netapp plugin: The %s config option is not allowed within "
1203 "`GetWaflPerfData' blocks.", item->key);
1208 static int build_perf_sys_config (host_config_t *host, /* {{{ */
1209 oconfig_item_t *ci, const service_config_t *default_service)
1212 service_config_t *service;
1213 perf_system_data_t *perf_system;
1215 service = malloc(sizeof(*service));
1216 if (service == NULL)
1218 memset (service, 0, sizeof (*service));
1219 *service = *default_service;
1220 service->handler = collect_perf_system_data;
1222 perf_system = malloc(sizeof(*perf_system));
1223 if (perf_system == NULL) {
1227 memset (perf_system, 0, sizeof (*perf_system));
1228 perf_system->flags = PERF_SYSTEM_ALL;
1229 service->data = perf_system;
1231 for (i = 0; i < ci->children_num; ++i) {
1232 oconfig_item_t *item = ci->children + i;
1234 if (!strcasecmp(item->key, "Multiplier")) {
1235 config_get_multiplier (item, service);
1236 } else if (!strcasecmp(item->key, "GetCPULoad")) {
1237 config_bool_to_flag (item, &perf_system->flags, PERF_SYSTEM_CPU);
1238 } else if (!strcasecmp(item->key, "GetInterfaces")) {
1239 config_bool_to_flag (item, &perf_system->flags, PERF_SYSTEM_NET);
1240 } else if (!strcasecmp(item->key, "GetDiskOps")) {
1241 config_bool_to_flag (item, &perf_system->flags, PERF_SYSTEM_OPS);
1242 } else if (!strcasecmp(item->key, "GetDiskIO")) {
1243 config_bool_to_flag (item, &perf_system->flags, PERF_SYSTEM_DISK);
1245 WARNING ("netapp plugin: The %s config option is not allowed within "
1246 "`GetSystemPerfData' blocks.", item->key);
1250 service->next = host->services;
1251 host->services = service;
1254 } /* }}} int build_perf_sys_config */
1256 static host_config_t *build_host_config(const oconfig_item_t *ci, const host_config_t *default_host, const service_config_t *def_def_service) {
1258 oconfig_item_t *item;
1259 host_config_t *host, *hc, temp = *default_host;
1260 service_config_t default_service = *def_def_service;
1262 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
1263 WARNING("netapp plugin: \"Host\" needs exactly one string argument. Ignoring host block.");
1267 temp.name = ci->values[0].value.string;
1268 for (i = 0; i < ci->children_num; ++i) {
1269 item = ci->children + i;
1271 /* if (!item || !item->key || !*item->key) continue; */
1272 if (!strcasecmp(item->key, "Address")) {
1273 if ((item->values_num != 1) || (item->values[0].type != OCONFIG_TYPE_STRING)) {
1274 WARNING("netapp plugin: \"Name\" needs exactly one string argument. Ignoring host block \"%s\".", ci->values[0].value.string);
1277 temp.host = item->values[0].value.string;
1278 } else if (!strcasecmp(item->key, "Port")) {
1279 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 < 1) || (item->values[0].value.number > 65535)) {
1280 WARNING("netapp plugin: \"Port\" needs exactly one integer argument in the range of 1-65535. Ignoring host block \"%s\".", ci->values[0].value.string);
1283 temp.port = item->values[0].value.number;
1284 } else if (!strcasecmp(item->key, "Protocol")) {
1285 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"))) {
1286 WARNING("netapp plugin: \"Protocol\" needs to be either \"http\" or \"https\". Ignoring host block \"%s\".", ci->values[0].value.string);
1289 if (!strcasecmp(item->values[0].value.string, "http")) temp.protocol = NA_SERVER_TRANSPORT_HTTP;
1290 else temp.protocol = NA_SERVER_TRANSPORT_HTTPS;
1291 } else if (!strcasecmp(item->key, "Login")) {
1292 if ((item->values_num != 2) || (item->values[0].type != OCONFIG_TYPE_STRING) || (item->values[1].type != OCONFIG_TYPE_STRING)) {
1293 WARNING("netapp plugin: \"Login\" needs exactly two string arguments, username and password. Ignoring host block \"%s\".", ci->values[0].value.string);
1296 temp.username = item->values[0].value.string;
1297 temp.password = item->values[1].value.string;
1298 } else if (!strcasecmp(item->key, "Interval")) {
1299 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) {
1300 WARNING("netapp plugin: \"Interval\" of host %s needs exactly one integer argument.", ci->values[0].value.string);
1303 temp.interval = item->values[0].value.number;
1304 } else if (!strcasecmp(item->key, "GetVolumePerfData")) {
1305 build_perf_vol_config(&temp, item);
1306 } else if (!strcasecmp(item->key, "GetSystemPerfData")) {
1307 build_perf_sys_config(&temp, item, &default_service);
1308 } else if (!strcasecmp(item->key, "GetWaflPerfData")) {
1309 build_perf_wafl_config(&temp, item);
1310 } else if (!strcasecmp(item->key, "GetDiskPerfData")) {
1311 build_perf_disk_config(&temp, item);
1312 } else if (!strcasecmp(item->key, "GetVolumeData")) {
1313 build_volume_config(&temp, item);
1315 WARNING("netapp plugin: Ignoring unknown config option \"%s\" in host block \"%s\".",
1316 item->key, ci->values[0].value.string);
1320 if (!temp.host) temp.host = temp.name;
1321 if (!temp.port) temp.port = temp.protocol == NA_SERVER_TRANSPORT_HTTP ? 80 : 443;
1322 if (!temp.username) {
1323 WARNING("netapp plugin: Please supply login information for host \"%s\". Ignoring host block.", temp.name);
1326 for (hc = host_config; hc; hc = hc->next) {
1327 if (!strcasecmp(hc->name, temp.name)) WARNING("netapp plugin: Duplicate definition of host \"%s\". This is probably a bad idea.", hc->name);
1329 host = malloc(sizeof(*host));
1331 host->name = strdup(temp.name);
1332 host->protocol = temp.protocol;
1333 host->host = strdup(temp.host);
1334 host->username = strdup(temp.username);
1335 host->password = strdup(temp.password);
1336 host->next = host_config;
1341 static int build_config (oconfig_item_t *ci) {
1343 oconfig_item_t *item;
1344 host_config_t default_host = HOST_INIT;
1345 service_config_t default_service = SERVICE_INIT;
1347 for (i = 0; i < ci->children_num; ++i) {
1348 item = ci->children + i;
1350 /* if (!item || !item->key || !*item->key) continue; */
1351 if (!strcasecmp(item->key, "Host")) {
1352 build_host_config(item, &default_host, &default_service);
1354 WARNING("netapp plugin: Ignoring unknown config option \"%s\".", item->key);
1360 static int netapp_read() {
1362 host_config_t *host;
1363 service_config_t *service;
1365 for (host = host_config; host; host = host->next) {
1366 for (service = host->services; service; service = service->next) {
1367 if (--service->skip_countdown > 0) continue;
1368 service->skip_countdown = service->multiplier;
1369 out = na_server_invoke_elem(host->srv, service->query);
1370 if (na_results_status(out) != NA_OK) {
1371 int netapp_errno = na_results_errno(out);
1372 ERROR("netapp plugin: Error %d from host %s: %s", netapp_errno, host->name, na_results_reason(out));
1374 if (netapp_errno == EIO || netapp_errno == ETIMEDOUT) {
1375 /* Network problems. Just give up on all other services on this host. */
1380 service->handler(host, out, service->data);
1387 void module_register() {
1388 plugin_register_complex_config("netapp", build_config);
1389 plugin_register_init("netapp", config_init);
1390 plugin_register_read("netapp", netapp_read);
1393 /* vim: set sw=2 ts=2 noet fdm=marker : */