Output in table


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output in table
# 1  
Old 12-23-2014
Output in table

Hi,

I have a script which gives output as below:

We want to extract the output which will contain only PoolManager and Total number of connections, and if possible in a table with two columns having PoolManager and Total number of connections

Code:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PoolManager name:jdbc/AntalisUK.XA
PoolManager object:1945596919
Total number of connections: 1 (max/min 10/1, reap/unused/aged 180/1800/0, connectiontimeout/purge 180/EntirePool)
                               (testConnection/inteval false/0, stuck timer/time/threshold 0/0/0, surge time/connections 0/-1)
Shared Connection information (shared partitions 200)
  No shared connections
Free Connection information (free distribution table/partitions 5/1)
  (0)(0)MCWrapper id 2d062d06  Managed connection WSRdbManagedConnectionImpl@6e056e05  State:STATE_ACTIVE_FREE
  Total number of connection in free pool: 1
UnShared Connection information
  No unshared connections
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PoolManager name:jdbc/AntalisDE.XA
PoolManager object:769469917
Total number of connections: 0 (max/min 10/1, reap/unused/aged 180/1800/0, connectiontimeout/purge 180/EntirePool)
                               (testConnection/inteval false/0, stuck timer/time/threshold 0/0/0, surge time/connections 0/-1)
Shared Connection information (shared partitions 200)
  No shared connections
Free Connection information (free distribution table/partitions 5/1)
  No free connections
UnShared Connection information
  No unshared connections
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Your help is highly appreciated.

Thanks,
Saurau

Last edited by Scrutinizer; 12-23-2014 at 06:03 AM.. Reason: code tags
# 2  
Old 12-23-2014
This might do what you want:
Code:
awk -F: 'NR==1                  {print HD
                                 HDCnt=split(HD, HDArr)
                                 HDCM=FS HD FS
                                 NXTREC="^=-=-=-"
                                }


         $1 ~ NXTREC && PR      {printf "%s", RES[HDArr[1]]
                                 for (i=2; i<=HDCnt; i++) printf "%s%s", FS, RES[HDArr[i]]
                                 printf "\n"
                                 delete RES
                                }
         $1 ~ NXTREC            {PR=1}

         HDCM ~ FS $1 FS        {sub (/\(.*$/, "", $2); RES[$1]=$2}


         END                    {printf "%s", RES[HDArr[1]]
                                 for (i=1; i<=HDCnt; i++) printf "%s%s", FS, RES[HDArr[i]]
                                 printf "\n"
                                }
        ' HD="PoolManager name:Total number of connections" file
PoolManager name:Total number of connections
jdbc/AntalisUK.XA: 1 
jdbc/AntalisDE.XA: 0 
::

I've used ":" as the input and output record saparator here; adapt it if need be. If you can make sure there's always a record separator "=-=-=-..." in the end, you can drop the END section.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 12-23-2014
Code:
$ awk -F':' '/PoolManager name/{ nm=$2 } /Total number of connections/ { sub(".max.*",X,$2); print nm $2 } ' file
jdbc/AntalisUK.XA 1
jdbc/AntalisDE.XA 0

This User Gave Thanks to anbu23 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell output format like table

Hi, OS: Redhat 7.5 shell: Bash Wrote below script to login into oracle via shell script and trying to reset locked account..It works as expected. But I need specific output << EOF should go to target terminal not all out put running below script from ansible command line.. #!/bin/bash... (1 Reply)
Discussion started by: onenessboy
1 Replies

2. Shell Programming and Scripting

Need the output in the mentioned Table format

Hi Friends, I have the script output like below: Script Output: ----------------------------------------------------------------------- Details of the Client: ----------------------- name: server1; save set: All; ... (3 Replies)
Discussion started by: akmani
3 Replies

3. Solaris

SQL QUERY to Table Output

Hi I am trying to run sql query from solaris in csh script and send the output to email. Below is my sql query select p.spid,se.program seprogram, se.machine, se.username, sq.sql_text,sq.retrows from v$process p inner join v$session se on p.addr = se.paddr inner join ( select... (2 Replies)
Discussion started by: tharmendran
2 Replies

4. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

5. Shell Programming and Scripting

Output in table format

I have one script which generate file called report.txt having following output parameter_name status comment banking ok NA finance 30% hike NA Loan_department ok 20% HR_Group defaulters Ajay I wanted to convert this file into tabular form. You can see each line contain 3 words and... (7 Replies)
Discussion started by: Nakul_sh
7 Replies

6. Shell Programming and Scripting

Excel table like output with printf

Hi All; I try to create a excel like table with headers and some fields containing values, other long and complex mathematic formulas. I have some header like : Name Formula Value True/False Under name column, they are some formula names, formula column some long mathematic formulas... (9 Replies)
Discussion started by: reseki
9 Replies

7. Shell Programming and Scripting

convert the output in table format

Hi All, I have a output like below values val1=test.com val2=10.26.208.11 val3=en1 val4=test-priv1.com val5=192.168.3.4 val6=en2 val7=test-priv2.com val8=192.168.4.4 val9=en3 val10=test-vip.com val11=10.26.208.9 val12=$val3 I want to convet this output values into below... (1 Reply)
Discussion started by: kamauv234
1 Replies

8. Shell Programming and Scripting

Script for a syntax output for a table.

Hello Unix Gurus, I need a few instuructions how to approach the following scenarios.For a given TABLENAME a script should display the following structure on the screen.The structure should be as below.for a given perticular table. SELECT *FROM TAB1 a JOIN TAB1 b ON ... (0 Replies)
Discussion started by: kanakaraju
0 Replies

9. Shell Programming and Scripting

to create an output file as a table

Hi, I have four input files and would like to create an output file as a table. Please check the example below. File 1. 111111 222222 333333 444444 File 2. 555555 666666 777777 888888 File 3. aaaaa bbbbb ccccc ddddd (2 Replies)
Discussion started by: marcelus
2 Replies

10. Shell Programming and Scripting

displaying output in a table.

Hello, I've just finished my first script (about displaying open ports on the computer and who opened them) and everything is fine with it but I want to style it a little bit just for the sake of learning how to do this. What I want to do is make the display like the one of ps, for example,... (6 Replies)
Discussion started by: sanchopansa
6 Replies
Login or Register to Ask a Question