tnsping is an Oracle tool that is sort of like a ping command. Unfortunately it does not come with a tool that can be used to parse its output which is very frustrating.
Example output of tnsping are as below:
At the moment, I re-direct the output of tnsping to a file and then grep -i for the the "Attempting to contact" line. which should give me the following output:
For clarity, I manually indented and posted these output to the forum as below:
Now come the big questions. Can anyone help me how to re-direct the output to an array and access it like an associative array?
For example, for the tnsping testd1 output, I want to be able to access address[host] and get testd1.mnl.ph.com or connect_data[sid] and get testd1.
For the tnsping testp1, it has two (2) address_list, so I will need to differentiate between the two (2) so that one is address_list_1 and the other is address_list_2. I want to be able to access address_list_1[host] and should get testp1prim.mnl.ph.com and address_list_2[host] and should give me testp1stdby.mnl.ph.com. Some tnsping output gives me as much as four (4) values.
I honestly don't know where to start except for doing the tnsping and redirect the output to a file and grep -i for the "Attempting to contact" string.
For a start, how do I count the number of times a string appears in a line? For example, I want to be able to check how many address_list there is from the tnsping output?
Not sure how to proceed from there. If any awk expert can help me parse the output into several parts that can be re-directed to a file, I will be more than satisfied with that instead of using an array.
For example, if using awk/nawk/gawk, how do I parse the string so that I get the following result:
I hope I've explained myself well. Sorry for a long post.
Any feedback/guidance will be much appreciated. Thanks in advance.
---------- Post updated at 12:50 AM ---------- Previous update was at 12:39 AM ----------
Hi
BTW, need to do this in KSH as the boxes only have KSH, no bash -
I have a file that contains the output of the ls -iR command, something like this:
./results:
2504641011 result_1410 2500957642 result_525
2504641012 result_1425 2500957643 result_540
./tests/1:
2500788755 1 2500788743 1000
./tests/2:
2500788759 3 2500788758 999
... (6 Replies)
I need to parse the following out put and determine if the USB is a DISK and whether or not it's External.
If an HBA line contains "USB" then does the next line contain
"DISK" and "External".
0:0,31,0: HBA : (aacraid,1) AAC SCSI
0,0,0: DISK : Adaptec ASR4800SAS Volu0001
... (6 Replies)
How to enable this command ?
Thanks.
---------- Post updated at 03:36 AM ---------- Previous update was at 03:34 AM ----------
I forgot to tell it is Unix server (3 Replies)
I'm trying to gather information on the interfaces on a large number of servers.
If I run ifconfig I will get: eth0 Link encap:Ethernet HWaddr 00:50:56:A2:27:C1
inet addr:10.145.xxx.xxx Bcast:10.152.45.255 Mask:255.255.254.0
-----
eth1 Link... (2 Replies)
Guys can you help me fix this parse error.
Here's my script.
#!/bin/bash
# Set up limit below
NOTIFY="6.0% us 6.1% us 6.2% us 6.3% us 6.5% us 6.6% us 6.7% us 6.8% us 6.9% us 7.0% us"
# CPU Usage every minute
TOP="$(top -b -n2 -d 00.20 |grep Cpu|tail -1 | awk -F ":" '{ print $2 }' | cut... (3 Replies)
Hi ,
i am trying to set up an alert, when CPU usage (0.2%us in below output) is more than 40%
top | head | grep '^Cpu'
Cpu(s): 0.2%us, 0.2%sy, 0.0%ni, 99.1%id, 0.6%wa, 0.0%hi, 0.0%si, 0.0%st
using CUT, i pulled the value 0.2 and assigned to CPU (variable)
CPU=$(expr `top | head -10... (5 Replies)
Hi all,
Can anyone help with the following request?
I need to extract HOST value, SERVICE_NAME and msec value from a tnsping output and append to a file. The tnsping output is typically as follows:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS =... (4 Replies)
Hello All,
I am using Linux OS. My idea is get the host name when we do tnsping in oracle.
output of : tnsping DOELO01
TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 15-OCT-2015 20:20:05
Copyright (c) 1997, 2011, Oracle. All rights reserved.
Used parameter files:... (2 Replies)
Hi,
I need some advise on how to print 'sections' of the attached file. I am searching for some that says Marked Corrupt and print some lines after it.
At the moment I am running the command below:
sed -n -e '/Marked Corrupt/{N;N;p;}' rman_list_validate.txtThis gives me the following... (1 Reply)