Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    Oct 2004
    Posts
    268

    Unanswered: Database Size Monitoring

    RHLinux-DB2 V8.2.

    I am trying to setup a database and a table where I can monitor the database growth on a weekly/monthly bases on a production server. I want to run a query and insert the database size for individual databases into a table on weekly/monthly bases.

    The result of db2 "call get_dbsize_info(?,?,?,-1)" does not help since I can not insert it into a table. Also, we don't use federated server.

    Anyone has a query that will give me the database size I can insert it into a table on weekly/monthly bases ?

    Thanks.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Here's a shell script snippet that extracts the get_dbsize_info results as a single line of space-delimited fields. I'm sure you can derive an insert statement from that:
    Code:
    # run the stored proc and parse results
    OUTPUT=`db2 -tx +p <<EOF | perl -e 'undef $/;while (<>){my($t,$s,$c)=(/SNAPSHOTTIMESTAMP.+?: ([^\n]+).*DATABASESIZE.*?: ([^\n]+).*DATABASECAPACITY.*?: ([^\n]+)/s); print "$t $s $c\n";}'
    connect to $DB;
    call get_dbsize_info(?, ?, ?, -1);
    connect reset;
    quit;
    EOF
    `
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Oct 2004
    Posts
    268
    Thanks but it looks like it is using a pearl code which I am not familiar with. I don't think the server is setup to execute a pearl code either.

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by mioot
    db2 "call get_dbsize_info(?,?,?,0)"
    There was that joke about one prominent writer who, when asked about the book he admired the most, responded: "I don't read no stinkin' books. I'm a writer, not a reader!"
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Oct 2004
    Posts
    268
    That cracked me up.............Forget the database size !!..........Thanks Nick.

  6. #6
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    It is funny.

    MDX. You might try this

    db2 "call get_dbsize_info(?,?,?,-1)" | grep -i -p DATABASESIZE | cut -d: -f2

    that will give you just two lines. From there discard non numeric values and you are done.

    Sorry, I am not as humorous as Nick
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  7. #7
    Join Date
    Oct 2004
    Posts
    268
    Thanks Cougar,
    Although I make the same mistake once in a while (Answering to something without reading/knowing ALL the details) I found his example funny.

    I ran your statement and got the following.

    grep: invalid option -- p
    Usage: grep [OPTION]... PATTERN [FILE]...
    Try `grep --help' for more information.


    Thanks.

  8. #8
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    Looks like you might have had two dashes before p. Post your exact statement.

    It works for me

    db2 "call get_dbsize_info(?,?,?,-1)" | grep -i -p DATABASESIZE | cut -d: -f2


    DATABASESIZE
    4600775696384
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  9. #9
    Join Date
    Oct 2004
    Posts
    268
    No........I am copying it from your post. Double - is in the error message not in the command executed. Could it be the Linux/DB2 version

    Red Hat Enterprise Linux WS release 3 (Taroon Update 9)
    DB2 V.8.1 FP14.


    Thanks.

  10. #10
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    hmm, that I do not know. Create a dummy file and run grep command against it with with out "-p" then with it.

    Your dummy file should have more then 4 lines with two lines groups separated by the blank line. i.e.

    a
    b

    c
    d

    then run

    grep -i c filename ---> this should give you a one liner that would just show c

    then grep -i -c filename ---> this should give you a two liner that would show c and d
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  11. #11
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    it would have to do with unix vs db2 version
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  12. #12
    Join Date
    Oct 2004
    Posts
    268
    grep -i c filename ----> Gives me "c"

    grep -i -c filename ----> Server goes to freeze.


    db2 "call get_dbsize_info(?,?,?,-1)" | grep -i DATABASESIZE | cut -d: -f2 -----> (Without the -p Gives me only DATABASESIZE )

  13. #13
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    Sorry, second command should have had -p and not -c

    I wonder why your server went into a freeze mode with -c option. All it does is gives you the count, but that is for another time

    Try it again with -p on your file
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  14. #14
    Join Date
    Nov 2005
    Location
    IL
    Posts
    557
    You would still need to resolve the -p issue, but I have found a way to get you a single lie with just what you need

    db2 "call get_dbsize_info(?,?,?,-1)" | grep -i -p DATABASESIZE | grep [0-9] | cut -d: -f2

    4564020183040
    --
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows

    DB2 v9.7.0.6 os 6.1.0.0

  15. #15
    Join Date
    Oct 2004
    Posts
    268
    grep -i -p filename ----> Gives me the same below error. Your latest 1 line statement gives the same below error since it has the -p option........Thanks.

    grep: invalid option -- p
    Usage: grep [OPTION]... PATTERN [FILE]...
    Try `grep --help' for more information.

Posting Permissions

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