IBM Db2 for i
Db2 for i is the database built into IBM i (formerly known as OS/400, AS/400 or iSeries). It is a separate platform from IBM Db2 for Linux, UNIX and Windows (LUW) and has its own Instance Type in DBmarlin. Support for Db2 for i was added in DBmarlin 6.11.0.
Pre-requisites​
Check the supported versions​
DBmarlin supports Db2 for i on IBM i 7.5 and 7.6. Please check the list of supported platforms before continuing and contact us if you are not sure.
The version shown in DBmarlin is the IBM i release, for example 7.5 for V7R5M0.
Network access​
DBmarlin connects to Db2 for i using the IBM Toolbox for Java (JTOpen) JDBC driver, which is included with DBmarlin, so nothing needs to be installed on the IBM i system.
The connection is made to the IBM i database host server, which listens on TCP port 8471 by default (9471 when TLS is used). This port must be open between the DBmarlin agent and the IBM i system, and the database host server must be running:
STRHOSTSVR SERVER(*DATABASE)
Create a monitoring user profile with the correct authority​
Before adding a target Db2 for i system in the UI you should first create a DBMARLIN user profile on the IBM i system (you can choose a name other than DBMARLIN if you prefer).
CRTUSRPRF USRPRF(DBMARLIN) PASSWORD(<password>) USRCLS(*USER) SPCAUT(*NONE) +
TEXT('DBmarlin monitoring user')
Then allow the user profile to use the QIBM_DB_SYSMON and QIBM_DB_SQLADM functions. These let it see the SQL running in other users' jobs and dump the plan cache for SQL statistics and execution plans, without granting it any special authority.
CHGFCNUSG FCNID(QIBM_DB_SYSMON) USER(DBMARLIN) USAGE(*ALLOWED)
CHGFCNUSG FCNID(QIBM_DB_SQLADM) USER(DBMARLIN) USAGE(*ALLOWED)
Authority needed for each feature​
| Feature | IBM i service | Authority needed |
|---|---|---|
| Activity (the SQL each job is running) | QSYS2.ACTIVE_JOB_INFO | QIBM_DB_SQLADM function usage (or QIBM_DB_SYSMON, or *JOBCTL) |
| SQL statistics and execution plans | QSYS2.DUMP_PLAN_CACHE | QIBM_DB_SQLADM function usage, or *JOBCTL |
| Blocking sessions | QSYS2.JOB_LOCK_INFO and QSYS2.RECORD_LOCK_INFO | *JOBCTL special authority |
| System statistics, version and system values | QSYS2.SYSTEM_STATUS_INFO, SYSIBMADM.ENV_SYS_INFO, QSYS2.SYSTEM_VALUE_INFO | None |
Without QIBM_DB_SQLADM function usage (or *JOBCTL), IBM i does not return the SQL text of other users' jobs, so DBmarlin sees almost no activity, and SQL statistics and execution plans are not available. The agent log will contain the message SQL statistics unavailable. The user needs QIBM_DB_SQLADM function usage or *JOBCTL.
Blocking sessions​
To find which job holds the lock that another user's job is waiting for, IBM i requires *JOBCTL special authority. QIBM_DB_SQLADM and QIBM_DB_SYSMON function usage are not enough. If you want to collect blocking sessions, give the user profile *JOBCTL:
CHGUSRPRF USRPRF(DBMARLIN) SPCAUT(*JOBCTL)
Keep the QIBM_DB_SQLADM and QIBM_DB_SYSMON function usage as well, as that is the combination we have tested. *JOBCTL also allows the user profile to hold, release, change and end other users' jobs, so only grant it if you need blocking sessions. Without it, jobs waiting for locks are still shown with the LCKW wait event and their SQL, but the blocking job is not identified and no error is logged. The only exception is jobs running under the same user profile as DBmarlin, whose blockers are always found.
IBM's documentation for QSYS2.RECORD_LOCK_INFO also lists *EXECUTE authority to the library and *OBJOPR and *READ authority to the locked file. In our testing these were not needed when the user profile had QIBM_DB_SQLADM and QIBM_DB_SYSMON function usage.
Adding the Database Target​
This is done through the User Interface using the Add Database screen. Choose Db2 for i as the Instance Type and enter the IBM i host name, port 8471, and the DBMARLIN user profile and password.
The default connection URL is jdbc:as400://<host>:<port>. Additional JTOpen JDBC properties can be added to the Connection string under Advanced mode. For example, to connect over TLS, add secure=true; and use port 9471. The IBM i certificate must be trusted by the Java runtime used by the DBmarlin agent.
What is collected​
DBmarlin samples the active jobs on the IBM i system that are running SQL, using the QSYS2.ACTIVE_JOB_INFO table function. Because Db2 for i is integrated into the operating system, some of the dimensions are shown with IBM i names.
| DBmarlin | Db2 for i |
|---|---|
| Session | The qualified job name (number/user/name), e.g. 123456/QUSER/QZDASOINIT |
| Username | The user profile the SQL is running as (the authorization name) |
| Job Users tab | The job user. For host server jobs this is a generic profile such as QUSER; for batch jobs it is the submitting user. |
| Jobs tab | The subsystem and job name, e.g. QUSRWRK/QZDASOINIT, which tells the different server jobs apart |
| Program | The client application name, client program ID or interface name |
| Database | The relational database name (current server) |
| Wait event | The job status, e.g. RUN or LCKW (waiting for a lock) |
Idle jobs, such as host server jobs waiting for the next client request (TIMW, TIMA, CNDW, SELW, PSRW and others), are not counted as database time.
SQL Statistics​
When Collect SQL Statistics is enabled, DBmarlin takes a snapshot of the SQL plan cache each batch interval with QSYS2.DUMP_PLAN_CACHE and collects executions, duration, CPU time, synchronous and asynchronous reads, rows returned and page faults per statement. The snapshot is written to a table in QTEMP, which is private to the DBmarlin job and is deleted automatically when the job ends, so nothing is left behind on the monitored system.
Only statements that are in the plan cache are included. Very simple statements, such as INSERT ... VALUES, may not be cached and so do not appear in SQL statistics, although they are still seen in activity.
Execution plans​
Db2 for i has no explain tables, so DBmarlin builds a text execution plan from the access plan records in the plan cache snapshot: table scans, indexes used and created, sorts, temporary tables, hash tables, grouping, indexes advised and the reasons the optimizer gives for each. No extra setup is needed beyond QIBM_DB_SQLADM function usage. Host variable values are not read.
Blocking sessions​
When Collect Blocking Sessions is enabled, DBmarlin finds the job holding the record lock that each job in LCKW status is waiting for, using QSYS2.JOB_LOCK_INFO and QSYS2.RECORD_LOCK_INFO. This needs *JOBCTL special authority, as described in Authority needed for each feature.
Object Browser​
Table, index and column statistics for the Object Browser are read from the QSYS2 catalog views. In Db2 for i a schema is a library. IBM-supplied libraries (Q*, SYS* and #*) are excluded.
Configuration changes​
IBM i system values (QSYS2.SYSTEM_VALUE_INFO) are tracked, and a change is recorded as an event. System values that change all the time, such as the date and time, are ignored.
Monitoring the IBM i host​
The IBM i operating system can also be monitored as a host, to show CPU utilisation, memory pools, page faults and disk activity alongside database activity. See IBM i for the host pre-requisites.
Feature walkthrough​
Watch this walkthrough of DBmarlin's monitoring features for IBM Db2 for i.