diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2021-06-07 14:42:40 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2021-06-07 15:04:46 +0200 |
commit | 54e0601fec5330aa93810c7212dde233c4354379 (patch) | |
tree | ed44b4b3d72d407a73c295a3df9952a255905891 /examples | |
parent | 382706cd20b99f12b0e7106ffc4af0e01a5e0e02 (diff) |
Unified IO buffer mgmt.
* c-collectd gives the user control over collectd-exec instance name
* added missing collectd type `flow_l4_icmp_count`
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/c-collectd/c-collectd.c | 23 | ||||
-rw-r--r-- | examples/c-collectd/plugin_nDPIsrvd_types.db | 1 |
2 files changed, 20 insertions, 4 deletions
diff --git a/examples/c-collectd/c-collectd.c b/examples/c-collectd/c-collectd.c index 42e8b6020..59f724773 100644 --- a/examples/c-collectd/c-collectd.c +++ b/examples/c-collectd/c-collectd.c @@ -10,6 +10,8 @@ #include "nDPIsrvd.h" +#define DEFAULT_COLLECTD_EXEC_INST "exec-nDPIsrvd" + #define LOG(flags, format, ...) \ if (quiet == 0) \ { \ @@ -28,6 +30,7 @@ static int collectd_timerfd = -1; static char * serv_optarg = NULL; static char * collectd_hostname = NULL; static char * collectd_interval = NULL; +static char * instance_name = NULL; static nDPIsrvd_ull collectd_interval_ull = 0uL; static int quiet = 0; @@ -134,16 +137,19 @@ static int parse_options(int argc, char ** argv) static char const usage[] = "Usage: %s " - "[-s host] [-c hostname] [-i interval] [-q]\n\n" + "[-s host] [-c hostname] [-n collectd-instance-name] [-i interval] [-q]\n\n" "\t-s\tDestination where nDPIsrvd is listening on.\n" "\t-c\tCollectd hostname.\n" "\t \tThis value defaults to the environment variable COLLECTD_HOSTNAME.\n" + "\t-n\tName of the collectd(-exec) instance.\n" + "\t \tDefaults to: " DEFAULT_COLLECTD_EXEC_INST + "\n" "\t-i\tInterval between print statistics to stdout.\n" "\t \tThis value defaults to the environment variable COLLECTD_INTERVAL.\n" "\t-q\tDo not print anything except collectd statistics.\n" "\t \tAutomatically enabled if environment variables mentioned above are set.\n"; - while ((opt = getopt(argc, argv, "hs:c:i:q")) != -1) + while ((opt = getopt(argc, argv, "hs:c:n:i:q")) != -1) { switch (opt) { @@ -155,6 +161,10 @@ static int parse_options(int argc, char ** argv) free(collectd_hostname); collectd_hostname = strdup(optarg); break; + case 'n': + free(instance_name); + instance_name = strdup(optarg); + break; case 'i': free(collectd_interval); collectd_interval = strdup(optarg); @@ -182,6 +192,11 @@ static int parse_options(int argc, char ** argv) } } + if (instance_name == NULL) + { + instance_name = strdup(DEFAULT_COLLECTD_EXEC_INST); + } + if (collectd_interval == NULL) { collectd_interval = getenv("COLLECTD_INTERVAL"); @@ -217,9 +232,9 @@ static int parse_options(int argc, char ** argv) return 0; } -#define COLLECTD_PUTVAL_N_FORMAT(name) "PUTVAL %s/nDPId/" #name " interval=%llu %llu:%llu\n" +#define COLLECTD_PUTVAL_N_FORMAT(name) "PUTVAL %s/%s/" #name " interval=%llu %llu:%llu\n" #define COLLECTD_PUTVAL_N(value) \ - collectd_hostname, collectd_interval_ull, (unsigned long long int)now, \ + collectd_hostname, instance_name, collectd_interval_ull, (unsigned long long int)now, \ (unsigned long long int)collectd_statistics.value static void print_collectd_exec_output(void) { diff --git a/examples/c-collectd/plugin_nDPIsrvd_types.db b/examples/c-collectd/plugin_nDPIsrvd_types.db index 7211939c3..dc910a3bb 100644 --- a/examples/c-collectd/plugin_nDPIsrvd_types.db +++ b/examples/c-collectd/plugin_nDPIsrvd_types.db @@ -60,6 +60,7 @@ flow_category_unknown_count value:GAUGE:0:U flow_l3_ip4_count value:GAUGE:0:U flow_l3_ip6_count value:GAUGE:0:U flow_l3_other_count value:GAUGE:0:U +flow_l4_icmp_count value:GAUGE:0:U flow_l4_tcp_count value:GAUGE:0:U flow_l4_udp_count value:GAUGE:0:U flow_l4_other_count value:GAUGE:0:U |