Code

snort plugin: Implement the "Instance" config option.
authorFlorian Forster <octo@collectd.org>
Wed, 20 Feb 2013 13:36:15 +0000 (14:36 +0100)
committerFlorian Forster <octo@collectd.org>
Wed, 20 Feb 2013 13:36:15 +0000 (14:36 +0100)
src/collectd.conf.in
src/snort.c

index 0c80ac645713b790b609ef3427df2456363a3203..8065b0304f24b08fcaa0cdd06277d75c10f5ef8a 100644 (file)
 
 #<Plugin "snort">
 #   <Metric "dropped">
-#       Type "pkt_drop_percent"
+#       Type "percent"
+#       Instance "dropped"
 #       Index 1
 #   </Metric>
 #   <Metric "mbps">
-#       Type "wire_mbits_per_sec.realtime"
+#       Type "bytes"
+#       Instance "wire-realtime"
 #       Index 2
 #   </Metric>
 #   <Metric "alerts">
index bf804f705538d8789f4ad785bf2e69c93873eefd..3fb48b6bf6323fa544413b3939ecddd1c1786757 100644 (file)
@@ -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 {