summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 53d05e8)
raw | patch | inline | side by side (parent: 53d05e8)
author | Florian Forster <octo@collectd.org> | |
Wed, 20 Feb 2013 08:31:12 +0000 (09:31 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 20 Feb 2013 08:31:12 +0000 (09:31 +0100) |
Also uses the utility function from configfile.h to read the metric
definition's name.
definition's name.
src/snort.c | patch | blob | history |
diff --git a/src/snort.c b/src/snort.c
index 208258228b0c6da4d32384719da68f6790077466..bf804f705538d8789f4ad785bf2e69c93873eefd 100644 (file)
--- a/src/snort.c
+++ b/src/snort.c
int status = 0;
int i;
- if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)){
- WARNING("snort plugin: The `Metric' config option needs exactly one string argument.");
- return (-1);
- }
-
md = (metric_definition_t *)malloc(sizeof(*md));
if (md == NULL)
return (-1);
memset(md, 0, sizeof(*md));
- md->name = strdup(ci->values[0].value.string);
- if (md->name == NULL){
- free(md);
+ md->name = NULL;
+ status = cf_util_get_string (ci, &md->name);
+ if (status != 0) {
+ sfree (md);
return (-1);
}
/* Retrieve the data source type from the types db. */
ds = plugin_get_ds(md->type);
if (ds == NULL){
- WARNING("snort plugin: `Type' must be defined in `types.db'.");
+ ERROR ("snort plugin: Failed to look up type \"%s\". "
+ "It may not be defined in the types.db file. "
+ "Please read the types.db(5) manual page for more details.",
+ md->type);
snort_metric_definition_destroy(md);
return (-1);
+ } else if (ds->ds_num != 1) {
+ ERROR ("snort plugin: The type \"%s\" has %i data sources. "
+ "Only types with a single data soure are supported.",
+ ds->type, ds->ds_num);
+ return (-1);
} else {
md->data_source_type = ds->ds->type;
}