[collectd] patch for email stats from postfix and amavisd-new, dns stats from powerdns
Florian Forster
octo at verplant.org
Thu Nov 29 09:05:32 CET 2007
Hi Luke :)
thanks for your modifications, I hope to have some time to take a look
at it later today.
One small thing jumped to my eye though: You define
static const unsigned int primes[] = {
53,101,211,401,809,1601,3203,6421,12809,25601,51203,102407,204803,409609,
..., 419430419
};
and later search the smallest of these numbers that's greater than an
argument (in a function called `calc_table_len').
1) Why primes? 2^k-1 I would have understood, basically anything that
has to with padding and avoiding extra bytes, but primes? What do
they have to do with it?
2) I doubt that anyone needs more than 419e6 entries in some table, but
why not make this dynamic? History has shown that limiting a list or
counter is problematic. Think Y2K-bug ;) I would have expected
something along these lines:
uint32_t bits = floor (log (min_size) / log (2.0)) + 1;
return (pow (2, bits) - 1);
Since your primes roughly double every step, too, it probably doesn't
make a big difference, but the primes here are very unexpected..
On Wed, Nov 28, 2007 at 07:43:32PM -0800, Luke Heberling wrote:
> It appears that when the plugin processing returns you close the file
> handle, save the position and re-open the file when the plugin is next
> called, attempting to seek back to the same position.
That's right. I was thinking about implementing a option to chose the
behavior, i. e. have the module behave like `tail -f' or `tail -F',
depending on which options are passed to the ``constructor''. I didn't
implement this because I thought that one could just simply open the
file in the plugin and keep the filedescriptor around for as long as
needed.
Maybe the right way to do this is to implement a method that returns
the data in lines, similar to fgets. This function could check if the
file was moved when it reads an end-of-file, open the new file and
return the first line of that file.
> Is file locking necessary? I wrote my tail code using as a guide
> tail.c from coreutils.
Probably not. First of all, this is only advisory locking, i. e. any
process not doing locking out of free will may still write to that part
of the file. Second, usually the logfiles are not changed except for
lines being appended. I think I'll change this to have an option to
activate/deactivate locking.
I'll propose a changed interface soon, so we can discuss the changes.
Hopefully I'll have time for this today..
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/20071129/b740fac9/attachment-0001.pgp
More information about the collectd
mailing list