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 typedef struct host_config_s host_config_t;
33 typedef void service_handler_t(host_config_t *host, na_elem_t *result, void *data);
35 #define PERF_SYSTEM_CPU 0x01
36 #define PERF_SYSTEM_NET 0x02
37 #define PERF_SYSTEM_OPS 0x04
38 #define PERF_SYSTEM_DISK 0x08
39 #define PERF_SYSTEM_ALL 0x0F
42 * \brief Persistent data for system performence counters
50 * \brief Persistent data for WAFL performence counters. (a.k.a. cache performence)
53 #define PERF_WAFL_NAME_CACHE 0x01
54 #define PERF_WAFL_DIR_CACHE 0x02
55 #define PERF_WAFL_BUF_CACHE 0x04
56 #define PERF_WAFL_INODE_CACHE 0x08
57 #define PERF_WAFL_ALL 0x0F
61 uint64_t last_name_cache_hit;
62 uint64_t last_name_cache_miss;
63 uint64_t last_find_dir_hit;
64 uint64_t last_find_dir_miss;
65 uint64_t last_buf_hash_hit;
66 uint64_t last_buf_hash_miss;
67 uint64_t last_inode_cache_hit;
68 uint64_t last_inode_cache_miss;
71 #define PERF_VOLUME_INIT 0x01
72 #define PERF_VOLUME_IO 0x02
73 #define PERF_VOLUME_OPS 0x03
74 #define PERF_VOLUME_LATENCY 0x08
75 #define PERF_VOLUME_ALL 0x0F
85 #define PERF_DISK_BUSIEST 0x01
86 #define PERF_DISK_ALL 0x01
94 time_t last_timestamp;
95 uint64_t last_read_latency;
96 uint64_t last_write_latency;
97 uint64_t last_read_ops;
98 uint64_t last_write_ops;
99 } per_volume_perf_data_t;
101 #define VOLUME_INIT 0x01
102 #define VOLUME_DF 0x02
103 #define VOLUME_SNAP 0x04
111 double last_disk_busy_percent;
112 uint64_t last_disk_busy;
113 uint64_t last_base_for_disk_busy;
114 } per_disk_perf_data_t;
116 typedef struct service_config_s {
118 service_handler_t *handler;
123 struct service_config_s *next;
126 #define SERVICE_INIT {0, 0, 1, 1, 0, 0, 0}
128 typedef struct volume_s {
130 per_volume_perf_data_t perf_data;
131 per_volume_data_t volume_data;
132 struct volume_s *next;
136 * \brief A disk in the netapp.
138 * A disk doesn't have any more information than its name atm.
139 * The name includes the "disk_" prefix.
142 typedef struct disk_s {
144 per_disk_perf_data_t perf_data;
148 #define DISK_INIT {0, {0, 0, 0, 0}, 0}
150 struct host_config_s {
153 na_server_transport_t protocol;
159 service_config_t *services;
162 struct host_config_s *next;
165 #define HOST_INIT {0, 0, NA_SERVER_TRANSPORT_HTTPS, 0, 0, 0, 0, 10, 0, 0, 0}
167 static host_config_t *host_config;
169 static volume_t *get_volume (host_config_t *host, const char *name) /* {{{ */
176 for (v = host->volumes; v; v = v->next) {
177 if (strcmp(v->name, name) == 0)
181 v = malloc(sizeof(*v));
184 memset (v, 0, sizeof (*v));
186 v->name = strdup(name);
187 if (v->name == NULL) {
192 v->next = host->volumes;
196 } /* }}} volume_t *get_volume */
198 static disk_t *get_disk(host_config_t *host, const char *name) /* {{{ */
200 disk_t *v, init = DISK_INIT;
205 for (v = host->disks; v; v = v->next) {
206 if (strcmp(v->name, name) == 0)
209 v = malloc(sizeof(*v));
214 v->name = strdup(name);
215 if (v->name == NULL) {
220 v->next = host->disks;
224 } /* }}} disk_t *get_disk */
226 static int submit_values (const char *host, /* {{{ */
227 const char *plugin_inst,
228 const char *type, const char *type_inst,
229 value_t *values, int values_len,
232 value_list_t vl = VALUE_LIST_INIT;
235 vl.values_len = values_len;
241 sstrncpy (vl.host, host, sizeof (vl.host));
243 sstrncpy (vl.host, hostname_g, sizeof (vl.host));
244 sstrncpy (vl.plugin, "netapp", sizeof (vl.plugin));
245 if (plugin_inst != NULL)
246 sstrncpy (vl.plugin_instance, plugin_inst, sizeof (vl.plugin_instance));
247 sstrncpy (vl.type, type, sizeof (vl.type));
248 if (type_inst != NULL)
249 sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
251 return (plugin_dispatch_values (&vl));
252 } /* }}} int submit_uint64 */
254 static int submit_two_counters (const char *host, const char *plugin_inst, /* {{{ */
255 const char *type, const char *type_inst, counter_t val0, counter_t val1,
260 values[0].counter = val0;
261 values[1].counter = val1;
263 return (submit_values (host, plugin_inst, type, type_inst,
264 values, 2, timestamp));
265 } /* }}} int submit_two_counters */
267 static int submit_counter (const char *host, const char *plugin_inst, /* {{{ */
268 const char *type, const char *type_inst, counter_t counter, time_t timestamp)
274 return (submit_values (host, plugin_inst, type, type_inst,
276 } /* }}} int submit_counter */
278 static int submit_double (const char *host, const char *plugin_inst, /* {{{ */
279 const char *type, const char *type_inst, double d, time_t timestamp)
283 v.gauge = (gauge_t) d;
285 return (submit_values (host, plugin_inst, type, type_inst,
287 } /* }}} int submit_uint64 */
289 static int submit_cache_ratio (const char *host, /* {{{ */
290 const char *plugin_inst,
291 const char *type_inst,
295 uint64_t *old_misses,
300 if ((new_hits >= (*old_hits)) && (new_misses >= (*old_misses))) {
304 hits = new_hits - (*old_hits);
305 misses = new_misses - (*old_misses);
307 v.gauge = 100.0 * ((gauge_t) hits) / ((gauge_t) (hits + misses));
312 *old_hits = new_hits;
313 *old_misses = new_misses;
315 return (submit_values (host, plugin_inst, "cache_ratio", type_inst,
317 } /* }}} int submit_cache_ratio */
319 static void collect_perf_wafl_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
320 perf_wafl_data_t *wafl = data;
321 uint64_t name_cache_hit = 0, name_cache_miss = 0;
322 uint64_t find_dir_hit = 0, find_dir_miss = 0;
323 uint64_t buf_hash_hit = 0, buf_hash_miss = 0;
324 uint64_t inode_cache_hit = 0, inode_cache_miss = 0;
325 const char *plugin_inst;
329 timestamp = (time_t) na_child_get_uint64(out, "timestamp", 0);
330 out = na_elem_child(na_elem_child(out, "instances"), "instance-data");
331 plugin_inst = na_child_get_string(out, "name");
333 /* Iterate over all counters */
334 na_elem_iter_t iter = na_child_iterator(na_elem_child(out, "counters"));
335 for (counter = na_iterator_next(&iter); counter; counter = na_iterator_next(&iter)) {
338 name = na_child_get_string(counter, "name");
339 if (!strcmp(name, "name_cache_hit"))
340 name_cache_hit = na_child_get_uint64(counter, "value", UINT64_MAX);
341 else if (!strcmp(name, "name_cache_miss"))
342 name_cache_miss = na_child_get_uint64(counter, "value", UINT64_MAX);
343 else if (!strcmp(name, "find_dir_hit"))
344 find_dir_hit = na_child_get_uint64(counter, "value", UINT64_MAX);
345 else if (!strcmp(name, "find_dir_miss"))
346 find_dir_miss = na_child_get_uint64(counter, "value", UINT64_MAX);
347 else if (!strcmp(name, "buf_hash_hit"))
348 buf_hash_hit = na_child_get_uint64(counter, "value", UINT64_MAX);
349 else if (!strcmp(name, "buf_hash_miss"))
350 buf_hash_miss = na_child_get_uint64(counter, "value", UINT64_MAX);
351 else if (!strcmp(name, "inode_cache_hit"))
352 inode_cache_hit = na_child_get_uint64(counter, "value", UINT64_MAX);
353 else if (!strcmp(name, "inode_cache_miss"))
354 inode_cache_miss = na_child_get_uint64(counter, "value", UINT64_MAX);
356 DEBUG("netapp plugin: Found unexpected child: %s", name);
359 /* Submit requested counters */
360 if ((wafl->flags & PERF_WAFL_NAME_CACHE)
361 && (name_cache_hit != UINT64_MAX) && (name_cache_miss != UINT64_MAX))
362 submit_cache_ratio (host->name, plugin_inst, "name_cache_hit",
363 name_cache_hit, name_cache_miss,
364 &wafl->last_name_cache_hit, &wafl->last_name_cache_miss,
367 if ((wafl->flags & PERF_WAFL_DIR_CACHE)
368 && (find_dir_hit != UINT64_MAX) && (find_dir_miss != UINT64_MAX))
369 submit_cache_ratio (host->name, plugin_inst, "find_dir_hit",
370 find_dir_hit, find_dir_miss,
371 &wafl->last_find_dir_hit, &wafl->last_find_dir_miss,
374 if ((wafl->flags & PERF_WAFL_BUF_CACHE)
375 && (buf_hash_hit != UINT64_MAX) && (buf_hash_miss != UINT64_MAX))
376 submit_cache_ratio (host->name, plugin_inst, "buf_hash_hit",
377 buf_hash_hit, buf_hash_miss,
378 &wafl->last_buf_hash_hit, &wafl->last_buf_hash_miss,
381 if ((wafl->flags & PERF_WAFL_INODE_CACHE)
382 && (inode_cache_hit != UINT64_MAX) && (inode_cache_miss != UINT64_MAX))
383 submit_cache_ratio (host->name, plugin_inst, "inode_cache_hit",
384 inode_cache_hit, inode_cache_miss,
385 &wafl->last_inode_cache_hit, &wafl->last_inode_cache_miss,
387 } /* }}} void collect_perf_wafl_data */
389 static void collect_perf_disk_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
390 perf_disk_data_t *perf = data;
393 na_elem_t *counter, *inst;
394 disk_t *disk, *worst_disk = 0;
396 timestamp = (time_t) na_child_get_uint64(out, "timestamp", 0);
397 out = na_elem_child(out, "instances");
399 /* Iterate over all children */
400 na_elem_iter_t inst_iter = na_child_iterator(out);
401 for (inst = na_iterator_next(&inst_iter); inst; inst = na_iterator_next(&inst_iter)) {
402 uint64_t disk_busy = 0;
403 uint64_t base_for_disk_busy = 0;
405 disk = get_disk(host, na_child_get_string(inst, "name"));
409 /* Look for the "disk_busy" and "base_for_disk_busy" counters */
410 na_elem_iter_t count_iter = na_child_iterator(na_elem_child(inst, "counters"));
411 for (counter = na_iterator_next(&count_iter); counter; counter = na_iterator_next(&count_iter)) {
412 name = na_child_get_string(counter, "name");
416 if (strcmp(name, "disk_busy") == 0)
417 disk_busy = na_child_get_uint64(counter, "value", UINT64_MAX);
418 else if (strcmp(name, "base_for_disk_busy") == 0)
419 base_for_disk_busy = na_child_get_uint64(counter, "value", UINT64_MAX);
422 if ((disk_busy == UINT64_MAX) || (base_for_disk_busy == UINT64_MAX))
424 disk->perf_data.last_disk_busy = 0;
425 disk->perf_data.last_base_for_disk_busy = 0;
429 disk->perf_data.last_update = timestamp;
430 if ((disk_busy >= disk->perf_data.last_disk_busy)
431 && (base_for_disk_busy >= disk->perf_data.last_base_for_disk_busy))
433 uint64_t disk_busy_diff;
436 disk_busy_diff = disk_busy - disk->perf_data.last_disk_busy;
437 base_diff = base_for_disk_busy - disk->perf_data.last_base_for_disk_busy;
440 disk->perf_data.last_disk_busy_percent = NAN;
442 disk->perf_data.last_disk_busy_percent = 100.0
443 * ((gauge_t) disk_busy_diff) / ((gauge_t) base_diff);
447 disk->perf_data.last_disk_busy_percent = NAN;
450 disk->perf_data.last_disk_busy = disk_busy;
451 disk->perf_data.last_base_for_disk_busy = base_for_disk_busy;
453 if ((worst_disk == NULL)
454 || (worst_disk->perf_data.last_disk_busy_percent < disk->perf_data.last_disk_busy_percent))
458 if ((perf->flags & PERF_DISK_BUSIEST) && (worst_disk != NULL))
459 submit_double (host->name, "system", "percent", "disk_busy",
460 worst_disk->perf_data.last_disk_busy_percent, timestamp);
461 } /* }}} void collect_perf_disk_data */
463 static void collect_volume_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
466 volume_data_t *volume_data = data;
468 out = na_elem_child(out, "volumes");
469 na_elem_iter_t inst_iter = na_child_iterator(out);
470 for (inst = na_iterator_next(&inst_iter); inst; inst = na_iterator_next(&inst_iter)) {
471 uint64_t size_free = 0, size_used = 0, snap_reserved = 0;
474 const char *sis_state;
475 uint64_t sis_saved_reported;
478 volume = get_volume(host, na_child_get_string(inst, "name"));
482 if (!(volume->volume_data.flags & VOLUME_INIT))
483 volume->volume_data.flags = volume_data->flags;
485 if (!(volume->volume_data.flags & VOLUME_DF))
488 /* 2^4 exa-bytes? This will take a while ;) */
489 size_free = na_child_get_uint64(inst, "size-available", UINT64_MAX);
490 if (size_free != UINT64_MAX)
491 submit_double (host->name, volume->name, "df_complex", "used",
492 (double) size_used, /* time = */ 0);
494 size_used = na_child_get_uint64(inst, "size-used", UINT64_MAX);
495 if (size_free != UINT64_MAX)
496 submit_double (host->name, volume->name, "df_complex", "free",
497 (double) size_free, /* time = */ 0);
499 snap_reserved = na_child_get_uint64(inst, "snapshot-blocks-reserved", UINT64_MAX);
500 if (snap_reserved != UINT64_MAX)
501 /* 1 block == 1024 bytes as per API docs */
502 submit_double (host->name, volume->name, "df_complex", "snap_reserved",
503 (double) (1024 * snap_reserved), /* time = */ 0);
505 sis = na_elem_child(inst, "sis");
509 sis_state = na_child_get_string(sis, "state");
510 if ((sis_state == NULL)
511 || (strcmp ("enabled", sis_state) != 0))
514 sis_saved_reported = na_child_get_uint64(sis, "size-saved", UINT64_MAX);
515 if (sis_saved_reported == UINT64_MAX)
518 /* size-saved is actually a 32 bit number, so ... time for some guesswork. */
519 if ((sis_saved_reported >> 32) != 0) {
520 /* In case they ever fix this bug. */
521 sis_saved = sis_saved_reported;
523 uint64_t sis_saved_percent;
524 uint64_t sis_saved_guess;
525 uint64_t overflow_guess;
526 uint64_t guess1, guess2, guess3;
528 sis_saved_percent = na_child_get_uint64(sis, "percentage-saved", UINT64_MAX);
529 if (sis_saved_percent > 100)
532 /* The "size-saved" value is a 32bit unsigned integer. This is a bug and
533 * will hopefully be fixed in later versions. To work around the bug, try
534 * to figure out how often the 32bit integer wrapped around by using the
535 * "percentage-saved" value. Because the percentage is in the range
536 * [0-100], this should work as long as the saved space does not exceed
538 /* percentage-saved = size-saved / (size-saved + size-used) */
539 if (sis_saved_percent < 100)
540 sis_saved_guess = size_used * sis_saved_percent / (100 - sis_saved_percent);
542 sis_saved_guess = size_used;
544 overflow_guess = sis_saved_guess >> 32;
545 guess1 = overflow_guess ? ((overflow_guess - 1) << 32) + sis_saved_reported : sis_saved_reported;
546 guess2 = (overflow_guess << 32) + sis_saved_reported;
547 guess3 = ((overflow_guess + 1) << 32) + sis_saved_reported;
549 if (sis_saved_guess < guess2) {
550 if ((sis_saved_guess - guess1) < (guess2 - sis_saved_guess))
555 if ((sis_saved_guess - guess2) < (guess3 - sis_saved_guess))
560 } /* end of 32-bit workaround */
562 submit_double (host->name, volume->name, "df_complex", "sis_saved",
563 (double) sis_saved, /* time = */ 0);
565 } /* }}} void collect_volume_data */
567 static void collect_perf_volume_data(host_config_t *host, na_elem_t *out, void *data) {
568 perf_volume_data_t *perf = data;
571 na_elem_t *counter, *inst;
574 value_list_t vl = VALUE_LIST_INIT;
576 timestamp = (time_t) na_child_get_uint64(out, "timestamp", 0);
577 out = na_elem_child(out, "instances");
578 na_elem_iter_t inst_iter = na_child_iterator(out);
579 for (inst = na_iterator_next(&inst_iter); inst; inst = na_iterator_next(&inst_iter)) {
580 uint64_t read_data = 0, write_data = 0, read_ops = 0, write_ops = 0, read_latency = 0, write_latency = 0;
582 volume = get_volume(host, na_child_get_string(inst, "name"));
583 if (!volume->perf_data.flags) {
584 volume->perf_data.flags = perf->flags;
585 volume->perf_data.last_read_latency = volume->perf_data.last_read_ops = 0;
586 volume->perf_data.last_write_latency = volume->perf_data.last_write_ops = 0;
588 na_elem_iter_t count_iter = na_child_iterator(na_elem_child(inst, "counters"));
589 for (counter = na_iterator_next(&count_iter); counter; counter = na_iterator_next(&count_iter)) {
590 name = na_child_get_string(counter, "name");
591 if (!strcmp(name, "read_ops")) {
592 read_ops = na_child_get_uint64(counter, "value", 0);
593 } else if (!strcmp(name, "write_ops")) {
594 write_ops = na_child_get_uint64(counter, "value", 0);
595 } else if (!strcmp(name, "read_data")) {
596 read_data = na_child_get_uint64(counter, "value", 0);
597 } else if (!strcmp(name, "write_data")) {
598 write_data = na_child_get_uint64(counter, "value", 0);
599 } else if (!strcmp(name, "read_latency")) {
600 read_latency = na_child_get_uint64(counter, "value", 0);
601 } else if (!strcmp(name, "write_latency")) {
602 write_latency = na_child_get_uint64(counter, "value", 0);
605 if (read_ops && write_ops) {
606 values[0].counter = read_ops;
607 values[1].counter = write_ops;
611 vl.interval = interval_g;
612 sstrncpy(vl.plugin, "netapp", sizeof(vl.plugin));
613 sstrncpy(vl.host, host->name, sizeof(vl.host));
614 sstrncpy(vl.plugin_instance, volume->name, sizeof(vl.plugin_instance));
615 sstrncpy(vl.type, "disk_ops", sizeof(vl.type));
616 vl.type_instance[0] = 0;
617 if (volume->perf_data.flags & PERF_VOLUME_OPS) {
618 /* We might need the data even if it wasn't configured to calculate
619 the latency. Therefore we just skip the dispatch. */
620 DEBUG("%s/netapp-%s/disk_ops: %"PRIu64" %"PRIu64, host->name, volume->name, read_ops, write_ops);
621 plugin_dispatch_values(&vl);
623 if ((volume->perf_data.flags & PERF_VOLUME_LATENCY) && read_latency && write_latency) {
625 if (read_ops - volume->perf_data.last_read_ops) values[0].gauge = (read_latency - volume->perf_data.last_read_latency) * (timestamp - volume->perf_data.last_timestamp) / (read_ops - volume->perf_data.last_read_ops);
627 if (write_ops - volume->perf_data.last_write_ops) values[1].gauge = (write_latency - volume->perf_data.last_write_latency) * (timestamp - volume->perf_data.last_timestamp) / (write_ops - volume->perf_data.last_write_ops);
631 vl.interval = interval_g;
632 sstrncpy(vl.plugin, "netapp", sizeof(vl.plugin));
633 sstrncpy(vl.host, host->name, sizeof(vl.host));
634 sstrncpy(vl.plugin_instance, volume->name, sizeof(vl.plugin_instance));
635 sstrncpy(vl.type, "disk_latency", sizeof(vl.type));
636 vl.type_instance[0] = 0;
637 if (volume->perf_data.last_read_ops && volume->perf_data.last_write_ops) {
638 DEBUG("%s/netapp-%s/disk_latency: ro: %"PRIu64" lro: %"PRIu64" "
639 "rl: %"PRIu64" lrl: %"PRIu64" "
641 host->name, volume->name,
642 read_ops, volume->perf_data.last_read_ops,
643 read_latency, volume->perf_data.last_read_latency,
644 values[0].counter, values[1].counter);
645 plugin_dispatch_values(&vl);
647 volume->perf_data.last_timestamp = timestamp;
648 volume->perf_data.last_read_latency = read_latency;
649 volume->perf_data.last_read_ops = read_ops;
650 volume->perf_data.last_write_latency = write_latency;
651 volume->perf_data.last_write_ops = write_ops;
654 if ((volume->perf_data.flags & PERF_VOLUME_IO) && read_data && write_data) {
655 values[0].counter = read_data;
656 values[1].counter = write_data;
660 vl.interval = interval_g;
661 sstrncpy(vl.plugin, "netapp", sizeof(vl.plugin));
662 sstrncpy(vl.host, host->name, sizeof(vl.host));
663 sstrncpy(vl.plugin_instance, volume->name, sizeof(vl.plugin_instance));
664 sstrncpy(vl.type, "disk_octets", sizeof(vl.type));
665 vl.type_instance[0] = 0;
666 DEBUG("%s/netapp-%s/disk_octets: %"PRIu64" %"PRIu64, host->name, volume->name, read_data, write_data);
667 plugin_dispatch_values (&vl);
672 static void collect_perf_system_data(host_config_t *host, na_elem_t *out, void *data) { /* {{{ */
673 counter_t disk_read = 0, disk_written = 0;
674 counter_t net_recv = 0, net_sent = 0;
675 counter_t cpu_busy = 0, cpu_total = 0;
676 unsigned int counter_flags = 0;
678 perf_system_data_t *perf = data;
679 const char *instance;
683 timestamp = (time_t) na_child_get_uint64(out, "timestamp", 0);
684 out = na_elem_child(na_elem_child(out, "instances"), "instance-data");
685 instance = na_child_get_string(out, "name");
687 na_elem_iter_t iter = na_child_iterator(na_elem_child(out, "counters"));
688 for (counter = na_iterator_next(&iter); counter; counter = na_iterator_next(&iter)) {
692 name = na_child_get_string(counter, "name");
696 value = na_child_get_uint64(counter, "value", UINT64_MAX);
697 if (value == UINT64_MAX)
700 if (!strcmp(name, "disk_data_read")) {
701 disk_read = (counter_t) (value * 1024);
702 counter_flags |= 0x01;
703 } else if (!strcmp(name, "disk_data_written")) {
704 disk_written = (counter_t) (value * 1024);
705 counter_flags |= 0x02;
706 } else if (!strcmp(name, "net_data_recv")) {
707 net_recv = (counter_t) (value * 1024);
708 counter_flags |= 0x04;
709 } else if (!strcmp(name, "net_data_sent")) {
710 net_sent = (counter_t) (value * 1024);
711 counter_flags |= 0x08;
712 } else if (!strcmp(name, "cpu_busy")) {
713 cpu_busy = (counter_t) value;
714 counter_flags |= 0x10;
715 } else if (!strcmp(name, "cpu_elapsed_time")) {
716 cpu_total = (counter_t) value;
717 counter_flags |= 0x20;
718 } else if ((perf->flags & PERF_SYSTEM_OPS)
719 && (strlen(name) > 4)
720 && (!strcmp(name + strlen(name) - 4, "_ops"))) {
721 submit_counter (host->name, instance, "disk_ops_complex", name,
722 (counter_t) value, timestamp);
724 } /* for (counter) */
726 if ((perf->flags & PERF_SYSTEM_DISK)
727 && ((counter_flags & 0x03) == 0x03))
728 submit_two_counters (host->name, instance, "disk_octets", NULL,
729 disk_read, disk_written, timestamp);
731 if ((perf->flags & PERF_SYSTEM_NET)
732 && ((counter_flags & 0x0c) == 0x0c))
733 submit_two_counters (host->name, instance, "if_octets", NULL,
734 net_recv, net_sent, timestamp);
736 if ((perf->flags & PERF_SYSTEM_CPU)
737 && ((counter_flags & 0x30) == 0x30)) {
738 submit_counter (host->name, instance, "cpu", "system",
739 cpu_busy, timestamp);
740 submit_counter (host->name, instance, "cpu", "idle",
741 cpu_total - cpu_busy, timestamp);
743 } /* }}} void collect_perf_system_data */
749 service_config_t *service;
752 WARNING("netapp plugin: Plugin loaded but no hosts defined.");
756 if (!na_startup(err, sizeof(err))) {
757 ERROR("netapp plugin: Error initializing netapp API: %s", err);
761 for (host = host_config; host; host = host->next) {
762 host->srv = na_server_open(host->host, 1, 1);
763 na_server_set_transport_type(host->srv, host->protocol, 0);
764 na_server_set_port(host->srv, host->port);
765 na_server_style(host->srv, NA_STYLE_LOGIN_PASSWORD);
766 na_server_adminuser(host->srv, host->username, host->password);
767 na_server_set_timeout(host->srv, 5);
768 for (service = host->services; service; service = service->next) {
769 service->interval = host->interval * service->multiplier;
770 if (service->handler == collect_perf_system_data) {
771 service->query = na_elem_new("perf-object-get-instances");
772 na_child_add_string(service->query, "objectname", "system");
773 } else if (service->handler == collect_perf_volume_data) {
774 service->query = na_elem_new("perf-object-get-instances");
775 na_child_add_string(service->query, "objectname", "volume");
776 /* e = na_elem_new("instances");
777 na_child_add_string(e, "foo", "system");
778 na_child_add(root, e);*/
779 e = na_elem_new("counters");
780 na_child_add_string(e, "foo", "read_ops");
781 na_child_add_string(e, "foo", "write_ops");
782 na_child_add_string(e, "foo", "read_data");
783 na_child_add_string(e, "foo", "write_data");
784 na_child_add_string(e, "foo", "read_latency");
785 na_child_add_string(e, "foo", "write_latency");
786 na_child_add(service->query, e);
787 } else if (service->handler == collect_perf_wafl_data) {
788 service->query = na_elem_new("perf-object-get-instances");
789 na_child_add_string(service->query, "objectname", "wafl");
790 /* e = na_elem_new("instances");
791 na_child_add_string(e, "foo", "system");
792 na_child_add(root, e);*/
793 e = na_elem_new("counters");
794 na_child_add_string(e, "foo", "name_cache_hit");
795 na_child_add_string(e, "foo", "name_cache_miss");
796 na_child_add_string(e, "foo", "find_dir_hit");
797 na_child_add_string(e, "foo", "find_dir_miss");
798 na_child_add_string(e, "foo", "buf_hash_hit");
799 na_child_add_string(e, "foo", "buf_hash_miss");
800 na_child_add_string(e, "foo", "inode_cache_hit");
801 na_child_add_string(e, "foo", "inode_cache_miss");
802 /* na_child_add_string(e, "foo", "inode_eject_time"); */
803 /* na_child_add_string(e, "foo", "buf_eject_time"); */
804 na_child_add(service->query, e);
805 } else if (service->handler == collect_perf_disk_data) {
806 service->query = na_elem_new("perf-object-get-instances");
807 na_child_add_string(service->query, "objectname", "disk");
808 e = na_elem_new("counters");
809 na_child_add_string(e, "foo", "disk_busy");
810 na_child_add_string(e, "foo", "base_for_disk_busy");
811 na_child_add(service->query, e);
812 } else if (service->handler == collect_volume_data) {
813 service->query = na_elem_new("volume-list-info");
814 /* na_child_add_string(service->query, "objectname", "volume"); */
815 /* } else if (service->handler == collect_snapshot_data) { */
816 /* service->query = na_elem_new("snapshot-list-info"); */
823 static void set_global_perf_vol_flag(const host_config_t *host, uint32_t flag, int value) {
826 for (v = host->volumes; v; v = v->next) {
827 v->perf_data.flags &= ~flag;
828 if (value) v->perf_data.flags |= flag;
832 static void set_global_vol_flag(const host_config_t *host, uint32_t flag, int value) {
835 for (v = host->volumes; v; v = v->next) {
836 v->volume_data.flags &= ~flag;
837 if (value) v->volume_data.flags |= flag;
841 static void process_perf_volume_flag(host_config_t *host, perf_volume_data_t *perf_volume, const oconfig_item_t *item, uint32_t flag) {
844 for (n = 0; n < item->values_num; ++n) {
846 const char *name = item->values[n].value.string;
848 if (item->values[n].type != OCONFIG_TYPE_STRING) {
849 WARNING("netapp plugin: Ignoring non-string argument in \"GetVolPerfData\" block for host %s", host->name);
852 if (name[0] == '+') {
854 } else if (name[0] == '-') {
859 perf_volume->flags &= ~flag;
860 if (!minus) perf_volume->flags |= flag;
861 set_global_perf_vol_flag(host, flag, !minus);
864 v = get_volume(host, name);
865 if (!v->perf_data.flags) {
866 v->perf_data.flags = perf_volume->flags;
867 v->perf_data.last_read_latency = v->perf_data.last_read_ops = 0;
868 v->perf_data.last_write_latency = v->perf_data.last_write_ops = 0;
870 v->perf_data.flags &= ~flag;
871 if (!minus) v->perf_data.flags |= flag;
875 static void process_volume_flag(host_config_t *host, volume_data_t *volume_data, const oconfig_item_t *item, uint32_t flag) {
878 for (n = 0; n < item->values_num; ++n) {
880 const char *name = item->values[n].value.string;
882 if (item->values[n].type != OCONFIG_TYPE_STRING) {
883 WARNING("netapp plugin: Ignoring non-string argument in \"GetVolData\" block for host %s", host->name);
886 if (name[0] == '+') {
888 } else if (name[0] == '-') {
893 volume_data->flags &= ~flag;
894 if (!minus) volume_data->flags |= flag;
895 set_global_vol_flag(host, flag, !minus);
898 v = get_volume(host, name);
899 if (!v->volume_data.flags) v->volume_data.flags = volume_data->flags;
900 v->volume_data.flags &= ~flag;
901 if (!minus) v->volume_data.flags |= flag;
905 static void build_perf_vol_config(host_config_t *host, const oconfig_item_t *ci) {
906 int i, had_io = 0, had_ops = 0, had_latency = 0;
907 service_config_t *service;
908 perf_volume_data_t *perf_volume;
910 service = malloc(sizeof(*service));
912 service->handler = collect_perf_volume_data;
913 perf_volume = service->data = malloc(sizeof(*perf_volume));
914 perf_volume->flags = PERF_VOLUME_INIT;
915 service->next = host->services;
916 host->services = service;
917 for (i = 0; i < ci->children_num; ++i) {
918 oconfig_item_t *item = ci->children + i;
920 /* if (!item || !item->key || !*item->key) continue; */
921 if (!strcasecmp(item->key, "Multiplier")) {
922 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) {
923 WARNING("netapp plugin: \"Multiplier\" of host %s service GetVolPerfData needs exactly one positive integer argument.", host->name);
926 service->skip_countdown = service->multiplier = item->values[0].value.number;
927 } else if (!strcasecmp(item->key, "GetIO")) {
929 process_perf_volume_flag(host, perf_volume, item, PERF_VOLUME_IO);
930 } else if (!strcasecmp(item->key, "GetOps")) {
932 process_perf_volume_flag(host, perf_volume, item, PERF_VOLUME_OPS);
933 } else if (!strcasecmp(item->key, "GetLatency")) {
935 process_perf_volume_flag(host, perf_volume, item, PERF_VOLUME_LATENCY);
939 perf_volume->flags |= PERF_VOLUME_IO;
940 set_global_perf_vol_flag(host, PERF_VOLUME_IO, 1);
943 perf_volume->flags |= PERF_VOLUME_OPS;
944 set_global_perf_vol_flag(host, PERF_VOLUME_OPS, 1);
947 perf_volume->flags |= PERF_VOLUME_LATENCY;
948 set_global_perf_vol_flag(host, PERF_VOLUME_LATENCY, 1);
952 static void build_volume_config(host_config_t *host, oconfig_item_t *ci) {
954 service_config_t *service;
955 volume_data_t *volume_data;
957 service = malloc(sizeof(*service));
959 service->handler = collect_volume_data;
960 volume_data = service->data = malloc(sizeof(*volume_data));
961 volume_data->flags = VOLUME_INIT;
962 service->next = host->services;
963 host->services = service;
964 for (i = 0; i < ci->children_num; ++i) {
965 oconfig_item_t *item = ci->children + i;
967 /* if (!item || !item->key || !*item->key) continue; */
968 if (!strcasecmp(item->key, "Multiplier")) {
969 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) {
970 WARNING("netapp plugin: \"Multiplier\" of host %s service GetVolPerfData needs exactly one positive integer argument.", host->name);
973 service->skip_countdown = service->multiplier = item->values[0].value.number;
974 } else if (!strcasecmp(item->key, "GetDiskUtil")) {
976 process_volume_flag(host, volume_data, item, VOLUME_DF);
980 volume_data->flags |= VOLUME_DF;
981 set_global_vol_flag(host, VOLUME_DF, 1);
983 /* service = malloc(sizeof(*service));
985 service->handler = collect_snapshot_data;
986 service->data = volume_data;
987 service->next = temp->services;
988 temp->services = service;*/
991 static void build_perf_disk_config(host_config_t *temp, oconfig_item_t *ci) {
993 service_config_t *service;
994 perf_disk_data_t *perf_disk;
996 service = malloc(sizeof(*service));
998 service->handler = collect_perf_disk_data;
999 perf_disk = service->data = malloc(sizeof(*perf_disk));
1000 perf_disk->flags = PERF_DISK_ALL;
1001 service->next = temp->services;
1002 temp->services = service;
1003 for (i = 0; i < ci->children_num; ++i) {
1004 oconfig_item_t *item = ci->children + i;
1006 /* if (!item || !item->key || !*item->key) continue; */
1007 if (!strcasecmp(item->key, "Multiplier")) {
1008 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) {
1009 WARNING("netapp plugin: \"Multiplier\" of host %s service GetWaflPerfData needs exactly one positive integer argument.", ci->values[0].value.string);
1012 service->skip_countdown = service->multiplier = item->values[0].value.number;
1013 } else if (!strcasecmp(item->key, "GetBusy")) {
1014 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) {
1015 WARNING("netapp plugin: \"GetBusy\" of host %s service GetDiskPerfData needs exactly one bool argument.", ci->values[0].value.string);
1018 perf_disk->flags = (perf_disk->flags & ~PERF_SYSTEM_CPU) | (item->values[0].value.boolean ? PERF_DISK_BUSIEST : 0);
1023 static void build_perf_wafl_config(host_config_t *temp, oconfig_item_t *ci) {
1025 service_config_t *service;
1026 perf_wafl_data_t *perf_wafl;
1028 service = malloc(sizeof(*service));
1030 service->handler = collect_perf_wafl_data;
1031 perf_wafl = service->data = malloc(sizeof(*perf_wafl));
1032 perf_wafl->flags = PERF_WAFL_ALL;
1033 perf_wafl->last_name_cache_hit = 0;
1034 perf_wafl->last_name_cache_miss = 0;
1035 perf_wafl->last_find_dir_hit = 0;
1036 perf_wafl->last_find_dir_miss = 0;
1037 perf_wafl->last_buf_hash_hit = 0;
1038 perf_wafl->last_buf_hash_miss = 0;
1039 perf_wafl->last_inode_cache_hit = 0;
1040 perf_wafl->last_inode_cache_miss = 0;
1041 service->next = temp->services;
1042 temp->services = service;
1043 for (i = 0; i < ci->children_num; ++i) {
1044 oconfig_item_t *item = ci->children + i;
1046 /* if (!item || !item->key || !*item->key) continue; */
1047 if (!strcasecmp(item->key, "Multiplier")) {
1048 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) {
1049 WARNING("netapp plugin: \"Multiplier\" of host %s service GetWaflPerfData needs exactly one positive integer argument.", ci->values[0].value.string);
1052 service->skip_countdown = service->multiplier = item->values[0].value.number;
1053 } else if (!strcasecmp(item->key, "GetNameCache")) {
1054 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) {
1055 WARNING("netapp plugin: \"GetNameCache\" of host %s service GetWaflPerfData needs exactly one bool argument.", ci->values[0].value.string);
1058 perf_wafl->flags = (perf_wafl->flags & ~PERF_WAFL_NAME_CACHE) | (item->values[0].value.boolean ? PERF_WAFL_NAME_CACHE : 0);
1059 } else if (!strcasecmp(item->key, "GetDirCache")) {
1060 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) {
1061 WARNING("netapp plugin: \"GetDirChache\" of host %s service GetWaflPerfData needs exactly one bool argument.", ci->values[0].value.string);
1064 perf_wafl->flags = (perf_wafl->flags & ~PERF_WAFL_DIR_CACHE) | (item->values[0].value.boolean ? PERF_WAFL_DIR_CACHE : 0);
1065 } else if (!strcasecmp(item->key, "GetBufCache")) {
1066 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) {
1067 WARNING("netapp plugin: \"GetBufCache\" of host %s service GetWaflPerfData needs exactly one bool argument.", ci->values[0].value.string);
1070 perf_wafl->flags = (perf_wafl->flags & ~PERF_WAFL_BUF_CACHE) | (item->values[0].value.boolean ? PERF_WAFL_BUF_CACHE : 0);
1071 } else if (!strcasecmp(item->key, "GetInodeCache")) {
1072 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) {
1073 WARNING("netapp plugin: \"GetInodeCache\" of host %s service GetWaflPerfData needs exactly one bool argument.", ci->values[0].value.string);
1076 perf_wafl->flags = (perf_wafl->flags & ~PERF_WAFL_INODE_CACHE) | (item->values[0].value.boolean ? PERF_WAFL_INODE_CACHE : 0);
1081 static void build_perf_sys_config(host_config_t *temp, oconfig_item_t *ci, const service_config_t *default_service) {
1083 service_config_t *service;
1084 perf_system_data_t *perf_system;
1086 service = malloc(sizeof(*service));
1087 *service = *default_service;
1088 service->handler = collect_perf_system_data;
1089 perf_system = service->data = malloc(sizeof(*perf_system));
1090 perf_system->flags = PERF_SYSTEM_ALL;
1091 service->next = temp->services;
1092 temp->services = service;
1093 for (i = 0; i < ci->children_num; ++i) {
1094 oconfig_item_t *item = ci->children + i;
1096 /* if (!item || !item->key || !*item->key) continue; */
1097 if (!strcasecmp(item->key, "Multiplier")) {
1098 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) {
1099 WARNING("netapp plugin: \"Multiplier\" of host %s service GetSystemPerfData needs exactly one positive integer argument.", ci->values[0].value.string);
1102 service->skip_countdown = service->multiplier = item->values[0].value.number;
1103 } else if (!strcasecmp(item->key, "GetCPULoad")) {
1104 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) {
1105 WARNING("netapp plugin: \"GetCPULoad\" of host %s service GetSystemPerfData needs exactly one bool argument.", ci->values[0].value.string);
1108 perf_system->flags = (perf_system->flags & ~PERF_SYSTEM_CPU) | (item->values[0].value.boolean ? PERF_SYSTEM_CPU : 0);
1109 } else if (!strcasecmp(item->key, "GetInterfaces")) {
1110 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) {
1111 WARNING("netapp plugin: \"GetInterfaces\" of host %s service GetSystemPerfData needs exactly one bool argument.", ci->values[0].value.string);
1114 perf_system->flags = (perf_system->flags & ~PERF_SYSTEM_NET) | (item->values[0].value.boolean ? PERF_SYSTEM_NET : 0);
1115 } else if (!strcasecmp(item->key, "GetDiskOps")) {
1116 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) {
1117 WARNING("netapp plugin: \"GetDiskOps\" of host %s service GetSystemPerfData needs exactly one bool argument.", ci->values[0].value.string);
1120 perf_system->flags = (perf_system->flags & ~PERF_SYSTEM_OPS) | (item->values[0].value.boolean ? PERF_SYSTEM_OPS : 0);
1121 } else if (!strcasecmp(item->key, "GetDiskIO")) {
1122 if (item->values_num != 1 || item->values[0].type != OCONFIG_TYPE_BOOLEAN) {
1123 WARNING("netapp plugin: \"GetDiskIO\" of host %s service GetSystemPerfData needs exactly one bool argument.", ci->values[0].value.string);
1126 perf_system->flags = (perf_system->flags & ~PERF_SYSTEM_DISK) | (item->values[0].value.boolean ? PERF_SYSTEM_DISK : 0);
1131 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) {
1133 oconfig_item_t *item;
1134 host_config_t *host, *hc, temp = *default_host;
1135 service_config_t default_service = *def_def_service;
1137 if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
1138 WARNING("netapp plugin: \"Host\" needs exactly one string argument. Ignoring host block.");
1142 temp.name = ci->values[0].value.string;
1143 for (i = 0; i < ci->children_num; ++i) {
1144 item = ci->children + i;
1146 /* if (!item || !item->key || !*item->key) continue; */
1147 if (!strcasecmp(item->key, "Address")) {
1148 if ((item->values_num != 1) || (item->values[0].type != OCONFIG_TYPE_STRING)) {
1149 WARNING("netapp plugin: \"Name\" needs exactly one string argument. Ignoring host block \"%s\".", ci->values[0].value.string);
1152 temp.host = item->values[0].value.string;
1153 } else if (!strcasecmp(item->key, "Port")) {
1154 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)) {
1155 WARNING("netapp plugin: \"Port\" needs exactly one integer argument in the range of 1-65535. Ignoring host block \"%s\".", ci->values[0].value.string);
1158 temp.port = item->values[0].value.number;
1159 } else if (!strcasecmp(item->key, "Protocol")) {
1160 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"))) {
1161 WARNING("netapp plugin: \"Protocol\" needs to be either \"http\" or \"https\". Ignoring host block \"%s\".", ci->values[0].value.string);
1164 if (!strcasecmp(item->values[0].value.string, "http")) temp.protocol = NA_SERVER_TRANSPORT_HTTP;
1165 else temp.protocol = NA_SERVER_TRANSPORT_HTTPS;
1166 } else if (!strcasecmp(item->key, "Login")) {
1167 if ((item->values_num != 2) || (item->values[0].type != OCONFIG_TYPE_STRING) || (item->values[1].type != OCONFIG_TYPE_STRING)) {
1168 WARNING("netapp plugin: \"Login\" needs exactly two string arguments, username and password. Ignoring host block \"%s\".", ci->values[0].value.string);
1171 temp.username = item->values[0].value.string;
1172 temp.password = item->values[1].value.string;
1173 } else if (!strcasecmp(item->key, "Interval")) {
1174 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) {
1175 WARNING("netapp plugin: \"Interval\" of host %s needs exactly one integer argument.", ci->values[0].value.string);
1178 temp.interval = item->values[0].value.number;
1179 } else if (!strcasecmp(item->key, "GetVolumePerfData")) {
1180 build_perf_vol_config(&temp, item);
1181 } else if (!strcasecmp(item->key, "GetSystemPerfData")) {
1182 build_perf_sys_config(&temp, item, &default_service);
1183 /* if ((item->values_num != 1) || (item->values[0].type != OCONFIG_TYPE_STRING)) {
1184 WARNING("netapp plugin: \"Collect\" needs exactly one string argument. Ignoring collect block for \"%s\".", ci->values[0].value.string);
1187 build_collect_config(&temp, item);*/
1188 } else if (!strcasecmp(item->key, "GetWaflPerfData")) {
1189 build_perf_wafl_config(&temp, item);
1190 } else if (!strcasecmp(item->key, "GetDiskPerfData")) {
1191 build_perf_disk_config(&temp, item);
1192 } else if (!strcasecmp(item->key, "GetVolumeData")) {
1193 build_volume_config(&temp, item);
1195 WARNING("netapp plugin: Ignoring unknown config option \"%s\" in host block \"%s\".", item->key, ci->values[0].value.string);
1199 if (!temp.host) temp.host = temp.name;
1200 if (!temp.port) temp.port = temp.protocol == NA_SERVER_TRANSPORT_HTTP ? 80 : 443;
1201 if (!temp.username) {
1202 WARNING("netapp plugin: Please supply login information for host \"%s\". Ignoring host block.", temp.name);
1205 for (hc = host_config; hc; hc = hc->next) {
1206 if (!strcasecmp(hc->name, temp.name)) WARNING("netapp plugin: Duplicate definition of host \"%s\". This is probably a bad idea.", hc->name);
1208 host = malloc(sizeof(*host));
1210 host->name = strdup(temp.name);
1211 host->protocol = temp.protocol;
1212 host->host = strdup(temp.host);
1213 host->username = strdup(temp.username);
1214 host->password = strdup(temp.password);
1215 host->next = host_config;
1220 static int build_config (oconfig_item_t *ci) {
1222 oconfig_item_t *item;
1223 host_config_t default_host = HOST_INIT;
1224 service_config_t default_service = SERVICE_INIT;
1226 for (i = 0; i < ci->children_num; ++i) {
1227 item = ci->children + i;
1229 /* if (!item || !item->key || !*item->key) continue; */
1230 if (!strcasecmp(item->key, "Host")) {
1231 build_host_config(item, &default_host, &default_service);
1233 WARNING("netapp plugin: Ignoring unknown config option \"%s\".", item->key);
1239 static int netapp_read() {
1241 host_config_t *host;
1242 service_config_t *service;
1244 for (host = host_config; host; host = host->next) {
1245 for (service = host->services; service; service = service->next) {
1246 if (--service->skip_countdown > 0) continue;
1247 service->skip_countdown = service->multiplier;
1248 out = na_server_invoke_elem(host->srv, service->query);
1249 if (na_results_status(out) != NA_OK) {
1250 int netapp_errno = na_results_errno(out);
1251 ERROR("netapp plugin: Error %d from host %s: %s", netapp_errno, host->name, na_results_reason(out));
1253 if (netapp_errno == EIO || netapp_errno == ETIMEDOUT) {
1254 /* Network problems. Just give up on all other services on this host. */
1259 service->handler(host, out, service->data);
1266 void module_register() {
1267 plugin_register_complex_config("netapp", build_config);
1268 plugin_register_init("netapp", config_init);
1269 plugin_register_read("netapp", netapp_read);
1272 /* vim: set sw=2 ts=2 noet fdm=marker : */