[collectd] Incomplete patch to differentiate traffic for dns server

Florian Forster octo at verplant.org
Fri Sep 26 17:11:49 CEST 2008


Hi Alessandro,

thanks a lot for your patch :) I have a couple of comments for you :)

On Mon, Sep 22, 2008 at 05:26:58PM +0200, Alessandro Iurlano wrote:
> No testing at all has been done for ip v6 even if some code exists in
> the patch.

Don't worry about that - I can do that.

> +struct sockaddr ** local_addresses_v4;
> +struct sockaddr ** local_addresses_v6;

Please don't export global variables in plugins. I'd so something like:
-- 8< -- src/utils_dns.h -- 8< --
 struct sockaddr_dns_s
 {
   int family;
   struct sockaddr_storage sa;
 };
 typedef struct sockaddr_dns_s sockaddr_dns_t;

 int handle_pcap (...,
     size_t local_addresses_length,
     sockaddr_dns_t *local_addresses);
-- >8 -- src/utils_dns.h -- >8 --

Maybe the `get_local_addresses' function, i. e. the one creating this
list, could be moved to `src/utils_dns.c', too.

> --- a/src/types.db
> +dns_sources		Local:COUNTER:0:U, Remote:COUNTER:0:U

Please use only one data source in this case. For example, this could be
done like this:
-- 8< -- src/types.db -- 8< --
dns_source      value:COUNTER:0:U
-- >8 -- src/types.db -- >8 --
-- 8< -- src/dns.c -- 8< --
 static void submit_source (const char *type_instance, counter_t value)
 {
   value_t values[1];
   value_list_t vl = VALUE_LIST_INIT;

   values[0].counter = value;

   vl.values = values;
   vl.values_len = 1;
   vl.time = time (NULL);
   sstrncpy (vl.host, hostname_g, sizeof (vl.host));
   sstrncpy (vl.plugin, "dns", sizeof (vl.plugin));
   sstrncpy (vl.type, "dns_source", sizeof (vl.type));
   sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance));

   plugin_dispatch_values (&vl);
 } /* void submit_sources */
-- >8 -- src/dns.c -- >8 --

The reason is, that someone might come up with another clever way of
classifying sources of DNS traffic, so that `local' and `remote' isn't
sufficient anymore.

Regards,
-octo
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080926/d32fd941/attachment.pgp 


More information about the collectd mailing list