+/*
+ * Callbacks registered with the daemon
+ *
+ * Pretty standard stuff here.
+ */
+static int cna_init(void) { /* {{{ */
+ char err[256];
+ na_elem_t *e;
+ host_config_t *host;
+ cfg_service_t *service;
+
+ if (!host_config) {
+ WARNING("netapp plugin: Plugin loaded but no hosts defined.");
+ return 1;
+ }
+
+ if (!na_startup(err, sizeof(err))) {
+ ERROR("netapp plugin: Error initializing netapp API: %s", err);
+ return 1;
+ }
+
+ for (host = host_config; host; host = host->next) {
+ host->srv = na_server_open(host->host, 1, 1);
+ na_server_set_transport_type(host->srv, host->protocol, 0);
+ na_server_set_port(host->srv, host->port);
+ na_server_style(host->srv, NA_STYLE_LOGIN_PASSWORD);
+ na_server_adminuser(host->srv, host->username, host->password);
+ na_server_set_timeout(host->srv, 5);
+ for (service = host->services; service; service = service->next) {
+ service->interval = host->interval * service->multiplier;
+ if (service->handler == collect_perf_system_data) {
+ service->query = na_elem_new("perf-object-get-instances");
+ na_child_add_string(service->query, "objectname", "system");
+ } else if (service->handler == query_volume_perf_data) {
+ service->query = na_elem_new("perf-object-get-instances");
+ na_child_add_string(service->query, "objectname", "volume");
+/* e = na_elem_new("instances");
+ na_child_add_string(e, "foo", "system");
+ na_child_add(root, e);*/
+ e = na_elem_new("counters");
+ na_child_add_string(e, "foo", "read_ops");
+ na_child_add_string(e, "foo", "write_ops");
+ na_child_add_string(e, "foo", "read_data");
+ na_child_add_string(e, "foo", "write_data");
+ na_child_add_string(e, "foo", "read_latency");
+ na_child_add_string(e, "foo", "write_latency");
+ na_child_add(service->query, e);
+ } else if (service->handler == query_wafl_data) {
+ service->query = na_elem_new("perf-object-get-instances");
+ na_child_add_string(service->query, "objectname", "wafl");
+/* e = na_elem_new("instances");
+ na_child_add_string(e, "foo", "system");
+ na_child_add(root, e);*/
+ e = na_elem_new("counters");
+ na_child_add_string(e, "foo", "name_cache_hit");
+ na_child_add_string(e, "foo", "name_cache_miss");
+ na_child_add_string(e, "foo", "find_dir_hit");
+ na_child_add_string(e, "foo", "find_dir_miss");
+ na_child_add_string(e, "foo", "buf_hash_hit");
+ na_child_add_string(e, "foo", "buf_hash_miss");
+ na_child_add_string(e, "foo", "inode_cache_hit");
+ na_child_add_string(e, "foo", "inode_cache_miss");
+ /* na_child_add_string(e, "foo", "inode_eject_time"); */
+ /* na_child_add_string(e, "foo", "buf_eject_time"); */
+ na_child_add(service->query, e);
+ } else if (service->handler == query_submit_disk_data) {
+ service->query = na_elem_new("perf-object-get-instances");
+ na_child_add_string(service->query, "objectname", "disk");
+ e = na_elem_new("counters");
+ na_child_add_string(e, "foo", "disk_busy");
+ na_child_add_string(e, "foo", "base_for_disk_busy");
+ na_child_add(service->query, e);
+ } else if (service->handler == collect_volume_data) {
+ service->query = na_elem_new("volume-list-info");
+ /* na_child_add_string(service->query, "objectname", "volume"); */
+ /* } else if (service->handler == collect_snapshot_data) { */
+ /* service->query = na_elem_new("snapshot-list-info"); */
+ }
+ }
+ }
+ return 0;
+} /* }}} int cna_init */
+