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 > Database Server Software > DB2 > Database Size Monitoring

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-24-09, 10:24
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
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.
Reply With Quote
  #2 (permalink)  
Old 07-24-09, 10:36
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
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
`
Reply With Quote
  #3 (permalink)  
Old 07-24-09, 11:09
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
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.
Reply With Quote
  #4 (permalink)  
Old 07-24-09, 12:25
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
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!"
Reply With Quote
  #5 (permalink)  
Old 07-24-09, 16:39
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
That cracked me up.............Forget the database size !!..........Thanks Nick.
Reply With Quote
  #6 (permalink)  
Old 07-24-09, 16:54
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
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.1.0.2 os 5.3.0.0
Reply With Quote
  #7 (permalink)  
Old 07-27-09, 11:24
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
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.
Reply With Quote
  #8 (permalink)  
Old 07-27-09, 11:26
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
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.1.0.2 os 5.3.0.0
Reply With Quote
  #9 (permalink)  
Old 07-27-09, 11:37
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
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.
Reply With Quote
  #10 (permalink)  
Old 07-27-09, 11:44
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
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.1.0.2 os 5.3.0.0
Reply With Quote
  #11 (permalink)  
Old 07-27-09, 11:47
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
it would have to do with unix vs db2 version
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #12 (permalink)  
Old 07-27-09, 11:59
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
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 )
Reply With Quote
  #13 (permalink)  
Old 07-27-09, 12:07
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
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.1.0.2 os 5.3.0.0
Reply With Quote
  #14 (permalink)  
Old 07-27-09, 12:34
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
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.1.0.2 os 5.3.0.0
Reply With Quote
  #15 (permalink)  
Old 07-27-09, 12:50
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
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.
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