static int mb_config_add_slave (mb_host_t *host, oconfig_item_t *ci) /* {{{ */ { mb_slave_t *slave; int status; int i; if ((host == NULL) || (ci == NULL)) return (EINVAL); slave = realloc (host->slaves, sizeof (*slave) * (host->slaves_num + 1)); if (slave == NULL) return (ENOMEM); host->slaves = slave; slave = host->slaves + host->slaves_num; memset (slave, 0, sizeof (*slave)); slave->collect = NULL; status = cf_util_get_int (ci, &slave->id); if (status != 0) return (status); for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; status = 0; if (strcasecmp ("Instance", child->key) == 0) status = cf_util_get_string_buffer (child, slave->instance, sizeof (slave->instance)); else if (strcasecmp ("Collect", child->key) == 0) { char buffer[1024]; status = cf_util_get_string_buffer (child, buffer, sizeof (buffer)); if (status == 0) data_copy_by_name (&slave->collect, data_definitions, buffer); status = 0; /* continue after failure. */ } else { ERROR ("Modbus plugin: Unknown configuration option: %s", child->key); status = -1; } if (status != 0) break; } if ((status == 0) && (slave->collect == NULL)) status = EINVAL; if (slave->id < 0) status = EINVAL; if (status == 0) host->slaves_num++; else /* if (status != 0) */ data_free_all (slave->collect); return (status); } /* }}} int mb_config_add_slave */
static int dpdk_events_link_status_config(dpdk_events_ctx_t *ec, oconfig_item_t *ci) { ec->config.link_status.enabled = 1; DEBUG(DPDK_EVENTS_PLUGIN ": Subscribed for Link Status Events."); for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp("EnabledPortMask", child->key) == 0) { if (cf_util_get_int(child, (int *)&ec->config.link_status.enabled_port_mask)) return -1; DEBUG(DPDK_EVENTS_PLUGIN ": LinkStatus:Enabled Port Mask 0x%X", ec->config.link_status.enabled_port_mask); } else if (strcasecmp("SendEventsOnUpdate", child->key) == 0) { if (cf_util_get_boolean(child, &ec->config.link_status.send_updated)) return -1; DEBUG(DPDK_EVENTS_PLUGIN ": LinkStatus:SendEventsOnUpdate %d", ec->config.link_status.send_updated); } else if (strcasecmp("SendNotification", child->key) == 0) { if (cf_util_get_boolean(child, &ec->config.link_status.notify)) return -1; DEBUG(DPDK_EVENTS_PLUGIN ": LinkStatus:SendNotification %d", ec->config.link_status.notify); } else if (strcasecmp("PortName", child->key) != 0) { ERROR(DPDK_EVENTS_PLUGIN ": unrecognized configuration option %s.", child->key); return -1; } } int port_num = 0; /* parse port names after EnabledPortMask was parsed */ for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp("PortName", child->key) == 0) { while (!(ec->config.link_status.enabled_port_mask & (1 << port_num))) port_num++; if (cf_util_get_string_buffer( child, ec->config.link_status.port_name[port_num], sizeof(ec->config.link_status.port_name[port_num]))) { return -1; } DEBUG(DPDK_EVENTS_PLUGIN ": LinkStatus:Port %d Name: %s", port_num, ec->config.link_status.port_name[port_num]); port_num++; } } return 0; }
static int rc_config_get_int_positive(oconfig_item_t const *ci, int *ret) { int status; int tmp = 0; status = cf_util_get_int(ci, &tmp); if (status != 0) return status; if (tmp < 0) return EINVAL; *ret = tmp; return 0; } /* int rc_config_get_int_positive */
static int redis_config_node (oconfig_item_t *ci) /* {{{ */ { redis_node_t rn; int i; int status; memset (&rn, 0, sizeof (rn)); sstrncpy (rn.host, REDIS_DEF_HOST, sizeof (rn.host)); rn.port = REDIS_DEF_PORT; rn.timeout = REDIS_DEF_TIMEOUT; status = cf_util_get_string_buffer (ci, rn.name, sizeof (rn.name)); if (status != 0) return (status); for (i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; if (strcasecmp ("Host", option->key) == 0) status = cf_util_get_string_buffer (option, rn.host, sizeof (rn.host)); else if (strcasecmp ("Port", option->key) == 0) { status = cf_util_get_port_number (option); if (status > 0) { rn.port = status; status = 0; } } else if (strcasecmp ("Timeout", option->key) == 0) status = cf_util_get_int (option, &rn.timeout); else if (strcasecmp ("Password", option->key) == 0) status = cf_util_get_string_buffer (option, rn.passwd, sizeof (rn.passwd)); else WARNING ("redis plugin: Option `%s' not allowed inside a `Node' " "block. I'll ignore this option.", option->key); if (status != 0) break; } if (status != 0) return (status); return (redis_node_add (&rn)); } /* }}} int redis_config_node */
static int camqp_config_connection (oconfig_item_t *ci, /* {{{ */ _Bool publish) { camqp_config_t *conf; int status; int i; conf = malloc (sizeof (*conf)); if (conf == NULL) { ERROR ("amqp plugin: malloc failed."); return (ENOMEM); } /* Initialize "conf" {{{ */ memset (conf, 0, sizeof (*conf)); conf->publish = publish; conf->name = NULL; conf->format = CAMQP_FORMAT_COMMAND; conf->host = NULL; conf->port = 5672; conf->vhost = NULL; conf->user = NULL; conf->password = NULL; conf->exchange = NULL; conf->routing_key = NULL; conf->connection_retry_delay = 0; /* publish only */ conf->delivery_mode = CAMQP_DM_VOLATILE; conf->store_rates = 0; conf->graphite_flags = 0; /* publish & graphite only */ conf->prefix = NULL; conf->postfix = NULL; conf->escape_char = '_'; /* subscribe only */ conf->exchange_type = NULL; conf->queue = NULL; conf->queue_durable = 0; conf->queue_auto_delete = 1; /* general */ conf->connection = NULL; pthread_mutex_init (&conf->lock, /* attr = */ NULL); /* }}} */ status = cf_util_get_string (ci, &conf->name); if (status != 0) { sfree (conf); return (status); } for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp ("Host", child->key) == 0) status = cf_util_get_string (child, &conf->host); else if (strcasecmp ("Port", child->key) == 0) { status = cf_util_get_port_number (child); if (status > 0) { conf->port = status; status = 0; } } else if (strcasecmp ("VHost", child->key) == 0) status = cf_util_get_string (child, &conf->vhost); else if (strcasecmp ("User", child->key) == 0) status = cf_util_get_string (child, &conf->user); else if (strcasecmp ("Password", child->key) == 0) status = cf_util_get_string (child, &conf->password); else if (strcasecmp ("Exchange", child->key) == 0) status = cf_util_get_string (child, &conf->exchange); else if ((strcasecmp ("ExchangeType", child->key) == 0) && !publish) status = cf_util_get_string (child, &conf->exchange_type); else if ((strcasecmp ("Queue", child->key) == 0) && !publish) status = cf_util_get_string (child, &conf->queue); else if ((strcasecmp ("QueueDurable", child->key) == 0) && !publish) status = cf_util_get_boolean (child, &conf->queue_durable); else if ((strcasecmp ("QueueAutoDelete", child->key) == 0) && !publish) status = cf_util_get_boolean (child, &conf->queue_auto_delete); else if (strcasecmp ("RoutingKey", child->key) == 0) status = cf_util_get_string (child, &conf->routing_key); else if ((strcasecmp ("Persistent", child->key) == 0) && publish) { _Bool tmp = 0; status = cf_util_get_boolean (child, &tmp); if (tmp) conf->delivery_mode = CAMQP_DM_PERSISTENT; else conf->delivery_mode = CAMQP_DM_VOLATILE; } else if ((strcasecmp ("StoreRates", child->key) == 0) && publish) { status = cf_util_get_boolean (child, &conf->store_rates); (void) cf_util_get_flag (child, &conf->graphite_flags, GRAPHITE_STORE_RATES); } else if ((strcasecmp ("Format", child->key) == 0) && publish) status = camqp_config_set_format (child, conf); else if ((strcasecmp ("GraphiteSeparateInstances", child->key) == 0) && publish) status = cf_util_get_flag (child, &conf->graphite_flags, GRAPHITE_SEPARATE_INSTANCES); else if ((strcasecmp ("GraphiteAlwaysAppendDS", child->key) == 0) && publish) status = cf_util_get_flag (child, &conf->graphite_flags, GRAPHITE_ALWAYS_APPEND_DS); else if ((strcasecmp ("GraphitePrefix", child->key) == 0) && publish) status = cf_util_get_string (child, &conf->prefix); else if ((strcasecmp ("GraphitePostfix", child->key) == 0) && publish) status = cf_util_get_string (child, &conf->postfix); else if ((strcasecmp ("GraphiteEscapeChar", child->key) == 0) && publish) { char *tmp_buff = NULL; status = cf_util_get_string (child, &tmp_buff); if (strlen (tmp_buff) > 1) WARNING ("amqp plugin: The option \"GraphiteEscapeChar\" handles " "only one character. Others will be ignored."); conf->escape_char = tmp_buff[0]; sfree (tmp_buff); } else if (strcasecmp ("ConnectionRetryDelay", child->key) == 0) status = cf_util_get_int (child, &conf->connection_retry_delay); else WARNING ("amqp plugin: Ignoring unknown " "configuration option \"%s\".", child->key); if (status != 0) break; } /* for (i = 0; i < ci->children_num; i++) */ if ((status == 0) && (conf->exchange == NULL)) { if (conf->exchange_type != NULL) WARNING ("amqp plugin: The option \"ExchangeType\" was given " "without the \"Exchange\" option. It will be ignored."); if (!publish && (conf->routing_key != NULL)) WARNING ("amqp plugin: The option \"RoutingKey\" was given " "without the \"Exchange\" option. It will be ignored."); } if (status != 0) { camqp_config_free (conf); return (status); } if (conf->exchange != NULL) { DEBUG ("amqp plugin: camqp_config_connection: exchange = %s;", conf->exchange); } if (publish) { char cbname[128]; user_data_t ud = { conf, camqp_config_free }; ssnprintf (cbname, sizeof (cbname), "amqp/%s", conf->name); status = plugin_register_write (cbname, camqp_write, &ud); if (status != 0) { camqp_config_free (conf); return (status); } } else { status = camqp_subscribe_init (conf); if (status != 0) { camqp_config_free (conf); return (status); } } return (0); } /* }}} int camqp_config_connection */
static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */ { cx_t *db; int status = 0; int i; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING ("curl_xml plugin: The `URL' block " "needs exactly one string argument."); return (-1); } db = (cx_t *) malloc (sizeof (*db)); if (db == NULL) { ERROR ("curl_xml plugin: malloc failed."); return (-1); } memset (db, 0, sizeof (*db)); db->timeout = -1; if (strcasecmp ("URL", ci->key) == 0) { status = cf_util_get_string (ci, &db->url); if (status != 0) { sfree (db); return (status); } } else { ERROR ("curl_xml plugin: cx_config: " "Invalid key: %s", ci->key); cx_free (db); return (-1); } /* Fill the `cx_t' structure.. */ for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp ("Instance", child->key) == 0) status = cf_util_get_string (child, &db->instance); else if (strcasecmp ("Host", child->key) == 0) status = cf_util_get_string (child, &db->host); else if (strcasecmp ("User", child->key) == 0) status = cf_util_get_string (child, &db->user); else if (strcasecmp ("Password", child->key) == 0) status = cf_util_get_string (child, &db->pass); else if (strcasecmp ("Digest", child->key) == 0) status = cf_util_get_boolean (child, &db->digest); else if (strcasecmp ("VerifyPeer", child->key) == 0) status = cf_util_get_boolean (child, &db->verify_peer); else if (strcasecmp ("VerifyHost", child->key) == 0) status = cf_util_get_boolean (child, &db->verify_host); else if (strcasecmp ("CACert", child->key) == 0) status = cf_util_get_string (child, &db->cacert); else if (strcasecmp ("xpath", child->key) == 0) status = cx_config_add_xpath (db, child); else if (strcasecmp ("Header", child->key) == 0) status = cx_config_append_string ("Header", &db->headers, child); else if (strcasecmp ("Post", child->key) == 0) status = cf_util_get_string (child, &db->post_body); else if (strcasecmp ("Namespace", child->key) == 0) status = cx_config_add_namespace (db, child); else if (strcasecmp ("Timeout", child->key) == 0) status = cf_util_get_int (child, &db->timeout); else { WARNING ("curl_xml plugin: Option `%s' not allowed here.", child->key); status = -1; } if (status != 0) break; } if (status == 0) { if (db->list == NULL) { WARNING ("curl_xml plugin: No (valid) `Key' block " "within `URL' block `%s'.", db->url); status = -1; } if (status == 0) status = cx_init_curl (db); } /* If all went well, register this database for reading */ if (status == 0) { user_data_t ud; char *cb_name; if (db->instance == NULL) db->instance = strdup("default"); DEBUG ("curl_xml plugin: Registering new read callback: %s", db->instance); memset (&ud, 0, sizeof (ud)); ud.data = (void *) db; ud.free_func = cx_free; cb_name = ssnprintf_alloc ("curl_xml-%s-%s", db->instance, db->url); plugin_register_complex_read (/* group = */ "curl_xml", cb_name, cx_read, /* interval = */ 0, &ud); sfree (cb_name); } else { cx_free (db); return (-1); } return (0); } /* }}} int cx_config_add_url */
static int dpdk_stats_config(oconfig_item_t *ci) { DPDK_STATS_TRACE(); int ret = dpdk_stats_preinit(); if (ret) { g_state = DPDK_STAT_STATE_CFG_ERR; return 0; } dpdk_stats_ctx_t *ctx = DPDK_STATS_CTX_GET(g_hc); for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp("EnabledPortMask", child->key) == 0) ret = cf_util_get_int(child, (int *)&ctx->config.enabled_port_mask); else if (strcasecmp("SharedMemObj", child->key) == 0) { ret = cf_util_get_string_buffer(child, g_shm_name, sizeof(g_shm_name)); if (ret == 0) ret = dpdk_stats_reinit_helper(); } else if (strcasecmp("EAL", child->key) == 0) ret = dpdk_helper_eal_config_parse(g_hc, child); else if (strcasecmp("PortName", child->key) != 0) { ERROR(DPDK_STATS_PLUGIN ": unrecognized configuration option %s", child->key); ret = -1; } if (ret != 0) { g_state = DPDK_STAT_STATE_CFG_ERR; return 0; } } DEBUG(DPDK_STATS_PLUGIN ": Enabled Port Mask 0x%X", ctx->config.enabled_port_mask); DEBUG(DPDK_STATS_PLUGIN ": Shared memory object %s", g_shm_name); int port_num = 0; /* parse port names after EnabledPortMask was parsed */ for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp("PortName", child->key) == 0) { while (!(ctx->config.enabled_port_mask & (1 << port_num))) port_num++; if (cf_util_get_string_buffer(child, ctx->config.port_name[port_num], sizeof(ctx->config.port_name[port_num]))) { g_state = DPDK_STAT_STATE_CFG_ERR; return 0; } DEBUG(DPDK_STATS_PLUGIN ": Port %d Name: %s", port_num, ctx->config.port_name[port_num]); port_num++; } } return 0; }
static int mb_config_add_host (oconfig_item_t *ci) /* {{{ */ { mb_host_t *host; int status; int i; host = malloc (sizeof (*host)); if (host == NULL) return (ENOMEM); memset (host, 0, sizeof (*host)); host->slaves = NULL; status = cf_util_get_string_buffer (ci, host->host, sizeof (host->host)); if (status != 0) return (status); if (host->host[0] == 0) return (EINVAL); for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; status = 0; if (strcasecmp ("Address", child->key) == 0) { char buffer[NI_MAXHOST]; status = cf_util_get_string_buffer (child, buffer, sizeof (buffer)); if (status == 0) status = mb_config_set_host_address (host, buffer); } else if (strcasecmp ("Port", child->key) == 0) { host->port = cf_util_get_port_number (child); if (host->port <= 0) status = -1; } else if (strcasecmp ("Interval", child->key) == 0) status = cf_util_get_int (child, &host->interval); else if (strcasecmp ("Slave", child->key) == 0) /* Don't set status: Gracefully continue if a slave fails. */ mb_config_add_slave (host, child); else { ERROR ("Modbus plugin: Unknown configuration option: %s", child->key); status = -1; } if (status != 0) break; } /* for (i = 0; i < ci->children_num; i++) */ assert (host->host[0] != 0); if (host->host[0] == 0) { ERROR ("Modbus plugin: Data block \"%s\": No type has been specified.", host->host); status = -1; } if (status == 0) { user_data_t ud; char name[1024]; struct timespec interval; ud.data = host; ud.free_func = host_free; ssnprintf (name, sizeof (name), "modbus-%s", host->host); interval.tv_nsec = 0; if (host->interval > 0) interval.tv_sec = host->interval; else interval.tv_sec = 0; plugin_register_complex_read (/* group = */ NULL, name, mb_read, (interval.tv_sec > 0) ? &interval : NULL, &ud); } else { host_free (host); } return (status); } /* }}} int mb_config_add_host */
static int cc_config_add_page (oconfig_item_t *ci) /* {{{ */ { web_page_t *page; int status; int i; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING ("curl plugin: `Page' blocks need exactly one string argument."); return (-1); } page = calloc (1, sizeof (*page)); if (page == NULL) { ERROR ("curl plugin: calloc failed."); return (-1); } page->url = NULL; page->user = NULL; page->pass = NULL; page->digest = 0; page->verify_peer = 1; page->verify_host = 1; page->response_time = 0; page->response_code = 0; page->timeout = -1; page->instance = strdup (ci->values[0].value.string); if (page->instance == NULL) { ERROR ("curl plugin: strdup failed."); sfree (page); return (-1); } /* Process all children */ status = 0; for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp ("URL", child->key) == 0) status = cf_util_get_string (child, &page->url); else if (strcasecmp ("User", child->key) == 0) status = cf_util_get_string (child, &page->user); else if (strcasecmp ("Password", child->key) == 0) status = cf_util_get_string (child, &page->pass); else if (strcasecmp ("Digest", child->key) == 0) status = cf_util_get_boolean (child, &page->digest); else if (strcasecmp ("VerifyPeer", child->key) == 0) status = cf_util_get_boolean (child, &page->verify_peer); else if (strcasecmp ("VerifyHost", child->key) == 0) status = cf_util_get_boolean (child, &page->verify_host); else if (strcasecmp ("MeasureResponseTime", child->key) == 0) status = cf_util_get_boolean (child, &page->response_time); else if (strcasecmp ("MeasureResponseCode", child->key) == 0) status = cf_util_get_boolean (child, &page->response_code); else if (strcasecmp ("CACert", child->key) == 0) status = cf_util_get_string (child, &page->cacert); else if (strcasecmp ("Match", child->key) == 0) /* Be liberal with failing matches => don't set `status'. */ cc_config_add_match (page, child); else if (strcasecmp ("Header", child->key) == 0) status = cc_config_append_string ("Header", &page->headers, child); else if (strcasecmp ("Post", child->key) == 0) status = cf_util_get_string (child, &page->post_body); else if (strcasecmp ("Timeout", child->key) == 0) status = cf_util_get_int (child, &page->timeout); else { WARNING ("curl plugin: Option `%s' not allowed here.", child->key); status = -1; } if (status != 0) break; } /* for (i = 0; i < ci->children_num; i++) */ /* Additionial sanity checks and libCURL initialization. */ while (status == 0) { if (page->url == NULL) { WARNING ("curl plugin: `URL' missing in `Page' block."); status = -1; } if (page->matches == NULL && !page->response_time && !page->response_code) { assert (page->instance != NULL); WARNING ("curl plugin: No (valid) `Match' block " "or MeasureResponseTime or MeasureResponseCode within " "`Page' block `%s'.", page->instance); status = -1; } if (status == 0) status = cc_page_init_curl (page); break; } /* while (status == 0) */ if (status != 0) { cc_web_page_free (page); return (status); } /* Add the new page to the linked list */ if (pages_g == NULL) pages_g = page; else { web_page_t *prev; prev = pages_g; while (prev->next != NULL) prev = prev->next; prev->next = page; } return (0); } /* }}} int cc_config_add_page */
static int wm_config_node (oconfig_item_t *ci) /* {{{ */ { wm_node_t *node; int status; node = calloc (1, sizeof (*node)); if (node == NULL) return (ENOMEM); mongo_init (node->conn); node->host = NULL; node->store_rates = 1; pthread_mutex_init (&node->lock, /* attr = */ NULL); status = cf_util_get_string_buffer (ci, node->name, sizeof (node->name)); if (status != 0) { sfree (node); return (status); } for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp ("Host", child->key) == 0) status = cf_util_get_string (child, &node->host); else if (strcasecmp ("Port", child->key) == 0) { status = cf_util_get_port_number (child); if (status > 0) { node->port = status; status = 0; } } else if (strcasecmp ("Timeout", child->key) == 0) status = cf_util_get_int (child, &node->timeout); else if (strcasecmp ("StoreRates", child->key) == 0) status = cf_util_get_boolean (child, &node->store_rates); else if (strcasecmp ("Database", child->key) == 0) status = cf_util_get_string (child, &node->db); else if (strcasecmp ("User", child->key) == 0) status = cf_util_get_string (child, &node->user); else if (strcasecmp ("Password", child->key) == 0) status = cf_util_get_string (child, &node->passwd); else WARNING ("write_mongodb plugin: Ignoring unknown config option \"%s\".", child->key); if (status != 0) break; } /* for (i = 0; i < ci->children_num; i++) */ if ((node->db != NULL) || (node->user != NULL) || (node->passwd != NULL)) { if ((node->db == NULL) || (node->user == NULL) || (node->passwd == NULL)) { WARNING ("write_mongodb plugin: Authentication requires the " "\"Database\", \"User\" and \"Password\" options to be specified, " "but at last one of them is missing. Authentication will NOT be " "used."); sfree (node->db); sfree (node->user); sfree (node->passwd); } } if (status == 0) { char cb_name[DATA_MAX_NAME_LEN]; user_data_t ud; ssnprintf (cb_name, sizeof (cb_name), "write_mongodb/%s", node->name); ud.data = node; ud.free_func = wm_config_free; status = plugin_register_write (cb_name, wm_write, &ud); INFO ("write_mongodb plugin: registered write plugin %s %d",cb_name,status); } if (status != 0) wm_config_free (node); return (status); } /* }}} int wm_config_node */
static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ { cj_t *db; int status = 0; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING ("curl_json plugin: The `URL' block " "needs exactly one string argument."); return (-1); } db = calloc (1, sizeof (*db)); if (db == NULL) { ERROR ("curl_json plugin: calloc failed."); return (-1); } db->timeout = -1; if (strcasecmp ("URL", ci->key) == 0) status = cf_util_get_string (ci, &db->url); else if (strcasecmp ("Sock", ci->key) == 0) status = cf_util_get_string (ci, &db->sock); else { ERROR ("curl_json plugin: cj_config: " "Invalid key: %s", ci->key); cj_free (db); return (-1); } if (status != 0) { sfree (db); return (status); } /* Fill the `cj_t' structure.. */ for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp ("Instance", child->key) == 0) status = cf_util_get_string (child, &db->instance); else if (strcasecmp ("Host", child->key) == 0) status = cf_util_get_string (child, &db->host); else if (db->url && strcasecmp ("User", child->key) == 0) status = cf_util_get_string (child, &db->user); else if (db->url && strcasecmp ("Password", child->key) == 0) status = cf_util_get_string (child, &db->pass); else if (strcasecmp ("Digest", child->key) == 0) status = cf_util_get_boolean (child, &db->digest); else if (db->url && strcasecmp ("VerifyPeer", child->key) == 0) status = cf_util_get_boolean (child, &db->verify_peer); else if (db->url && strcasecmp ("VerifyHost", child->key) == 0) status = cf_util_get_boolean (child, &db->verify_host); else if (db->url && strcasecmp ("CACert", child->key) == 0) status = cf_util_get_string (child, &db->cacert); else if (db->url && strcasecmp ("Header", child->key) == 0) status = cj_config_append_string ("Header", &db->headers, child); else if (db->url && strcasecmp ("Post", child->key) == 0) status = cf_util_get_string (child, &db->post_body); else if (strcasecmp ("Key", child->key) == 0) status = cj_config_add_key (db, child); else if (strcasecmp ("Interval", child->key) == 0) status = cf_util_get_cdtime(child, &db->interval); else if (strcasecmp ("Timeout", child->key) == 0) status = cf_util_get_int (child, &db->timeout); else if (strcasecmp ("Statistics", child->key) == 0) { db->stats = curl_stats_from_config (child); if (db->stats == NULL) status = -1; } else { WARNING ("curl_json plugin: Option `%s' not allowed here.", child->key); status = -1; } if (status != 0) break; } if (status == 0) { if (db->tree == NULL) { WARNING ("curl_json plugin: No (valid) `Key' block within `%s' \"`%s'\".", db->url ? "URL" : "Sock", db->url ? db->url : db->sock); status = -1; } if (status == 0 && db->url) status = cj_init_curl (db); } /* If all went well, register this database for reading */ if (status == 0) { user_data_t ud = { 0 }; char *cb_name; if (db->instance == NULL) db->instance = strdup("default"); DEBUG ("curl_json plugin: Registering new read callback: %s", db->instance); ud.data = (void *) db; ud.free_func = cj_free; cb_name = ssnprintf_alloc ("curl_json-%s-%s", db->instance, db->url ? db->url : db->sock); plugin_register_complex_read (/* group = */ NULL, cb_name, cj_read, /* interval = */ db->interval, &ud); sfree (cb_name); } else { cj_free (db); return (-1); } return (0); }
/* Configuration handling functiions * <Plugin apache> * <Instance "instance_name"> * URL ... * </Instance> * URL ... * </Plugin> */ static int config_add (oconfig_item_t *ci) { apache_t *st; int i; int status; st = calloc (1, sizeof (*st)); if (st == NULL) { ERROR ("apache plugin: calloc failed."); return (-1); } st->timeout = -1; status = cf_util_get_string (ci, &st->name); if (status != 0) { sfree (st); return (status); } assert (st->name != NULL); for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp ("URL", child->key) == 0) status = cf_util_get_string (child, &st->url); else if (strcasecmp ("Host", child->key) == 0) status = cf_util_get_string (child, &st->host); else if (strcasecmp ("User", child->key) == 0) status = cf_util_get_string (child, &st->user); else if (strcasecmp ("Password", child->key) == 0) status = cf_util_get_string (child, &st->pass); else if (strcasecmp ("VerifyPeer", child->key) == 0) status = cf_util_get_boolean (child, &st->verify_peer); else if (strcasecmp ("VerifyHost", child->key) == 0) status = cf_util_get_boolean (child, &st->verify_host); else if (strcasecmp ("CACert", child->key) == 0) status = cf_util_get_string (child, &st->cacert); else if (strcasecmp ("SSLCiphers", child->key) == 0) status = cf_util_get_string (child, &st->ssl_ciphers); else if (strcasecmp ("Server", child->key) == 0) status = cf_util_get_string (child, &st->server); else if (strcasecmp ("Timeout", child->key) == 0) status = cf_util_get_int (child, &st->timeout); else { WARNING ("apache plugin: Option `%s' not allowed here.", child->key); status = -1; } if (status != 0) break; } /* Check if struct is complete.. */ if ((status == 0) && (st->url == NULL)) { ERROR ("apache plugin: Instance `%s': " "No URL has been configured.", st->name); status = -1; } if (status == 0) { user_data_t ud; char callback_name[3*DATA_MAX_NAME_LEN]; memset (&ud, 0, sizeof (ud)); ud.data = st; ud.free_func = (void *) apache_free; memset (callback_name, 0, sizeof (callback_name)); ssnprintf (callback_name, sizeof (callback_name), "apache/%s/%s", (st->host != NULL) ? st->host : hostname_g, (st->name != NULL) ? st->name : "default"), status = plugin_register_complex_read (/* group = */ NULL, /* name = */ callback_name, /* callback = */ apache_read_host, /* interval = */ 0, /* user_data = */ &ud); } if (status != 0) { apache_free (st); return (-1); } return (0); } /* int config_add */
static int wm_config_node (oconfig_item_t *ci) /* {{{ */ { wm_node_t *node; int status; int i; node = malloc (sizeof (*node)); if (node == NULL) return (ENOMEM); memset (node, 0, sizeof (*node)); mongo_init (node->conn); node->host = NULL; node->store_rates = 1; pthread_mutex_init (&node->lock, /* attr = */ NULL); status = cf_util_get_string_buffer (ci, node->name, sizeof (node->name)); if (status != 0) { sfree (node); return (status); } for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp ("Host", child->key) == 0) status = cf_util_get_string (child, &node->host); else if (strcasecmp ("Port", child->key) == 0) { status = cf_util_get_port_number (child); if (status > 0) { node->port = status; status = 0; } } else if (strcasecmp ("Timeout", child->key) == 0) status = cf_util_get_int (child, &node->timeout); else if (strcasecmp ("StoreRates", child->key) == 0) status = cf_util_get_boolean (child, &node->store_rates); else WARNING ("write_mongodb plugin: Ignoring unknown config option \"%s\".", child->key); if (status != 0) break; } /* for (i = 0; i < ci->children_num; i++) */ if (status == 0) { char cb_name[DATA_MAX_NAME_LEN]; user_data_t ud; ssnprintf (cb_name, sizeof (cb_name), "write_mongodb/%s", node->name); ud.data = node; ud.free_func = wm_config_free; status = plugin_register_write (cb_name, wm_write, &ud); INFO ("write_mongodb plugin: registered write plugin %s %d",cb_name,status); } if (status != 0) wm_config_free (node); return (status); } /* }}} int wm_config_node */
static int mb_config_add_host (oconfig_item_t *ci) /* {{{ */ { mb_host_t *host; int status; int i; host = malloc (sizeof (*host)); if (host == NULL) return (ENOMEM); memset (host, 0, sizeof (*host)); host->slaves = NULL; status = cf_util_get_string_buffer (ci, host->host, sizeof (host->host)); if (status != 0) return (status); if (host->host[0] == 0) return (EINVAL); for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; status = 0; if (strcasecmp ("Address", child->key) == 0) { char buffer[NI_MAXHOST]; status = cf_util_get_string_buffer (child, buffer, sizeof (buffer)); if (status == 0) status = mb_config_set_host_address (host, buffer); if (status == 0) host->conntype = MBCONN_TCP; } else if (strcasecmp ("Port", child->key) == 0) { host->port = cf_util_get_port_number (child); if (host->port <= 0) status = -1; } else if (strcasecmp ("Device", child->key) == 0) { status = cf_util_get_string_buffer (child, host->node, sizeof (host->node)); if (status == 0) host->conntype = MBCONN_RTU; } else if (strcasecmp ("Baudrate", child->key) == 0) status = cf_util_get_int(child, &host->baudrate); else if (strcasecmp ("Interval", child->key) == 0) status = cf_util_get_cdtime (child, &host->interval); else if (strcasecmp ("Slave", child->key) == 0) /* Don't set status: Gracefully continue if a slave fails. */ mb_config_add_slave (host, child); else { ERROR ("Modbus plugin: Unknown configuration option: %s", child->key); status = -1; } if (status != 0) break; } /* for (i = 0; i < ci->children_num; i++) */ assert (host->host[0] != 0); if (host->node[0] == 0) { ERROR ("Modbus plugin: Data block \"%s\": No address or device has been specified.", host->host); status = -1; } if (host->conntype == MBCONN_RTU && !host->baudrate) { ERROR ("Modbus plugin: Data block \"%s\": No serial baudrate has been specified.", host->host); status = -1; } if ((host->conntype == MBCONN_TCP && host->baudrate) || (host->conntype == MBCONN_RTU && host->port)) { ERROR ("Modbus plugin: Data block \"%s\": You've mixed up RTU and TCP options.", host->host); status = -1; } if (status == 0) { user_data_t ud; char name[1024]; struct timespec interval = { 0, 0 }; ud.data = host; ud.free_func = host_free; ssnprintf (name, sizeof (name), "modbus-%s", host->host); CDTIME_T_TO_TIMESPEC (host->interval, &interval); plugin_register_complex_read (/* group = */ NULL, name, /* callback = */ mb_read, /* interval = */ (host->interval > 0) ? &interval : NULL, &ud); } else { host_free (host); } return (status); } /* }}} int mb_config_add_host */
/* Configuration handling functions {{{ * * <Plugin mysql> * <Database "plugin_instance1"> * Host "localhost" * Port 22000 * ... * </Database> * </Plugin> */ static int mysql_config_database (oconfig_item_t *ci) /* {{{ */ { mysql_database_t *db; int status = 0; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING ("mysql plugin: The `Database' block " "needs exactly one string argument."); return (-1); } db = calloc (1, sizeof (*db)); if (db == NULL) { ERROR ("mysql plugin: calloc failed."); return (-1); } /* initialize all the pointers */ db->alias = NULL; db->host = NULL; db->user = NULL; db->pass = NULL; db->database = NULL; db->socket = NULL; db->con = NULL; db->timeout = 0; /* trigger a notification, if it's not running */ db->slave_io_running = 1; db->slave_sql_running = 1; status = cf_util_get_string (ci, &db->instance); if (status != 0) { sfree (db); return (status); } assert (db->instance != NULL); /* Fill the `mysql_database_t' structure.. */ for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp ("Alias", child->key) == 0) status = cf_util_get_string (child, &db->alias); else if (strcasecmp ("Host", child->key) == 0) status = cf_util_get_string (child, &db->host); else if (strcasecmp ("User", child->key) == 0) status = cf_util_get_string (child, &db->user); else if (strcasecmp ("Password", child->key) == 0) status = cf_util_get_string (child, &db->pass); else if (strcasecmp ("Port", child->key) == 0) { status = cf_util_get_port_number (child); if (status > 0) { db->port = status; status = 0; } } else if (strcasecmp ("Socket", child->key) == 0) status = cf_util_get_string (child, &db->socket); else if (strcasecmp ("Database", child->key) == 0) status = cf_util_get_string (child, &db->database); else if (strcasecmp ("ConnectTimeout", child->key) == 0) status = cf_util_get_int (child, &db->timeout); else if (strcasecmp ("MasterStats", child->key) == 0) status = cf_util_get_boolean (child, &db->master_stats); else if (strcasecmp ("SlaveStats", child->key) == 0) status = cf_util_get_boolean (child, &db->slave_stats); else if (strcasecmp ("SlaveNotifications", child->key) == 0) status = cf_util_get_boolean (child, &db->slave_notif); else if (strcasecmp ("InnodbStats", child->key) == 0) status = cf_util_get_boolean (child, &db->innodb_stats); else if (strcasecmp ("WsrepStats", child->key) == 0) status = cf_util_get_boolean (child, &db->wsrep_stats); else { WARNING ("mysql plugin: Option `%s' not allowed here.", child->key); status = -1; } if (status != 0) break; } /* If all went well, register this database for reading */ if (status == 0) { user_data_t ud = { 0 }; char cb_name[DATA_MAX_NAME_LEN]; DEBUG ("mysql plugin: Registering new read callback: %s", (db->database != NULL) ? db->database : "<default>"); ud.data = (void *) db; ud.free_func = mysql_database_free; if (db->instance != NULL) ssnprintf (cb_name, sizeof (cb_name), "mysql-%s", db->instance); else sstrncpy (cb_name, "mysql", sizeof (cb_name)); plugin_register_complex_read (/* group = */ NULL, cb_name, mysql_read, /* interval = */ 0, &ud); } else { mysql_database_free (db); return (-1); } return (0); } /* }}} int mysql_config_database */
static int cx_config_add_url(oconfig_item_t *ci) /* {{{ */ { if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING("curl_xml plugin: The `URL' block " "needs exactly one string argument."); return -1; } cx_t *db = calloc(1, sizeof(*db)); if (db == NULL) { ERROR("curl_xml plugin: calloc failed."); return -1; } db->instance = strdup("default"); if (db->instance == NULL) { ERROR("curl_xml plugin: strdup failed."); sfree(db); return -1; } db->xpath_list = llist_create(); if (db->xpath_list == NULL) { ERROR("curl_xml plugin: list creation failed."); sfree(db->instance); sfree(db); return -1; } db->timeout = -1; int status = cf_util_get_string(ci, &db->url); if (status != 0) { llist_destroy(db->xpath_list); sfree(db->instance); sfree(db); return status; } /* Fill the `cx_t' structure.. */ for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp("Instance", child->key) == 0) status = cf_util_get_string(child, &db->instance); else if (strcasecmp("Plugin", child->key) == 0) status = cf_util_get_string(child, &db->plugin_name); else if (strcasecmp("Host", child->key) == 0) status = cf_util_get_string(child, &db->host); else if (strcasecmp("User", child->key) == 0) status = cf_util_get_string(child, &db->user); else if (strcasecmp("Password", child->key) == 0) status = cf_util_get_string(child, &db->pass); else if (strcasecmp("Digest", child->key) == 0) status = cf_util_get_boolean(child, &db->digest); else if (strcasecmp("VerifyPeer", child->key) == 0) status = cf_util_get_boolean(child, &db->verify_peer); else if (strcasecmp("VerifyHost", child->key) == 0) status = cf_util_get_boolean(child, &db->verify_host); else if (strcasecmp("CACert", child->key) == 0) status = cf_util_get_string(child, &db->cacert); else if (strcasecmp("xpath", child->key) == 0) status = cx_config_add_xpath(db, child); else if (strcasecmp("Header", child->key) == 0) status = cx_config_append_string("Header", &db->headers, child); else if (strcasecmp("Post", child->key) == 0) status = cf_util_get_string(child, &db->post_body); else if (strcasecmp("Namespace", child->key) == 0) status = cx_config_add_namespace(db, child); else if (strcasecmp("Timeout", child->key) == 0) status = cf_util_get_int(child, &db->timeout); else if (strcasecmp("Statistics", child->key) == 0) { db->stats = curl_stats_from_config(child); if (db->stats == NULL) status = -1; } else { WARNING("curl_xml plugin: Option `%s' not allowed here.", child->key); status = -1; } if (status != 0) break; } if (status != 0) { cx_free(db); return status; } if (llist_size(db->xpath_list) == 0) { WARNING("curl_xml plugin: No `xpath' block within `URL' block `%s'.", db->url); cx_free(db); return -1; } if (cx_init_curl(db) != 0) { cx_free(db); return -1; } /* If all went well, register this database for reading */ DEBUG("curl_xml plugin: Registering new read callback: %s", db->instance); char *cb_name = ssnprintf_alloc("curl_xml-%s-%s", db->instance, db->url); plugin_register_complex_read(/* group = */ "curl_xml", cb_name, cx_read, /* interval = */ 0, &(user_data_t){ .data = db, .free_func = cx_free, });
/* * Configuration * ============= * The following approximately two hundred functions are used to handle the * configuration and fill the threshold list. * {{{ */ static int ut_config_type(const threshold_t *th_orig, oconfig_item_t *ci) { threshold_t th; int status = 0; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING("threshold values: The `Type' block needs exactly one string " "argument."); return -1; } if (ci->children_num < 1) { WARNING("threshold values: The `Type' block needs at least one option."); return -1; } memcpy(&th, th_orig, sizeof(th)); sstrncpy(th.type, ci->values[0].value.string, sizeof(th.type)); th.warning_min = NAN; th.warning_max = NAN; th.failure_min = NAN; th.failure_max = NAN; th.hits = 0; th.hysteresis = 0; th.flags = UT_FLAG_INTERESTING; /* interesting by default */ for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; if (strcasecmp("Instance", option->key) == 0) status = cf_util_get_string_buffer(option, th.type_instance, sizeof(th.type_instance)); else if (strcasecmp("DataSource", option->key) == 0) status = cf_util_get_string_buffer(option, th.data_source, sizeof(th.data_source)); else if (strcasecmp("WarningMax", option->key) == 0) status = cf_util_get_double(option, &th.warning_max); else if (strcasecmp("FailureMax", option->key) == 0) status = cf_util_get_double(option, &th.failure_max); else if (strcasecmp("WarningMin", option->key) == 0) status = cf_util_get_double(option, &th.warning_min); else if (strcasecmp("FailureMin", option->key) == 0) status = cf_util_get_double(option, &th.failure_min); else if (strcasecmp("Interesting", option->key) == 0) status = cf_util_get_flag(option, &th.flags, UT_FLAG_INTERESTING); else if (strcasecmp("Invert", option->key) == 0) status = cf_util_get_flag(option, &th.flags, UT_FLAG_INVERT); else if (strcasecmp("Persist", option->key) == 0) status = cf_util_get_flag(option, &th.flags, UT_FLAG_PERSIST); else if (strcasecmp("PersistOK", option->key) == 0) status = cf_util_get_flag(option, &th.flags, UT_FLAG_PERSIST_OK); else if (strcasecmp("Percentage", option->key) == 0) status = cf_util_get_flag(option, &th.flags, UT_FLAG_PERCENTAGE); else if (strcasecmp("Hits", option->key) == 0) status = cf_util_get_int(option, &th.hits); else if (strcasecmp("Hysteresis", option->key) == 0) status = cf_util_get_double(option, &th.hysteresis); else { WARNING("threshold values: Option `%s' not allowed inside a `Type' " "block.", option->key); status = -1; } if (status != 0) break; } if (status == 0) { status = ut_threshold_add(&th); } return status; } /* int ut_config_type */
static int mb_config_add_data (oconfig_item_t *ci) /* {{{ */ { mb_data_t data; int status; int i; memset (&data, 0, sizeof (data)); data.name = NULL; data.register_type = REG_TYPE_UINT16; data.next = NULL; status = cf_util_get_string (ci, &data.name); if (status != 0) return (status); for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; status = 0; if (strcasecmp ("Type", child->key) == 0) status = cf_util_get_string_buffer (child, data.type, sizeof (data.type)); else if (strcasecmp ("Instance", child->key) == 0) status = cf_util_get_string_buffer (child, data.instance, sizeof (data.instance)); else if (strcasecmp ("RegisterBase", child->key) == 0) status = cf_util_get_int (child, &data.register_base); else if (strcasecmp ("RegisterType", child->key) == 0) { char tmp[16]; status = cf_util_get_string_buffer (child, tmp, sizeof (tmp)); if (status != 0) /* do nothing */; else if (strcasecmp ("Uint16", tmp) == 0) data.register_type = REG_TYPE_UINT16; else if (strcasecmp ("Uint32", tmp) == 0) data.register_type = REG_TYPE_UINT32; else if (strcasecmp ("Float", tmp) == 0) data.register_type = REG_TYPE_FLOAT; else { ERROR ("Modbus plugin: The register type \"%s\" is unknown.", tmp); status = -1; } } else { ERROR ("Modbus plugin: Unknown configuration option: %s", child->key); status = -1; } if (status != 0) break; } /* for (i = 0; i < ci->children_num; i++) */ assert (data.name != NULL); if (data.type[0] == 0) { ERROR ("Modbus plugin: Data block \"%s\": No type has been specified.", data.name); status = -1; } if (status == 0) data_copy (&data_definitions, &data); sfree (data.name); return (status); } /* }}} int mb_config_add_data */
static int wr_config_node (oconfig_item_t *ci) /* {{{ */ { wr_node_t *node; int timeout; int status; int i; node = calloc (1, sizeof (*node)); if (node == NULL) return (ENOMEM); node->host = NULL; node->port = 0; node->timeout.tv_sec = 0; node->timeout.tv_usec = 1000; node->conn = NULL; node->prefix = NULL; node->database = 0; node->max_set_size = -1; node->store_rates = 1; pthread_mutex_init (&node->lock, /* attr = */ NULL); status = cf_util_get_string_buffer (ci, node->name, sizeof (node->name)); if (status != 0) { sfree (node); return (status); } for (i = 0; i < ci->children_num; i++) { oconfig_item_t *child = ci->children + i; if (strcasecmp ("Host", child->key) == 0) status = cf_util_get_string (child, &node->host); else if (strcasecmp ("Port", child->key) == 0) { status = cf_util_get_port_number (child); if (status > 0) { node->port = status; status = 0; } } else if (strcasecmp ("Timeout", child->key) == 0) { status = cf_util_get_int (child, &timeout); if (status == 0) node->timeout.tv_usec = timeout; } else if (strcasecmp ("Prefix", child->key) == 0) { status = cf_util_get_string (child, &node->prefix); } else if (strcasecmp ("Database", child->key) == 0) { status = cf_util_get_int (child, &node->database); } else if (strcasecmp ("MaxSetSize", child->key) == 0) { status = cf_util_get_int (child, &node->max_set_size); } else if (strcasecmp ("StoreRates", child->key) == 0) { status = cf_util_get_boolean (child, &node->store_rates); } else WARNING ("write_redis plugin: Ignoring unknown config option \"%s\".", child->key); if (status != 0) break; } /* for (i = 0; i < ci->children_num; i++) */ if (status == 0) { char cb_name[DATA_MAX_NAME_LEN]; user_data_t ud; ssnprintf (cb_name, sizeof (cb_name), "write_redis/%s", node->name); ud.data = node; ud.free_func = wr_config_free; status = plugin_register_write (cb_name, wr_write, &ud); } if (status != 0) wr_config_free (node); return (status); } /* }}} int wr_config_node */
static int redis_config_node (oconfig_item_t *ci) /* {{{ */ { redis_query_t *rq; int status; int timeout; redis_node_t rn = { .port = REDIS_DEF_PORT, .timeout.tv_usec = REDIS_DEF_TIMEOUT }; sstrncpy (rn.host, REDIS_DEF_HOST, sizeof (rn.host)); status = cf_util_get_string_buffer (ci, rn.name, sizeof (rn.name)); if (status != 0) return (status); for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; if (strcasecmp ("Host", option->key) == 0) status = cf_util_get_string_buffer (option, rn.host, sizeof (rn.host)); else if (strcasecmp ("Port", option->key) == 0) { status = cf_util_get_port_number (option); if (status > 0) { rn.port = status; status = 0; } } else if (strcasecmp ("Query", option->key) == 0) { rq = redis_config_query(option); if (rq == NULL) { status =1; } else { rq->next = rn.queries; rn.queries = rq; } } else if (strcasecmp ("Timeout", option->key) == 0) { status = cf_util_get_int (option, &timeout); if (status == 0) rn.timeout.tv_usec = timeout; } else if (strcasecmp ("Password", option->key) == 0) status = cf_util_get_string_buffer (option, rn.passwd, sizeof (rn.passwd)); else WARNING ("redis plugin: Option `%s' not allowed inside a `Node' " "block. I'll ignore this option.", option->key); if (status != 0) break; } if (status != 0) return (status); return (redis_node_add (&rn)); } /* }}} int redis_config_node */ static int redis_config (oconfig_item_t *ci) /* {{{ */ { for (int i = 0; i < ci->children_num; i++) { oconfig_item_t *option = ci->children + i; if (strcasecmp ("Node", option->key) == 0) redis_config_node (option); else WARNING ("redis plugin: Option `%s' not allowed in redis" " configuration. It will be ignored.", option->key); } if (nodes_head == NULL) { ERROR ("redis plugin: No valid node configuration could be found."); return (ENOENT); } return (0); } /* }}} */ __attribute__ ((nonnull(2))) static void redis_submit (char *plugin_instance, const char *type, const char *type_instance, value_t value) /* {{{ */ { value_t values[1]; value_list_t vl = VALUE_LIST_INIT; values[0] = value; vl.values = values; vl.values_len = 1; sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "redis", sizeof (vl.plugin)); if (plugin_instance != NULL) sstrncpy (vl.plugin_instance, plugin_instance, sizeof (vl.plugin_instance)); sstrncpy (vl.type, type, sizeof (vl.type)); if (type_instance != NULL) sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); plugin_dispatch_values (&vl); } /* }}} */