In article <3b*************@individual.net>,
Civilian_Target <ta****@bigfoot.com> wrote:
Is there any way in DB2 to automate the taking of a snapshot, for
example, a function that will cause a db2 snapshot to be taken every 5
minutes and written to a uniquely named file?
Snapshots are taken with the administrative API; the DB2 CLP uses the
administrative API to get snapshot data and then displays it in textual
format.
At work, I have written a perl XS module (XS is the perl-to-C API) that
invokes the Admin API to collect snapshot data every minute and stores
it (we keep 2 hours); this is used to drive performance monitoring,
troubleshooting, etc. (Not open sourced - I'm working on that.)
If you're comfortable with C, look at the IBM-supplied samples - they
are quite nice and show how to get snapshot data, parse and display it,
etc.
What I like most about the admin API is that you can get snapshot data
for multiple areas at the same time, e.g. a snapshot for both the
instance, all active databases, and the tablespaces, all in one chunk of
data. Also, getting a snapshot and then analyzing it in
your own code is less expensive for the database than using the snapshot
SQL functions and cheaper in terms of CPU time than running the DB2 CLP
and then parsing the output.