collectd/cpu-0/cpu-user
+=item B<NotificationPrefix> I<Prefix> (Publish only)
+
+Like B<Prefix>, this plugin will use one topic per I<notification> instance.
+I<Prefix> is used as the first path element and defaults to B<collectd/event>.
+
+An example topic name would be:
+
+ collectd/event/host/interface-eth0/if_octets
+
=item B<Retain> B<false>|B<true> (Publish only)
Controls whether the MQTT broker will retain (keep a copy of) the last message
Controls whether notifications are sent. Defaults to B<false>.
-Notifications are published to an C<event> subtopic for each type instance.
-
-Example:
-
- collectd/host/interface-eth0/if_octets/event
+Notifications are published with a B<NotificationPrefix> for each type instance.
=item B<CleanSession> B<true>|B<false> (Subscribe only)
#define MQTT_DEFAULT_HOST "localhost"
#define MQTT_DEFAULT_PORT 1883
#define MQTT_DEFAULT_TOPIC_PREFIX "collectd"
+#define MQTT_DEFAULT_NOTIFICATION_PREFIX "collectd/event"
#define MQTT_DEFAULT_TOPIC "collectd/#"
#ifndef MQTT_KEEPALIVE
#define MQTT_KEEPALIVE 60
/* For publishing */
char *topic_prefix;
+ char *notification_prefix;
bool store_rates;
bool retain;
bool send_notifications;
sfree(conf->password);
sfree(conf->client_id);
sfree(conf->topic_prefix);
+ sfree(conf->notification_prefix);
sfree(conf);
}
int status;
char *c;
- if ((conf->topic_prefix == NULL) || (conf->topic_prefix[0] == 0)) {
+ if ((conf->notification_prefix == NULL) ||
+ (conf->notification_prefix[0] == 0)) {
// tempting but unsafe to use FORMAT_VL here
return format_name(buf, buf_len, n->host, n->plugin, n->plugin_instance,
n->type, n->type_instance);
if (status != 0)
return status;
- status = ssnprintf(buf, buf_len, "%s/%s/event", conf->topic_prefix, name);
+ status = ssnprintf(buf, buf_len, "%s/%s", conf->notification_prefix, name);
if ((status < 0) || (((size_t)status) >= buf_len))
return ENOMEM;
* StoreRates true
* Retain false
* SendNotifications false
+ * NotificationPrefix "collectd/event"
* QoS 0
* Format PLAIN
* CACert "ca.pem" Enables TLS if set
conf->qos = 0;
conf->format = MQTT_FORMAT_PLAIN;
conf->topic_prefix = strdup(MQTT_DEFAULT_TOPIC_PREFIX);
+ conf->notification_prefix = strdup(MQTT_DEFAULT_NOTIFICATION_PREFIX);
conf->store_rates = true;
status = pthread_mutex_init(&conf->lock, NULL);
cf_util_get_boolean(child, &conf->retain);
else if (strcasecmp("SendNotifications", child->key) == 0)
cf_util_get_boolean(child, &conf->send_notifications);
+ else if (strcasecmp("NotificationPrefix", child->key) == 0)
+ cf_util_get_string(child, &conf->notification_prefix);
else if (strcasecmp("CACert", child->key) == 0)
cf_util_get_string(child, &conf->cacertificatefile);
else if (strcasecmp("CertificateFile", child->key) == 0)