[baylisa] Re: wtf: hostid gives '0' as a hostid

Ray Wong rayw at rayw.net
Sun Feb 17 03:53:31 PST 2008



So, getting back to your actual requirements, the point is that you want to
be able to uniquely identify machines for an automated process.  Would that
be a fair statement?

This implies you have some sort of automated management system intended.
Something like CFengine handles all that, but supposing you want to have
some sort of parallel system in place that can scale with a specific unique
identifier.

As discussed, hostid will always return a value, and it's one that can't
by default be expected unique and that you wouldn't want to arbitrarily
be changing all the time.

Taking a look at Sam'l's idea of simply creating your own ID file (let's
call it /etc/site/myID since we're about to change it from his idea), he
readily acknowledge 2 obvious limits, that of being done manually, and
concommitantly, lack of scalability.

The obvious merging of these 2 is to create a tool that can automatically
create /etc/site/myID, and a mechanism to notice when it's not there yet.

Let's refer to the tool as /usr/local/sbin/createmyID.  It's likely just
going to be a shell script that creates some random string and checks some
central registry (say, a mysql DB table with the ID as the primary key)
for uniqueness there, then saves it to said registry and /etc/site/myID.
(Note that of using a DB and primary key, success in doing an INSERT would
combine the first 2 steps, leaving the write to the file dependent.

Then all you need to do is ensure it gets called once for each host, and
only once.  In pseudo-cfengine terms:

groups: have_unique_id = ( FileExists(/etc/site/myID))

copy: ${masterfiles}/inputs/usr/local/sbin/makemyID dest=/usr/local/sbin/makemyID server=${server} mode=755 type=checksum

!have_unique_id::
     create_id

shellcommands:
     create_id::
          "/usr/local/sbin/createmyID"

Simple enough to manage it running once per host, and creates the ability
for any subsequent task to simply use the grab /etc/site/myID and use that
to decide if it's processed the task for that host or not.




On Sat, Feb 16, 2008 at 10:00:02AM -0800, David Alban wrote:
> On Feb 14, 2008 9:29 PM, Rick Moen <rick at linuxmafia.com> wrote:
> > I know of no implications of the hostid value for networking.  Maybe I'm
> > wrong about this (you tell me), but I get the somewhat fuzzy impression
> > that its main use is in licensing managers for proprietary *ix software.
> 
> having a unique id for each host means that i can with confidence know
> that i've processed a particular host in a set of hosts.  say i have
> host foo.bar.bat.  say it has two ip addresses.  say there are two
> additional cnames that point to it.  say i have a config file for a
> program that allows a user to specify a hostname or ip address for a
> host.  and that any host may appear multiple times in the config file.
> 
> say it's very important that the host get processed only once, for
> some reason.  if there are tasks in the config file for:
> 
>   foo
>   foo.bar
>   foo.bar.bat
>   addl_cname_01.bar.bat
>   addl_cname_02.bar.bat
>   10.1.2.3
>   10.2.3.4
> 
> which are all references to the host foo.bar.bat, then i the only way
> i know to collect all the tasks for foo.bar.bat is for the program to
> connect to each of these "host handles" and get the hostid.  then it
> can create sets of tasks for each host based on hostid, and all of the
> tasks identified by the hostnames / ip addresses above will become a
> single set.
> 
> i suppose i could use hostname instead of hostid, but now that i know
> on what hostid is based, it makes even more sense to use it (or
> something similar).  it's possible someone could mess up hostnames
> and/or dns.  but if a host can be reached via the network, it's hostid
> should be a unique identifier.
> 
> so the value for me is not with regard to networking per se, but truly
> one of determining the uniqueness of a machine, despite the many "host
> handles" we can use to get to that machine.
> 
> p.s.  i'm starting to think that maybe a mac address on a host might
> be better yet than the output of hostid...
> 
> -- 
> Live in a world of your own, but always welcome visitors.



More information about the Baylisa mailing list