| |
|
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.
|
 |
|

07-24-09, 10:24
|
|
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.
|
|

07-24-09, 10:36
|
|
:-)
|
|
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
`
|
|

07-24-09, 11:09
|
|
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.
|
|

07-24-09, 12:25
|
|
:-)
|
|
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!"
|
|

07-24-09, 16:39
|
|
Registered User
|
|
Join Date: Oct 2004
Posts: 238
|
|
That cracked me up.............Forget the database size !!..........Thanks Nick.
|
|

07-24-09, 16:54
|
|
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
|
|

07-27-09, 11:24
|
|
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.
|
|

07-27-09, 11:26
|
|
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
|
|

07-27-09, 11:37
|
|
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.
|
|

07-27-09, 11:44
|
|
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
|
|

07-27-09, 11:47
|
|
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
|
|

07-27-09, 11:59
|
|
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 )
|
|

07-27-09, 12:07
|
|
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
|
|

07-27-09, 12:34
|
|
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
|
|

07-27-09, 12:50
|
|
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.
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|