projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Auto-Merge pull request #3206 from dago/pid_test
[collectd.git]
/
src
/
target_notification.c
diff --git
a/src/target_notification.c
b/src/target_notification.c
index
7c82c79
..
6d8059e
100644
(file)
--- a/
src/target_notification.c
+++ b/
src/target_notification.c
@@
-26,8
+26,8
@@
#include "collectd.h"
#include "collectd.h"
-#include "common.h"
#include "filter_chain.h"
#include "filter_chain.h"
+#include "utils/common/common.h"
#include "utils_cache.h"
#include "utils_subst.h"
#include "utils_cache.h"
#include "utils_subst.h"
@@
-43,7
+43,7
@@
static int tn_config_add_severity(tn_data_t *data, /* {{{ */
ERROR("Target `notification': The `%s' option requires exactly one string "
"argument.",
ci->key);
ERROR("Target `notification': The `%s' option requires exactly one string "
"argument.",
ci->key);
- return
(-1)
;
+ return
-1
;
}
if ((strcasecmp("FAILURE", ci->values[0].value.string) == 0) ||
}
if ((strcasecmp("FAILURE", ci->values[0].value.string) == 0) ||
@@
-61,7
+61,7
@@
static int tn_config_add_severity(tn_data_t *data, /* {{{ */
data->severity = NOTIF_FAILURE;
}
data->severity = NOTIF_FAILURE;
}
- return
(0)
;
+ return
0
;
} /* }}} int tn_config_add_severity */
static int tn_config_add_string(char **dest, /* {{{ */
} /* }}} int tn_config_add_severity */
static int tn_config_add_string(char **dest, /* {{{ */
@@
-69,32
+69,32
@@
static int tn_config_add_string(char **dest, /* {{{ */
char *temp;
if (dest == NULL)
char *temp;
if (dest == NULL)
- return
(-EINVAL)
;
+ return
-EINVAL
;
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
ERROR("Target `notification': The `%s' option requires exactly one string "
"argument.",
ci->key);
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
ERROR("Target `notification': The `%s' option requires exactly one string "
"argument.",
ci->key);
- return
(-1)
;
+ return
-1
;
}
if (ci->values[0].value.string[0] == 0) {
ERROR(
"Target `notification': The `%s' option does not accept empty strings.",
ci->key);
}
if (ci->values[0].value.string[0] == 0) {
ERROR(
"Target `notification': The `%s' option does not accept empty strings.",
ci->key);
- return
(-1)
;
+ return
-1
;
}
temp = sstrdup(ci->values[0].value.string);
if (temp == NULL) {
ERROR("tn_config_add_string: sstrdup failed.");
}
temp = sstrdup(ci->values[0].value.string);
if (temp == NULL) {
ERROR("tn_config_add_string: sstrdup failed.");
- return
(-1)
;
+ return
-1
;
}
free(*dest);
*dest = temp;
}
free(*dest);
*dest = temp;
- return
(0)
;
+ return
0
;
} /* }}} int tn_config_add_string */
static int tn_destroy(void **user_data) /* {{{ */
} /* }}} int tn_config_add_string */
static int tn_destroy(void **user_data) /* {{{ */
@@
-102,16
+102,16
@@
static int tn_destroy(void **user_data) /* {{{ */
tn_data_t *data;
if (user_data == NULL)
tn_data_t *data;
if (user_data == NULL)
- return
(-EINVAL)
;
+ return
-EINVAL
;
data = *user_data;
if (data == NULL)
data = *user_data;
if (data == NULL)
- return
(0)
;
+ return
0
;
sfree(data->message);
sfree(data);
sfree(data->message);
sfree(data);
- return
(0)
;
+ return
0
;
} /* }}} int tn_destroy */
static int tn_create(const oconfig_item_t *ci, void **user_data) /* {{{ */
} /* }}} int tn_destroy */
static int tn_create(const oconfig_item_t *ci, void **user_data) /* {{{ */
@@
-122,7
+122,7
@@
static int tn_create(const oconfig_item_t *ci, void **user_data) /* {{{ */
data = calloc(1, sizeof(*data));
if (data == NULL) {
ERROR("tn_create: calloc failed.");
data = calloc(1, sizeof(*data));
if (data == NULL) {
ERROR("tn_create: calloc failed.");
- return
(-ENOMEM)
;
+ return
-ENOMEM
;
}
data->message = NULL;
}
data->message = NULL;
@@
-168,11
+168,11
@@
static int tn_create(const oconfig_item_t *ci, void **user_data) /* {{{ */
if (status != 0) {
tn_destroy((void *)&data);
if (status != 0) {
tn_destroy((void *)&data);
- return
(status)
;
+ return
status
;
}
*user_data = data;
}
*user_data = data;
- return
(0)
;
+ return
0
;
} /* }}} int tn_create */
static int tn_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */
} /* }}} int tn_create */
static int tn_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */
@@
-186,12
+186,12
@@
static int tn_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */
int rates_failed;
if ((ds == NULL) || (vl == NULL) || (user_data == NULL))
int rates_failed;
if ((ds == NULL) || (vl == NULL) || (user_data == NULL))
- return
(-EINVAL)
;
+ return
-EINVAL
;
data = *user_data;
if (data == NULL) {
ERROR("Target `notification': Invoke: `data' is NULL.");
data = *user_data;
if (data == NULL) {
ERROR("Target `notification': Invoke: `data' is NULL.");
- return
(-EINVAL)
;
+ return
-EINVAL
;
}
/* Initialize the structure. */
}
/* Initialize the structure. */
@@
-221,7
+221,9
@@
static int tn_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */
char template[DATA_MAX_NAME_LEN];
char value_str[DATA_MAX_NAME_LEN];
char template[DATA_MAX_NAME_LEN];
char value_str[DATA_MAX_NAME_LEN];
- ssnprintf(template, sizeof(template), "%%{ds:%s}", ds->ds[i].name);
+ const char *format = "%%{ds:%.*s}";
+ snprintf(template, sizeof(template), format,
+ DATA_MAX_NAME_LEN - strlen(format), ds->ds[i].name);
if (ds->ds[i].type != DS_TYPE_GAUGE) {
if ((rates == NULL) && (rates_failed == 0)) {
if (ds->ds[i].type != DS_TYPE_GAUGE) {
if ((rates == NULL) && (rates_failed == 0)) {
@@
-233,12
+235,12
@@
static int tn_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */
/* If this is a gauge value, use the current value. */
if (ds->ds[i].type == DS_TYPE_GAUGE)
/* If this is a gauge value, use the current value. */
if (ds->ds[i].type == DS_TYPE_GAUGE)
- s
s
nprintf(value_str, sizeof(value_str), GAUGE_FORMAT,
-
(double)vl->values[i].gauge);
+ snprintf(value_str, sizeof(value_str), GAUGE_FORMAT,
+ (double)vl->values[i].gauge);
/* If it's a counter, try to use the current rate. This may fail, if the
* value has been renamed. */
else if (rates != NULL)
/* If it's a counter, try to use the current rate. This may fail, if the
* value has been renamed. */
else if (rates != NULL)
- s
s
nprintf(value_str, sizeof(value_str), GAUGE_FORMAT, (double)rates[i]);
+ snprintf(value_str, sizeof(value_str), GAUGE_FORMAT, (double)rates[i]);
/* Since we don't know any better, use the string `unknown'. */
else
sstrncpy(value_str, "unknown", sizeof(value_str));
/* Since we don't know any better, use the string `unknown'. */
else
sstrncpy(value_str, "unknown", sizeof(value_str));
@@
-249,7
+251,7
@@
static int tn_invoke(const data_set_t *ds, value_list_t *vl, /* {{{ */
plugin_dispatch_notification(&n);
plugin_dispatch_notification(&n);
- return
(FC_TARGET_CONTINUE)
;
+ return
FC_TARGET_CONTINUE
;
} /* }}} int tn_invoke */
void module_register(void) {
} /* }}} int tn_invoke */
void module_register(void) {