Rounding Up Computers

Today I was given a list of computers that SMS could not contact, most likely the DNS setting was incorrect. So here are the scripts I used to diagnose the problem.

First I wrote a little script that looks for the computer name in our DNS directories, I called it ng, short for named grep, here it is:


#  2007-09-19 Jud Bishop
#  ng short for namedgrep.  Does a case insensitive
#  search for the hostname
#  supplied at the command line.

if [ -z $1 ]
        echo " Useage:$0 host "

        grep -i $1 /var/named/internal/*
        grep -i $1 /var/named/internal/172.25/*
# end script

Next I was given a file with the hostname and error, the file was in this format:

prompt> cat tmp.txt

Unable to retrieve computer information for ''. Access is


Unable to retrieve computer information for ''. Access is


Unable to retrieve computer information for ''. The network
path was not found.
/end tmp.txt

So I ran this little on liner on it to edit out just the hostnames, the sed
joins two lines, thus eliminating the blank ones, cheap hack but it works:

promtp> cat tmp.txt |sed  /^$/d |grep -v Unable >

Now I have a files of hostnames, one per line that I can send into ng.

prompt> cat

Finally I just ran this from the command line:

prompt> for I in `cat ng.txt`; do echo $I; ng $I; done >ng.out

And that was the first 20 minutes of work after reading my email this morning.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s