[Samba] Better way to enumerate hosts in domain?

Jason Balicki kodak at frontierhomemortgage.com
Mon Nov 8 19:03:52 GMT 2004


I'm writing a script to pull some application logs off of
machines on my domain.

In order to enumerate the machines I'm just grepping through
wins.dat, but I suspect that there is a better way of acomplishing
my goal than that, possibly using the "net" command or nmblookup.

Right now I'm doing:

grep \#00 /var/cache/samba/wins.dat | cut -d " " -f 1 \
| cut -d \# -f 1 | cut -d \" -f 2  > $TEMPFILE

And this gives me a list of all hosts that have registered with
nmbd, including hosts connected via VPN, network printers, Samba
servers and other devices (which I don't need, but it's not
hurting anything -- I just have an ignore list built into the
script.)

I know there are near infinite ways of doing this, and I can
think of a lot of them off the top of my head, but I don't
know if one way is better than another for any reason.  I
chose using wins.dat over "net" because I was getting duplicates
with "net" -- but there may be a way to keep that from happening
that I don't know about.

So, if anyones got any suggestions, I'd be happy to hear them.
Most especially I'd like to hear if using wins.dat is a bad
idea for any reason.

TIA,

--J(K)

PS:  this script is for processing and reporting on anti-virus
logs.  The vendor has their own tools but I've found them
limiting, so I want to massage the raw data myself.



More information about the samba mailing list