- else
- {
- ERROR ("write_http plugin: Invalid SSLVersion "
- "option: %s.", value);
- status = EINVAL;
- }
-
- sfree(value);
- }
- else if (strcasecmp ("Format", child->key) == 0)
- status = config_set_format (cb, child);
- else if (strcasecmp ("StoreRates", child->key) == 0)
- status = cf_util_get_boolean (child, &cb->store_rates);
- else if (strcasecmp ("BufferSize", child->key) == 0)
- status = cf_util_get_int (child, &buffer_size);
- else if (strcasecmp ("LowSpeedLimit", child->key) == 0)
- status = cf_util_get_int (child, &cb->low_speed_limit);
- else if (strcasecmp ("Timeout", child->key) == 0)
- status = cf_util_get_int (child, &cb->timeout);
- else if (strcasecmp ("LogHttpError", child->key) == 0)
- status = cf_util_get_boolean (child, &cb->log_http_error);
- else if (strcasecmp ("Header", child->key) == 0)
- status = wh_config_append_string ("Header", &cb->headers, child);
- else
- {
- ERROR ("write_http plugin: Invalid configuration "
- "option: %s.", child->key);
- status = EINVAL;
- }
-
- if (status != 0)
- break;
- }
-
- if (status != 0)
- {
- wh_callback_free (cb);
- return (status);
- }
-
- if (cb->location == NULL)
- {
- ERROR ("write_http plugin: no URL defined for instance '%s'",
- cb->name);
- wh_callback_free (cb);
- return (-1);
- }
-
- if (cb->low_speed_limit > 0)
- cb->low_speed_time = CDTIME_T_TO_TIME_T(plugin_get_interval());
-
- /* Determine send_buffer_size. */
- cb->send_buffer_size = WRITE_HTTP_DEFAULT_BUFFER_SIZE;
- if (buffer_size >= 1024)
- cb->send_buffer_size = (size_t) buffer_size;
- else if (buffer_size != 0)
- ERROR ("write_http plugin: Ignoring invalid BufferSize setting (%d).",
- buffer_size);
-
- /* Allocate the buffer. */
- cb->send_buffer = malloc (cb->send_buffer_size);
- if (cb->send_buffer == NULL)
- {
- ERROR ("write_http plugin: malloc(%zu) failed.", cb->send_buffer_size);
- wh_callback_free (cb);
- return (-1);
- }
- /* Nulls the buffer and sets ..._free and ..._fill. */
- wh_reset_buffer (cb);
-
- ssnprintf (callback_name, sizeof (callback_name), "write_http/%s",
- cb->name);
- DEBUG ("write_http: Registering write callback '%s' with URL '%s'",
- callback_name, cb->location);
-
- user_data.data = cb;
- plugin_register_flush (callback_name, wh_flush, &user_data);
-
- user_data.free_func = wh_callback_free;
- plugin_register_write (callback_name, wh_write, &user_data);
-
- return (0);
+ else {
+ ERROR("write_http plugin: Invalid SSLVersion "
+ "option: %s.",
+ value);
+ status = EINVAL;
+ }
+
+ sfree(value);
+ } else if (strcasecmp("Format", child->key) == 0)
+ status = config_set_format(cb, child);
+ else if (strcasecmp("Metrics", child->key) == 0)
+ cf_util_get_boolean(child, &cb->send_metrics);
+ else if (strcasecmp("Notifications", child->key) == 0)
+ cf_util_get_boolean(child, &cb->send_notifications);
+ else if (strcasecmp("StoreRates", child->key) == 0)
+ status = cf_util_get_boolean(child, &cb->store_rates);
+ else if (strcasecmp("BufferSize", child->key) == 0)
+ status = cf_util_get_int(child, &buffer_size);
+ else if (strcasecmp("LowSpeedLimit", child->key) == 0)
+ status = cf_util_get_int(child, &cb->low_speed_limit);
+ else if (strcasecmp("Timeout", child->key) == 0)
+ status = cf_util_get_int(child, &cb->timeout);
+ else if (strcasecmp("LogHttpError", child->key) == 0)
+ status = cf_util_get_boolean(child, &cb->log_http_error);
+ else if (strcasecmp("Header", child->key) == 0)
+ status = wh_config_append_string("Header", &cb->headers, child);
+ else {
+ ERROR("write_http plugin: Invalid configuration "
+ "option: %s.",
+ child->key);
+ status = EINVAL;
+ }
+
+ if (status != 0)
+ break;
+ }
+
+ if (status != 0) {
+ wh_callback_free(cb);
+ return (status);
+ }
+
+ if (cb->location == NULL) {
+ ERROR("write_http plugin: no URL defined for instance '%s'", cb->name);
+ wh_callback_free(cb);
+ return (-1);
+ }
+
+ if (!cb->send_metrics && !cb->send_notifications) {
+ ERROR("write_http plugin: Neither metrics nor notifications "
+ "are enabled for \"%s\".",
+ cb->name);
+ wh_callback_free(cb);
+ return (-1);
+ }
+
+ if (cb->low_speed_limit > 0)
+ cb->low_speed_time = CDTIME_T_TO_TIME_T(plugin_get_interval());
+
+ /* Determine send_buffer_size. */
+ cb->send_buffer_size = WRITE_HTTP_DEFAULT_BUFFER_SIZE;
+ if (buffer_size >= 1024)
+ cb->send_buffer_size = (size_t)buffer_size;
+ else if (buffer_size != 0)
+ ERROR("write_http plugin: Ignoring invalid BufferSize setting (%d).",
+ buffer_size);
+
+ /* Allocate the buffer. */
+ cb->send_buffer = malloc(cb->send_buffer_size);
+ if (cb->send_buffer == NULL) {
+ ERROR("write_http plugin: malloc(%zu) failed.", cb->send_buffer_size);
+ wh_callback_free(cb);
+ return (-1);
+ }
+ /* Nulls the buffer and sets ..._free and ..._fill. */
+ wh_reset_buffer(cb);
+
+ ssnprintf(callback_name, sizeof(callback_name), "write_http/%s", cb->name);
+ DEBUG("write_http: Registering write callback '%s' with URL '%s'",
+ callback_name, cb->location);
+
+ user_data_t user_data = {
+ .data = cb, .free_func = wh_callback_free,
+ };
+
+ if (cb->send_metrics) {
+ plugin_register_write(callback_name, wh_write, &user_data);
+ user_data.free_func = NULL;
+
+ plugin_register_flush(callback_name, wh_flush, &user_data);
+ }
+
+ if (cb->send_notifications) {
+ plugin_register_notification(callback_name, wh_notify, &user_data);
+ user_data.free_func = NULL;
+ }
+
+ return (0);