projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
proto/*.proto: Add the go_package option.
[collectd.git]
/
src
/
mqtt.c
diff --git
a/src/mqtt.c
b/src/mqtt.c
index
8bc412c
..
b318f21
100644
(file)
--- a/
src/mqtt.c
+++ b/
src/mqtt.c
@@
-33,11
+33,8
@@
#include "collectd.h"
#include "common.h"
#include "plugin.h"
#include "collectd.h"
#include "common.h"
#include "plugin.h"
-#include "utils_cache.h"
#include "utils_complain.h"
#include "utils_complain.h"
-#include <pthread.h>
-
#include <mosquitto.h>
#define MQTT_MAX_TOPIC_SIZE 1024
#include <mosquitto.h>
#define MQTT_MAX_TOPIC_SIZE 1024
@@
-552,14
+549,14
@@
static int mqtt_config_publisher (oconfig_item_t *ci)
{
mqtt_client_conf_t *conf;
char cb_name[1024];
{
mqtt_client_conf_t *conf;
char cb_name[1024];
- user_data_t user_data;
+ user_data_t user_data
= { 0 }
;
int status;
int i;
conf = calloc (1, sizeof (*conf));
if (conf == NULL)
{
int status;
int i;
conf = calloc (1, sizeof (*conf));
if (conf == NULL)
{
- ERROR ("mqtt plugin:
m
alloc failed.");
+ ERROR ("mqtt plugin:
c
alloc failed.");
return (-1);
}
conf->publish = 1;
return (-1);
}
conf->publish = 1;
@@
-637,7
+634,6
@@
static int mqtt_config_publisher (oconfig_item_t *ci)
}
ssnprintf (cb_name, sizeof (cb_name), "mqtt/%s", conf->name);
}
ssnprintf (cb_name, sizeof (cb_name), "mqtt/%s", conf->name);
- memset (&user_data, 0, sizeof (user_data));
user_data.data = conf;
plugin_register_write (cb_name, mqtt_write, &user_data);
user_data.data = conf;
plugin_register_write (cb_name, mqtt_write, &user_data);
@@
-664,7
+660,7
@@
static int mqtt_config_subscriber (oconfig_item_t *ci)
conf = calloc (1, sizeof (*conf));
if (conf == NULL)
{
conf = calloc (1, sizeof (*conf));
if (conf == NULL)
{
- ERROR ("mqtt plugin:
m
alloc failed.");
+ ERROR ("mqtt plugin:
c
alloc failed.");
return (-1);
}
conf->publish = 0;
return (-1);
}
conf->publish = 0;
@@
-700,11
+696,11
@@
static int mqtt_config_subscriber (oconfig_item_t *ci)
cf_util_get_string (child, &conf->host);
else if (strcasecmp ("Port", child->key) == 0)
{
cf_util_get_string (child, &conf->host);
else if (strcasecmp ("Port", child->key) == 0)
{
-
int tmp
= cf_util_get_port_number (child);
- if (
tmp
< 0)
+
status
= cf_util_get_port_number (child);
+ if (
status
< 0)
ERROR ("mqtt plugin: Invalid port number.");
else
ERROR ("mqtt plugin: Invalid port number.");
else
- conf->port =
tmp
;
+ conf->port =
status
;
}
else if (strcasecmp ("ClientId", child->key) == 0)
cf_util_get_string (child, &conf->client_id);
}
else if (strcasecmp ("ClientId", child->key) == 0)
cf_util_get_string (child, &conf->client_id);
@@
-714,12
+710,12
@@
static int mqtt_config_subscriber (oconfig_item_t *ci)
cf_util_get_string (child, &conf->password);
else if (strcasecmp ("QoS", child->key) == 0)
{
cf_util_get_string (child, &conf->password);
else if (strcasecmp ("QoS", child->key) == 0)
{
- int
tmp
= -1;
- status = cf_util_get_int (child, &
tmp
);
- if ((status != 0) || (
tmp < 0) || (tmp
> 2))
+ int
qos
= -1;
+ status = cf_util_get_int (child, &
qos
);
+ if ((status != 0) || (
qos < 0) || (qos
> 2))
ERROR ("mqtt plugin: Not a valid QoS setting.");
else
ERROR ("mqtt plugin: Not a valid QoS setting.");
else
- conf->qos =
tmp
;
+ conf->qos =
qos
;
}
else if (strcasecmp ("Topic", child->key) == 0)
cf_util_get_string (child, &conf->topic);
}
else if (strcasecmp ("Topic", child->key) == 0)
cf_util_get_string (child, &conf->topic);