Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,369

    Unanswered: 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 Attached Files

  2. #2
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,369
    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'

  3. #3
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    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.

  4. #4
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,369
    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.

  5. #5
    Join Date
    Sep 2009
    Location
    Ontario
    Posts
    1,057
    Provided Answers: 1
    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 18:18.

  6. #6
    Join Date
    Aug 2008
    Location
    Toronto, Canada
    Posts
    2,369
    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

Posting Permissions

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