projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge remote-tracking branch 'github/pr/2052'
[collectd.git]
/
src
/
tail.c
diff --git
a/src/tail.c
b/src/tail.c
index
751243b
..
0ac8be7
100644
(file)
--- a/
src/tail.c
+++ b/
src/tail.c
@@
-25,6
+25,7
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "utils_tail_match.h"
#include "common.h"
#include "plugin.h"
#include "utils_tail_match.h"
@@
-56,9
+57,9
@@
struct ctail_config_match_s
};
typedef struct ctail_config_match_s ctail_config_match_t;
};
typedef struct ctail_config_match_s ctail_config_match_t;
-cu_tail_match_t **tail_match_list = NULL;
-size_t tail_match_list_num = 0;
-cdtime_t tail_match_list_intervals[255];
+
static
cu_tail_match_t **tail_match_list = NULL;
+s
tatic s
ize_t tail_match_list_num = 0;
+
static
cdtime_t tail_match_list_intervals[255];
static int ctail_config_add_match_dstype (ctail_config_match_t *cm,
oconfig_item_t *ci)
static int ctail_config_add_match_dstype (ctail_config_match_t *cm,
oconfig_item_t *ci)
@@
-84,6
+85,8
@@
static int ctail_config_add_match_dstype (ctail_config_match_t *cm,
cm->flags |= UTILS_MATCH_CF_GAUGE_INC;
else if (strcasecmp ("GaugeAdd", ci->values[0].value.string) == 0)
cm->flags |= UTILS_MATCH_CF_GAUGE_ADD;
cm->flags |= UTILS_MATCH_CF_GAUGE_INC;
else if (strcasecmp ("GaugeAdd", ci->values[0].value.string) == 0)
cm->flags |= UTILS_MATCH_CF_GAUGE_ADD;
+ else if (strcasecmp ("GaugePersist", ci->values[0].value.string) == 0)
+ cm->flags |= UTILS_MATCH_CF_GAUGE_PERSIST;
else
cm->flags = 0;
}
else
cm->flags = 0;
}
@@
-137,11
+140,8
@@
static int ctail_config_add_match_dstype (ctail_config_match_t *cm,
static int ctail_config_add_match (cu_tail_match_t *tm,
const char *plugin_instance, oconfig_item_t *ci, cdtime_t interval)
{
static int ctail_config_add_match (cu_tail_match_t *tm,
const char *plugin_instance, oconfig_item_t *ci, cdtime_t interval)
{
- ctail_config_match_t cm;
+ ctail_config_match_t cm
= { 0 }
;
int status;
int status;
- int i;
-
- memset (&cm, '\0', sizeof (cm));
if (ci->values_num != 0)
{
if (ci->values_num != 0)
{
@@
-149,7
+149,7
@@
static int ctail_config_add_match (cu_tail_match_t *tm,
}
status = 0;
}
status = 0;
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *option = ci->children + i;
{
oconfig_item_t *option = ci->children + i;
@@
-224,7
+224,6
@@
static int ctail_config_add_file (oconfig_item_t *ci)
cdtime_t interval = 0;
char *plugin_instance = NULL;
int num_matches = 0;
cdtime_t interval = 0;
char *plugin_instance = NULL;
int num_matches = 0;
- int i;
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
{
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
{
@@
-236,11
+235,11
@@
static int ctail_config_add_file (oconfig_item_t *ci)
if (tm == NULL)
{
ERROR ("tail plugin: tail_match_create (%s) failed.",
if (tm == NULL)
{
ERROR ("tail plugin: tail_match_create (%s) failed.",
- ci->values[0].value.string);
+
ci->values[0].value.string);
return (-1);
}
return (-1);
}
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *option = ci->children + i;
int status = 0;
{
oconfig_item_t *option = ci->children + i;
int status = 0;
@@
-253,7
+252,7
@@
static int ctail_config_add_file (oconfig_item_t *ci)
{
status = ctail_config_add_match (tm, plugin_instance, option, interval);
if (status == 0)
{
status = ctail_config_add_match (tm, plugin_instance, option, interval);
if (status == 0)
- num_matches++;
+
num_matches++;
/* Be mild with failed matches.. */
status = 0;
}
/* Be mild with failed matches.. */
status = 0;
}
@@
-266,10
+265,12
@@
static int ctail_config_add_file (oconfig_item_t *ci)
break;
} /* for (i = 0; i < ci->children_num; i++) */
break;
} /* for (i = 0; i < ci->children_num; i++) */
+ sfree (plugin_instance);
+
if (num_matches == 0)
{
ERROR ("tail plugin: No (valid) matches found for file `%s'.",
if (num_matches == 0)
{
ERROR ("tail plugin: No (valid) matches found for file `%s'.",
- ci->values[0].value.string);
+
ci->values[0].value.string);
tail_match_destroy (tm);
return (-1);
}
tail_match_destroy (tm);
return (-1);
}
@@
-277,8
+278,8
@@
static int ctail_config_add_file (oconfig_item_t *ci)
{
cu_tail_match_t **temp;
{
cu_tail_match_t **temp;
- temp =
(cu_tail_match_t **)
realloc (tail_match_list,
- sizeof (cu_tail_match_t *) * (tail_match_list_num + 1));
+ temp = realloc (tail_match_list,
+
sizeof (cu_tail_match_t *) * (tail_match_list_num + 1));
if (temp == NULL)
{
ERROR ("tail plugin: realloc failed.");
if (temp == NULL)
{
ERROR ("tail plugin: realloc failed.");
@@
-297,9
+298,7
@@
static int ctail_config_add_file (oconfig_item_t *ci)
static int ctail_config (oconfig_item_t *ci)
{
static int ctail_config (oconfig_item_t *ci)
{
- int i;
-
- for (i = 0; i < ci->children_num; i++)
+ for (int i = 0; i < ci->children_num; i++)
{
oconfig_item_t *option = ci->children + i;
{
oconfig_item_t *option = ci->children + i;
@@
-331,8
+330,6
@@
static int ctail_read (user_data_t *ud)
static int ctail_init (void)
{
char str[255];
static int ctail_init (void)
{
char str[255];
- user_data_t ud;
- size_t i;
if (tail_match_list_num == 0)
{
if (tail_match_list_num == 0)
{
@@
-340,13
+337,14
@@
static int ctail_init (void)
return (-1);
}
return (-1);
}
- memset(&ud, '\0', sizeof(ud));
-
- for (i = 0; i < tail_match_list_num; i++)
+ for (size_t i = 0; i < tail_match_list_num; i++)
{
{
- ud.data = (void *)tail_match_list[i];
ssnprintf(str, sizeof(str), "tail-%zu", i);
ssnprintf(str, sizeof(str), "tail-%zu", i);
- plugin_register_complex_read (NULL, str, ctail_read, tail_match_list_intervals[i], &ud);
+
+ plugin_register_complex_read (NULL, str, ctail_read, tail_match_list_intervals[i],
+ &(user_data_t) {
+ .data = tail_match_list[i],
+ });
}
return (0);
}
return (0);
@@
-354,9
+352,7
@@
static int ctail_init (void)
static int ctail_shutdown (void)
{
static int ctail_shutdown (void)
{
- size_t i;
-
- for (i = 0; i < tail_match_list_num; i++)
+ for (size_t i = 0; i < tail_match_list_num; i++)
{
tail_match_destroy (tail_match_list[i]);
tail_match_list[i] = NULL;
{
tail_match_destroy (tail_match_list[i]);
tail_match_list[i] = NULL;