summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 88ed443)
raw | patch | inline | side by side (parent: 88ed443)
author | Florian Forster <octo@collectd.org> | |
Fri, 22 Mar 2013 21:57:43 +0000 (22:57 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 22 Mar 2013 21:57:43 +0000 (22:57 +0100) |
This way the syntax of tail_csv's configuration is closer to that of the
csv plugin.
csv plugin.
src/collectd.conf.in | patch | blob | history | |
src/collectd.conf.pod | patch | blob | history | |
src/tail_csv.c | patch | blob | history |
diff --git a/src/collectd.conf.in b/src/collectd.conf.in
index fa4cccfea127de2cda2e6f5f4a3727d2aa413f95..8afad3eaa6c9957698d5ec00675656ad03cb8ffc 100644 (file)
--- a/src/collectd.conf.in
+++ b/src/collectd.conf.in
# Type "kpackets_wire_per_sec.realtime"
# Index 4
# </Metric>
-# <Instance "snort-eth0">
-# Path "/var/log/snort/snort.stats"
+# <File "/var/log/snort/snort.stats">
+# Instance "snort-eth0"
# Interval 600
# Collect "dropped" "mbps" "alerts" "kpps"
-# </Instance>
+# </File>
#</Plugin>
#<Plugin tcpconns>
diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod
index ee1481520a970fcf617a39f20eb3107f4cfce110..75509e86c3d6018b5932002f999627d8ed348ec7 100644 (file)
--- a/src/collectd.conf.pod
+++ b/src/collectd.conf.pod
B<Synopsis:>
<Plugin "tail_csv">
- <Metric "dropped">
+ <Metric "snort-dropped">
Type "percent"
Instance "dropped"
Index 1
</Metric>
- <Instance "snort-eth0">
- Path "/var/log/snort/snort.stats"
+ <File "/var/log/snort/snort.stats">
+ Instance "snort-eth0"
Interval 600
- Collect "dropped"
- </Instance>
+ Collect "snort-dropped"
+ </File>
</Plugin>
The configuration consists of one or more B<Metric> blocks that define an index
=back
-=item E<lt>B<Instance> I<Name>E<gt>
+=item E<lt>B<File> I<Path>E<gt>
-Each B<Instance> block represents on CSV file to read. The block's I<Name>
-will be used as I<plugin instance> when dispatching the values and is used to
-support multiple separate CSV files. There must be at least one I<Instance>
-block but there can be multiple if you have multiple CSV files.
+Each B<File> block represents one CSV file to read. There must be at least one
+I<File> block but there can be multiple if you have multiple CSV files.
=over 4
-=item B<Path> I<Path>
+=item B<Instance> I<PluginInstance>
-Configures the I<Path> to the statistics file to read.
+Sets the I<plugin instance> used when dispatching the values.
=item B<Collect> I<Metric>
diff --git a/src/tail_csv.c b/src/tail_csv.c
index cab26416cbffa97183e4f2c15bf2a14ff309e97e..ed79170add14069e35f777a81b1f6a690cb246a0 100644 (file)
--- a/src/tail_csv.c
+++ b/src/tail_csv.c
typedef struct metric_definition_s metric_definition_t;
struct instance_definition_s {
- char *name;
+ char *instance;
char *path;
cu_tail_t *tail;
metric_definition_t **metric_list;
sstrncpy(vl.host, hostname_g, sizeof (vl.host));
sstrncpy(vl.plugin, "tail_csv", sizeof(vl.plugin));
- sstrncpy(vl.plugin_instance, id->name, sizeof(vl.plugin_instance));
+ sstrncpy(vl.plugin_instance, id->instance, sizeof(vl.plugin_instance));
sstrncpy(vl.type, md->type, sizeof(vl.type));
if (md->instance != NULL)
sstrncpy(vl.type_instance, md->instance, sizeof(vl.type_instance));
instance_definition_t *id;
id = ud->data;
- DEBUG("tail_csv plugin: tcsv_read (instance = %s)", id->name);
+ DEBUG("tail_csv plugin: tcsv_read (instance = %s)", id->instance);
if (id->tail == NULL)
{
if (status != 0)
{
ERROR ("tail_csv plugin: Instance \"%s\": cu_tail_readline failed "
- "with status %i.", id->name, status);
+ "with status %i.", id->instance, status);
return (-1);
}
if (id == NULL)
return;
- if (id->name != NULL)
- DEBUG("tail_csv plugin: Destroying instance definition `%s'.", id->name);
+ if (id->instance != NULL)
+ DEBUG("tail_csv plugin: Destroying instance definition `%s'.", id->instance);
cu_tail_destroy (id->tail);
id->tail = NULL;
- sfree(id->name);
+ sfree(id->instance);
sfree(id->path);
sfree(id->metric_list);
sfree(id);
@@ -407,7 +407,7 @@ static int tcsv_config_add_instance_collect(instance_definition_t *id, oconfig_i
return (-1);
}
- DEBUG("tail_csv plugin: id { name=%s md->name=%s }", id->name, metric->name);
+ DEBUG("tail_csv plugin: id { instance=%s md->name=%s }", id->instance, metric->name);
id->metric_list[i] = metric;
id->metric_list_len++;
@@ -417,8 +417,8 @@ static int tcsv_config_add_instance_collect(instance_definition_t *id, oconfig_i
}
/* Parse instance */
-static int tcsv_config_add_instance(oconfig_item_t *ci){
-
+static int tcsv_config_add_file(oconfig_item_t *ci)
+{
instance_definition_t* id;
int status = 0;
int i;
user_data_t cb_data;
struct timespec cb_interval;
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)){
- WARNING("tail_csv plugin: The `Instance' config option needs exactly one string argument.");
- return (-1);
- }
-
- id = (instance_definition_t *)malloc(sizeof(*id));
+ id = malloc(sizeof(*id));
if (id == NULL)
return (-1);
memset(id, 0, sizeof(*id));
+ id->instance = NULL;
+ id->path = NULL;
+ id->metric_list = NULL;
+ id->next = NULL;
- id->name = strdup(ci->values[0].value.string);
- if (id->name == NULL){
- free(id);
- return (-1);
+ status = cf_util_get_string (ci, &id->path);
+ if (status != 0) {
+ sfree (id);
+ return (status);
}
/* Use default interval. */
oconfig_item_t *option = ci->children + i;
status = 0;
- if (strcasecmp("Path", option->key) == 0)
- status = cf_util_get_string(option, &id->path);
+ if (strcasecmp("Instance", option->key) == 0)
+ status = cf_util_get_string(option, &id->instance);
else if (strcasecmp("Collect", option->key) == 0)
status = tcsv_config_add_instance_collect(id, option);
else if (strcasecmp("Interval", option->key) == 0)
return (-1);
}
- DEBUG("tail_csv plugin: id = { name = %s, path = %s }", id->name, id->path);
+ DEBUG("tail_csv plugin: id = { instance = %s, path = %s }", id->instance, id->path);
- ssnprintf (cb_name, sizeof (cb_name), "tail_csv/%s", id->name);
+ ssnprintf (cb_name, sizeof (cb_name), "tail_csv/%s", id->path);
memset(&cb_data, 0, sizeof(cb_data));
cb_data.data = id;
cb_data.free_func = tcsv_instance_definition_destroy;
oconfig_item_t *child = ci->children + i;
if (strcasecmp("Metric", child->key) == 0)
tcsv_config_add_metric(child);
- else if (strcasecmp("Instance", child->key) == 0)
- tcsv_config_add_instance(child);
+ else if (strcasecmp("File", child->key) == 0)
+ tcsv_config_add_file(child);
else
WARNING("tail_csv plugin: Ignore unknown config option `%s'.", child->key);
}