[collectd] [PATCH] UUID plugin for collectd

Florian Forster octo at verplant.org
Mon Nov 5 20:25:38 CET 2007


Hi Rich ;)

On Mon, Nov 05, 2007 at 05:03:40PM +0000, Richard W.M. Jones wrote:
> What it does is, if the plugin is loaded, it changes the global
> hostname_g to be the machine's UUID, where the UUID is a (supposedly)
> unique identifier for the machine.

Wow, I never would have thought of this ;)

> However this is most often useful for virtual guests, where we have a
> concept of a UUID that refers to the guest for all time, even if the
> guest is shutdown or migrated to another physical host.

Just out of curiosity: Why don't hostnames work for you?

> The plugin uses a variety of different methods to try to find the
> UUID.

Could you please document these methods and the available configuration
options in `src/collectd.conf.pod'? The it's in the ``plain old
documentation'' format (used by Perl, see perlpod(1)) - the manpages are
generated from this.

> I don't really know whether updating hostname_g directly is a good
> idea. No other plugins do it, but on the other hand it does seem to
> work.

As long as you're doing this in the `init' hook (which is the case ;) it
shouldn't be a problem.

Your patch looks fine as far as I've seen it. These lines should be
hardened though:
-- 8< --
  /* from */
  strncpy (hostname_g, uuid, DATA_MAX_NAME_LEN);                                                                                                            
  free (uuid);                                                                                                                                              
--
  /* to */
  strncpy (hostname_g, uuid, sizeof (hostname_g));
  hostname_g[sizeof (hostname_g) - 1] = '\0';
  sfree (uuid);
-- >8 --
(I rather have an useless instruction in there than wondering if `uuid'
is short enough in any possible case in two years time..)

Regards,
-octo
-- 
Florian octo Forster
Hacker in training
GnuPG: 0x91523C3D
http://verplant.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2567 bytes
Desc: not available
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20071105/9c09fbc0/attachment.bin 


More information about the collectd mailing list