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:

#!/bin/bash

#  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 ]
then
        echo " Useage:$0 host "
                exit
fi

        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
HOST1

Unable to retrieve computer information for 'jlb18.circus.org'. Access is
denied.

HOSTIII

Unable to retrieve computer information for 'jlbIII.circus.org'. Access is
denied.

HOST4

Unable to retrieve computer information for 'jlb4.circus.org'. 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 >ng.in

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

prompt> cat ng.in
HOST1
HOSTIII
HOST4

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:

WordPress.com Logo

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

Facebook photo

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

Connecting to %s