From 67100d8b7cba7fd8da8966f9f24940a216c66da7 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Wed, 20 Feb 2013 14:36:15 +0100 Subject: [PATCH] snort plugin: Implement the "Instance" config option. --- src/collectd.conf.in | 6 ++++-- src/snort.c | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/collectd.conf.in b/src/collectd.conf.in index 0c80ac64..8065b030 100644 --- a/src/collectd.conf.in +++ b/src/collectd.conf.in @@ -916,11 +916,13 @@ # # -# Type "pkt_drop_percent" +# Type "percent" +# Instance "dropped" # Index 1 # # -# Type "wire_mbits_per_sec.realtime" +# Type "bytes" +# Instance "wire-realtime" # Index 2 # # diff --git a/src/snort.c b/src/snort.c index bf804f70..3fb48b6b 100644 --- a/src/snort.c +++ b/src/snort.c @@ -34,6 +34,7 @@ struct metric_definition_s { char *name; char *type; + char *instance; int data_source_type; int index; struct metric_definition_s *next; @@ -78,6 +79,8 @@ static int snort_read_submit(instance_definition_t *id, metric_definition_t *md, sstrncpy(vl.plugin, "snort", sizeof(vl.plugin)); sstrncpy(vl.plugin_instance, id->name, 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)); vl.time = id->last; vl.interval = id->interval; @@ -275,6 +278,8 @@ static int snort_config_add_metric(oconfig_item_t *ci){ if (strcasecmp("Type", option->key) == 0) status = cf_util_get_string(option, &md->type); + else if (strcasecmp("Instance", option->key) == 0) + status = cf_util_get_string(option, &md->instance); else if (strcasecmp("Index", option->key) == 0) status = snort_config_add_metric_index(md, option); else { -- 2.30.2