Help on a shell Script - Urgent!
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: Help on a shell Script - Urgent!

  1. #1
    Join Date
    Feb 2001
    Posts
    128

    Unhappy

    Hi,

    Objective - do a tnsping on all sid's and also do a nslookup on all the host names and store the results of the tnsping and nslookup which FAILED in a file. O/S Sun Solaris 5.8

    I need to capture all the sid names and host names from the tnsnames file(which is quite large) and I have to do a tnsping on all the sid's and a nslookup on all the host names to ensure there are no invalid entries.

    Could someone help me with a robust shell script.

    Sample Tnsnames entry
    ================
    test =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (PROTOCOL = TCP)
    (Host = xxxx.yyyy.com)
    (Port = 1521)
    )
    )
    (CONNECT_DATA =
    (SID = test)(server=dedicated)
    )
    )

    Thanks a bunch



  2. #2
    Join Date
    Aug 2000
    Location
    Belgium
    Posts
    342
    to select the names of the connect_string.

    We could assume that on the line where we put the connect-string, we don't have '('-characters.
    So we can have something like this

    for fname in $( grep -v "(" tnsnames.ora | awk '{ print $1 }' )
    do
    tnsping $fname
    .. continue with whatever you want to do.
    done

    Maybe you can use the output of the tnsping command to determine the hostname or IP-address of the connect-string you are testing. ( I would like to try, but don't have an oracle-system here )

    Hope this helps
    Gert


  3. #3
    Join Date
    Feb 2001
    Posts
    128
    thanks for your response, but
    I will have to do a tnsping on whatever is there in the SID =
    for example

    test =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (PROTOCOL = TCP)
    (Host = xxxx.yyyy.com)
    (Port = 1521)
    )
    )
    (CONNECT_DATA =
    (SID = test2)(server=dedicated)
    )
    )
    ##########
    dbtest =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS =
    (PROTOCOL = TCP)
    (Host = aaaa.bbbb.com)
    (Port = 1521)
    )
    )
    (CONNECT_DATA =
    (SID = testdb)(server=dedicated)
    )
    )
    ##########################

    In this case, I will have to do a tnsping on test2 and testdb
    and a nslookup on xxxx.yyyy.com and aaaa.bbbb.com

    I apprciate your help




  4. #4
    Join Date
    Jul 2001
    Location
    Minneapolis
    Posts
    15
    You could do something like...

    for f in `grep SID tnsnames.ora | awk -F= '{print $2}' | cut -d")" -f1`
    do
    tnsping $f | grep FAILED >> tnsping.log
    done

    And then do another for loop to do the nslookup on the hostnames. Just replace SID with HOST and tnsping with nslookup. Direct the results to a different logfile if necessary.

    However, this will only log the lines that say FAILED... not what failed. To do that, remove the | grep FAILED after tnsping $f. That will log all results to the file. You could then have another script that greps for FAILED ( or whatever for nslookup ) in the logfile. You could even set it up to have it page or email you that there was a failure so you can go check the log.

    Keep in mind, depending on how often you run this, you may need to purge your logfile once in awhile as it could grow quite large.

    Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width