Capturing database system snapshot information to a file using the SNAP_WRITE_FILE stored procedure
With the SNAP_WRITE_FILE stored procedure you can capture snapshots of monitor data and save this information to files on the database server and allow access to the data by users who do not have SYSADM, SYSCTRL, SYSMAINT, or SYSMON authority.
Any user can then issue a query with a snapshot table function to access the snapshot information in these files. In providing open access to snapshot monitor data, sensitive information (such as the list of connected users and the SQL statements they have submitted to the database) is available to all users who have the execution privilege for the snapshot table functions. The privilege to execute the snapshot table functions is granted to PUBLIC by default. (Note, however, that no actual data from tables or user passwords can be exposed using the snapshot monitor table functions.)Important: The SYSPROC.SNAP_WRITE_FILE procedure is deprecated and
might be removed in a future release. For more information, see SNAP_WRITE_FILE procedure.
Before you begin
About this task
Snapshot table function | Snapshot request type |
---|---|
SNAP_GET_AGENT | APPL_ALL |
SNAP_GET_AGENT_MEMORY_POOL | APPL_ALL |
SNAP_GET_APPL | APPL_ALL |
SNAP_GET_APPL_INFO | APPL_ALL |
SNAP_GET_STMT | APPL_ALL |
SNAP_GET_SUBSECTION | APPL_ALL |
SNAP_GET_BP_PART | BUFFERPOOLS_ALL |
SNAP_GET_BP | BUFFERPOOLS_ALL |
SNAP_GET_DB | DBASE_ALL |
SNAP_GET_DETAILLOG | DBASE_ALL |
SNAP_GET_DB_MEMORY_POOL | DBASE_ALL |
SNAP_GET_HADR | DBASE_ALL |
SNAP_GET_STORAGE_PATHS | DBASE_ALL |
SNAP_GET_DBM | DB2 |
SNAP_GET_DBM_MEMORY_POOL | DB2 |
SNAP_GET_FCM | DB2 |
SNAP_GET_FCM_PART | DB2 |
SNAP_GET_SWITCHES | DB2 |
SNAP_GET_DYN_SQL | DYNAMIC_SQL |
SNAP_GET_LOCK | DBASE_LOCKS |
SNAP_GET_LOCKWAIT | APPL_ALL |
SNAP_GET_TAB | DBASE_TABLES |
SNAP_GET_TAB_REORG | DBASE_TABLES |
SNAP_GET_TBSP | DBASE_TABLESPACES |
SNAP_GET_TBSP_PART | DBASE_TABLESPACES |
SNAP_GET_CONTAINER | DBASE_TABLESPACES |
SNAP_GET_UTIL | DB2 |
SNAP_GET_UTIL_PROGRESS | DB2 |
Procedure
Results
Note: While this provides a means to limit user
access to sensitive monitor data, this approach does have some limitations:
- The snapshot monitor data available from the SNAP_WRITE_FILE files is only as recent as the last time the SNAP_WRITE_FILE stored procedure was called. You can ensure that recent snapshot monitor data is available by making calls to the SNAP_WRITE_FILE stored procedure at regular intervals. For instance, on UNIX systems you can set a cron job to do this.
- Users issuing queries with the snapshot table functions cannot identify a database or partition to monitor. The database name and partition number identified by the user issuing the SNAP_WRITE_FILE calls determine the contents of the files accessible by the snapshot table functions.
- If a user issues an SQL query containing a snapshot table function for which a corresponding SNAP_WRITE_FILE request type has not been run, a direct snapshot is attempted for the currently connected database and partition. This operation is successful only if the user has SYSADM, SYSCTRL, SYSMAINT, or SYSMON authority.