Db2 for z/OS can record who did what to the data: failed authorizations, grants and revokes, objects created, altered and dropped, tables read and changed, utilities run and administrative authority used. The audit trace writes all of it to SMF, and that is where most of it stays, because turning SMF records into answers takes a trace setup, a formatting job and a report that someone has to read. TUC closes that gap. It starts and manages the audit trace and its policies from the dialog, collects and analyzes the formatted reports, and shows every audited event in the same events list as the utility history of the object. It also searches the Db2 log with DSN1LOGP and adds the units of recovery it finds to the same list. Who did it, what it changed and where to recover to are then answered in one place.
Key Benefits
Traces From the Dialog — Audit traces are started, modified and stopped from an integrated dialog, with their classes, constraints and destination chosen on screen.
Audit Policies Managed — Db2 audit policies are defined, updated and selected in the same dialog, so auditing is set up centrally without altering a single table.
Reports Collected and Analyzed — The audit records are formatted by Db2's own utility, and TUC analyzes the reports and loads every event for review.
One History per Object — Audited events appear in the events list beside the utility events and the logged changes of the object, on one timeline.
Every Detail at Hand — Each event shows who, from where and with which program, and the original report can be browsed from the event.
Log Analysis Built In — The Db2 log is searched with DSN1LOGP for a period and an object, and every unit of recovery found is added to the history of the objects it changed.
From Event to Recovery — Audited changes and units of recovery carry their log points, and consistent points around them are found without a QUIESCE, so a recovery can be generated or ordered from the list.
Why Db2 Audit Data Goes Unused
The audit trace is part of Db2, yet at many sites it is either switched off or written to SMF and never read. Starting it correctly is the first obstacle: some audit classes record table access only for tables defined with an audit attribute, so without care the trace misses exactly the tables that matter. Audit policies solve that, but they are defined in a catalog table and started with their own commands, which few people use every day.
Reading the records is the second obstacle. Db2 supplies a utility that formats them into reports, one report per kind of event, long and hard to relate to a particular table. When a question comes up, such as who changed this table last night or who dropped that index, the answer is buried in SMF, in a report that has not been produced, for a period that may already be gone.
Starting Traces and Defining Policies
TUC provides a trace dialog for all Db2 traces, not only audit. It lists the active traces, shows the output of the display command, and lets a trace be started, started again like an existing one, modified or stopped. When a trace is started, its classes, the individual records within each class, and the constraints that limit it to certain activity can be chosen from lists, and the destination and scope are set before the trace starts.
For audit traces, the same dialog manages Db2 audit policies. The defined policies are listed with the categories each one audits, and the policies to activate are selected for the start command. Policies can be inserted, updated and deleted on the spot:
- What is audited. Each policy names the categories it activates: authorization failures, authorization changes, the creation, alteration and dropping of tables, data access and changes, utilities, grants and revokes, administrative authority and database administration.
- Where it applies. A policy is limited to a database, a collection, a schema or a table, so auditing can be focused on the data that needs it.
- When it starts. A policy can be set to start automatically when Db2 starts, so auditing survives a restart.
Because policies can audit tables that were never defined with an audit attribute, auditing is switched on and managed centrally, without any change to the objects being monitored. Where table-level auditing is preferred instead, TUC can also generate the statements that add the audit attribute to the tables that lack it.
Collecting and Analyzing the Audit Records
A collection job gathers the audit records from SMF and formats them with Db2's own reporting utility, so the content is exactly what Db2 recorded. When Db2 compresses its SMF records, the job decompresses them first. TUC then analyzes the formatted reports and loads every audited event, with its object, its time and its context, into its own tables, where they can be searched and displayed.
The collection runs as part of the daily cycle. The loaded events can be replaced at each run, or accumulated from run to run to keep a longer history online.
Audited Events in the Events List
For any tablespace or indexspace, TUC's events list shows its complete history on one timeline, from three sources:
- Utility events. Copies, REORGs, loads, recoveries and every other utility recorded by Db2.
- Audited events. The events collected from the audit trace: who accessed or changed the object, who altered or dropped it, which authorizations failed.
- Logged events. The units of recovery found by analyzing the Db2 log, as described below.
The list can be narrowed to a time range, to particular jobs or to particular users, and the kinds of audited events shown can be chosen from the audit classes. Opening an audited event shows its details: the table, the time, the user, the plan, the correlation and connection identifiers, the location, the collection and the package, and, when the event changed data, the log point of the change. The original report produced by Db2 can be browsed from the same window, so the evidence is never more than one step away.
Questions that used to need an SMF extract and a report run are answered from the list: who changed this table yesterday afternoon, which job dropped that object, which user failed to read the payroll tables.
Log Analysis With DSN1LOGP
The audit trace says who touched the data. The Db2 log says exactly what was changed and when each change began and ended. TUC uses Db2's own log print utility, DSN1LOGP, to read it.
The available active and archive logs are listed with the period each one covers, so it is clear how far back the log still reaches. A log search is defined by a start and end time and, when needed, by a database or an object, and TUC generates the job that runs DSN1LOGP against every log in the range. The summary it produces is analyzed, and each unit of recovery found is loaded as a logged event of the objects it changed.
Opening a logged event shows the unit of recovery or the logical unit of work: its identifier, the connection, the job, the authorization ID and the plan, with its start and end log points, their times and its duration. Every object the unit of recovery changed can be listed from the event, so the full reach of a program that made a bad change is visible at once, not only the table where it was noticed.
From an Event to a Recovery
An audited change and a unit of recovery are more than evidence. Each carries a log point, and each is a precise point in time to recover to. From the events list, a recovery of the object to the point of the event, or to the start or end of a unit of recovery, can be generated for immediate execution or placed as an order, so it runs under TUC control like any other utility. All the objects touched by a unit of recovery can be recovered together.
Quiet Points Instead of QUIESCE
Recovering to a point in time is safe only at a point of consistency, a point on the log where no change to the data was in progress. Traditionally that point is created in advance with QUIESCE, which waits for running updates to finish and briefly holds back new ones so that it can record a clean log point. It disturbs the applications, so it is taken rarely, and when something goes wrong the nearest QUIESCE is often hours away from the moment that matters.
The log already contains the answer. Every change is made inside a unit of recovery with a known start and end, and between one unit of recovery and the next there is often a gap in which nothing touched the data. Any point in such a gap is as consistent as a QUIESCE, and it costs nothing, because it was never taken.
TUC finds these gaps from the units of recovery it loaded from the log. A program rarely changes a single table, so the gap has to be quiet for all of them. For the selected event, TUC takes every object that its unit of recovery or logical unit of work changed, and finds the nearest quiet point before the event and the nearest one after it. Recovering to the first removes the change; recovering to the second keeps it as the last change. The point found is consistent across the whole set of related tables, not just the one where the problem was noticed. Quiet points are found for units of recovery and for logical units of work, with or without data sharing, and can be used directly in the recovery.
When a recovery is requested from the event, the candidate points are presented together, in log order: the start and end of the event itself, the last QUIESCE before it and the first one after it, and the quiet points before and after it. The quiet points are marked as points of consistency. Choosing one sets the log point of the recovery, and every object the unit of recovery changed can be recovered to it together. When the table shares its tablespace with other tables, TUC warns before a point-in-time recovery, because those tables would be taken back too.
The result is a recovery to a consistent moment right before the event or right after it, found after the fact, without a QUIESCE ever having been taken and without holding up a single application.
The path from the question to the repair becomes short: the audit shows who did it, the log shows what was changed and where it is safe to go back to, and the recovery is generated from the same list.
Without and With TUC
| Task | Without TUC | With TUC |
| Starting an audit trace | Commands issued with the right classes and qualifiers. | Classes, constraints and destination chosen in the trace dialog. |
| Audit policies | Rows maintained in a catalog table. | Listed, defined and selected in the same dialog. |
| Auditing tables without an audit attribute | Alter every table. | Policies audit them centrally; the alter statements can be generated where wanted. |
| Reading SMF audit records | A formatting job and long reports. | Collected daily, analyzed and loaded for review. |
| Who did what to this table | Read through the reports. | The object's events list, filtered by time, job or user. |
| What a bad program changed | Print the log and read the summary. | Units of recovery loaded into the history, with every object they changed. |
| A consistent point to recover to | A QUIESCE that was taken in advance, or none. | Quiet points found in the log across every object the unit of work changed. |
| Recovering from a bad change | Find the log point, then build the job. | Recovery to the event or unit of recovery generated or ordered from the list. |
In short — TUC turns the Db2 audit trace and the Db2 log into working tools. Traces and audit policies are managed from one dialog, the audit records are collected and analyzed every day, and the log is searched with DSN1LOGP for the units of recovery that changed the data. Audited events and logged changes appear in the history of each object, with the user, the program and the original report one step away. When a change turns out to be a mistake, the recovery to a consistent point around it is generated from the same list, without a QUIESCE taken in advance.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article