If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > more script help

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-16-11, 17:37
db2girl db2girl is online now
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,830
more script help

This should be very easy for people on this forum.


Example from the attached report:

Index Root Page = 2
Node Type = Leaf Node / Large RID
Page State = x(41000204)

Tree Level = 1
Previous Node = Start of Chain
Next Node = Page 4
Total Free Space = 966
Maximum Free Space = 3500
Free Space Offset = 3130
Reserved Space = 0
Slot count = 250



What I want to do is to extract the lines that contain:

Node Type = Leaf Node / Large RID
followed by
Total Free Space = xxxx (that belongs to this 'Node Type')

but only if 'Total Free Space' != 0


I used:
more TEST.RPT | egrep "Leaf Node / Large RID|Total Free Space"


It gives me more than what I need, it also includes lines with:

Node Type = Last Leaf Node / Large RID
Node Type = Last Leaf Node / Large RID / Info Page


And I'm not sure how to exclude the lines (both 'Node Type = Leaf Node / Large RID' and 'Total Free Space = 0) when 'Total Free Space' !=0


Can you please help me.


Thanks
Attached Files
File Type: txt TEST.RPT.txt (3.68 MB, 45 views)
Reply With Quote
  #2 (permalink)  
Old 08-16-11, 20:33
db2girl db2girl is online now
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,830
I can exclude lines with 'Total Free Space = 0' using [ awk '^/Total Free Space = 0/' ]

Still looking for a way to exclude 'Node Type = ...' when 'Total Free Space = !0'
Reply With Quote
  #3 (permalink)  
Old 08-16-11, 23:40
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Code:
#!/usr/bin/bash                                                        
IFS="="                                                                
while read a b                                                         
do                                                                     
if [ "a$a" = "a                         Node Type " ]                  
then                                                                   
        savea=$a                                                       
        saveb=$b                                                       
fi                                                                     
if [ "a$a" = "a                  Total Free Space " ]                  
then                                                                   
        if [ "a$b" != "a 0" ]                                          
        then                                                           
            if [ "a$saveb" != "a Last Leaf Node / Large RID / Info Page" ] 
               then                                                           
               echo $savea\=$saveb                                            
               echo $a\=$b  
             fi                                                             
        fi                                                             
fi                                                                     
done<TEST.RPT
If your TEST.RPT-1 file contains carriage returns, first use:
Code:
tr -d "\r" <TEST.RPT-1 >TEST.RPT
to convert to unix line endings.
Reply With Quote
  #4 (permalink)  
Old 08-17-11, 09:27
db2girl db2girl is online now
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,830
Works great, as always! Thank you.


Is it possible to do the following:


For each 'Node Type = Leaf Node / Large RID' and 'Node Type = Last Leaf Node / Large RID' where 'Total Free Space' != 0 , display

Index Object page
Node Type
Total Free Space
Value (range of values stored on this 'Index Object page)



Example from the attached report:

Index Object page: 3
BPS pool page : 131
BPS object page : 3

... skipping

Index Root Page = 2
Node Type = Leaf Node / Large RID
Page State = x(41000204)

Tree Level = 1
Previous Node = Start of Chain
Next Node = Page 4
Total Free Space = 966
Maximum Free Space = 3500
Free Space Offset = 3130
Reserved Space = 0
Slot count = 250

... skipping

Index Key Records:

Key 0:

Offset Location = 596 (x254)
Record Length = 14 (xE)

Key Part 1:
Long Integer
Value = 1
Hex Format = 00000001

... skipping

Key 180:

Offset Location = 3116 (xC2C)
Record Length = 14 (xE)

Key Part 1:
Long Integer
Value = 181
Hex Format = 000000B5




To display:

Index Object page: 3
Node Type = Leaf Node / Large RID
Total Free Space = 966
Value = 1
Value = 181


And repeat the same for all 'Node Type = Leaf Node / Large RID' and 'Node Type = Last Leaf Node / Large RID' where 'Total Free Space' != 0
With the last one being:


Index Object page: 56
Node Type = Last Leaf Node / Large RID
Total Free Space = 2170
Value = 9906
Value = 10000



I think I'm asking for too much here... maybe just the 'Value' range and 'Total Free Space'?


Thanks.
Reply With Quote
  #5 (permalink)  
Old 08-17-11, 17:08
kitaman kitaman is offline
Papabi's friend
 
Join Date: Sep 2009
Location: Ontario
Posts: 629
Do all of the additional lines occur before the "Total free space" line? And if not, what line constitutes an end of incidence?
Better yet, if you intend to use the data as input to something else, what should that look like?

Last edited by kitaman; 08-17-11 at 17:18.
Reply With Quote
  #6 (permalink)  
Old 08-17-11, 20:30
db2girl db2girl is online now
∞∞∞∞∞∞
 
Join Date: Aug 2008
Location: Toronto, Canada
Posts: 1,830
Some lines occur before the "Total free space" line and some after. And I don't intend to use the data as input to something else.


This report is broken down into several sections separated by the following line:

______________________________________



The only sections I'm interested in are those with:
Node Type = Leaf Node / Large RID and
Node Type = Last Leaf Node / Large RID



From each section, I'd like to extract the following info:
Index Object page
Node Type
Total Free Space
Value = <lowest key value>
Value = <highest key value>


The value range is the difficult part, I think, because I'm only interested in the lowest and highest value stored on each 'Index Object page'.



Executing -> cat TEST.RPT | egrep "Index Object page|Node Type|Total Free Space|Value"

gives me what I need except it dispays some info I prefer not to see such as:



- I don't need to see this info because 'Node Type = Root/Leaf Node' or 'Node Type = Root Node / Large RID':

---------------------------
Index Object page: 0
Index Object page: 1
Node Type = Root/Leaf Node
Total Free Space = 3289
Value = 0
Value = 1
Index Object page: 2
Node Type = Root Node / Large RID
Total Free Space = 2513
Value = 181
Value = 368
Value = 555
...
Value = 9905

-----------------------------




- Instead of seeing this:
----------------------------
Index Object page: 3
Node Type = Leaf Node / Large RID
Total Free Space = 966
Value = 1
Value = 2
Value = 3
.... skipped some values
Value = 181

----------------------------


I prefer to see (just the range of values - low and high):
----------------------------
Index Object page: 3
Node Type = Leaf Node / Large RID
Total Free Space = 966
Value = 1
Value = 181

----------------------------


The same goes for all sections with 'Node Type = Leaf Node / Large RID' and 'Node Type = Last Leaf Node / Large RID' where 'Total Free Space' != 0



Please don't spend too much time on it. My customer asked me if I can help him write a script to extract this info and this is not really my job to do it.


Thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On