This chapter provides information about using the DB2 Query Patroller command-line interface.
The command-line interface for DB2 Query Patroller enables the system administrator to monitor and control DB2 Query Patroller from an operating system shell. The command-line interface also enables end users to submit and monitor jobs from the system prompt. When combined with shell scripts or languages such as Perl, awk, and REXX, you can use the command-line interface as an application programming interface (API) to DB2 Query Patroller.
The command-line interface consists of the following two commands:
You can execute these commands on any machine with a TCP/IP connection to the server node.
The command-line interface requires the following items for successful execution:
The submit command (iwm_submit) enables users to submit jobs to DB2 Query Patroller. Although SQL queries are usually submitted through a 32-bit ODBC query application (via QueryEnabler) or through QueryMonitor, you can use iwm_submit to submit SQL commands, and system commands.
The following diagram provides the syntax for the iwm_submit command:
>>-iwm_submit----+---------------------------------+------------> '--u--user_id--+---------------+--' '--p--password--' >-----+---------------+---+--F--sql_stmt_file-----+-------------> '--c--max_cost--' +--S--"sql_smt"---------+ '--E--"system_command"--' >-----+------------+---+------------+---------------------------> '--m--+-Y-+--' '--C--+-Y-+--' '-N-' '-N-' >-----+----------------------------+---+------------------+-----> '--t--sched_after_date_time--' '--d--data_source--' >-----+-------------------------+---+-------------------------+-> '--r--result_destination--' '--e--elapsed_time_limit--' >-----+----------------+---+-------------------+----------------> '--l--row_limit--' '--L--+-Abort----+--' '-Truncate-' >-----+-----------------+---+-----+-----------------------------> '--i--+-Low----+--' '--q--' +-Normal-+ '-High---' >-----+-------------------------+------------------------------>< '--j--predecessor_job_id--'
Table 4. iwm_submit Parameter Descriptions
Parameter | Description |
---|---|
-u user_id |
User identification. This parameter enables the submitting user to specify a different owner for the job. This gives the DB2 Query Patroller system administrator the ability to submit queries or jobs on behalf of end users. The user ID must be a valid system and database ID, and a registered DB2 Query Patroller user. The command iwm_submit executes under the submitting user's environment. The user ID must conform to the system user identification syntax. The job owner defaults to the submitting user.
|
-p password | User password. If you provide the -u parameter and the submitting user is neither root nor the DB2 Query Patroller system administrator, this password parameter must also be specified. The password must be the user's database password. |
-c max_cost |
Cost threshold. This option enables the user to lower the cost threshold from what is defined in the DB2 Query Patroller user profile. Only root and the DB2 Query Patroller system administrator can increase the cost threshold with this option. The cost threshold must be a numeric value. By default, DB2 Query Patroller uses the cost threshold defined in the DB2
Query Patroller database.
|
-F sql_stmt_file | Specifies a path name containing a single SQL statement. The sql_stmt_file must be a valid file path name. The file contents are immediately placed in the DB2 Query Patroller database. |
-S "sql_stmt" | Specifies a single SQL command enclosed in quotes. The SQL statement is immediately placed in the DB2 Query Patroller database. |
-E "system_command" | Specifies an entire system command including any optional arguments. The command is executed from the user's home directory, and its source directory must be available in the search path. |
-m {Y | N} |
Mail Notification. This parameter specifies whether or not the user
should be notified through e-mail when the job completes or receives a hold
status.
|
-C {Y | N} |
Cost analysis override. If the user's DB2 Query Patroller profile allows queries to be submitted without cost analysis, this parameter determines whether the cost analysis should be performed. The option must be either Y or N. Y directs iwm_submit to perform cost analysis; N indicates no cost analysis. By default, DB2 Query Patroller performs cost analysis on SQL
queries. DB2 Query Patroller ignores this option for system
commands.
|
-t sched_after_date_time | Schedule after date/time. This parameter specifies the date and time after which the job will run. The date/time format is YYYYMMDDHHMMSS. The parameter default is the present date and time. |
-d data_source | Data source. Specifies the data source to run the job on. The only supported data source is IWM. This is the default value. |
-r result_destination | Result Destination. This parameter specifies the name of an alternate destination where results are sent instead of being written to a table in the database. |
-e elapsed_time_limit | Elapsed time limit. This option enables the user to set a limit for the elapsed time the job will be permitted to run. If the time limit is exceeded, DB2 Query Patroller aborts the job. The time limit value is in seconds. By default, DB2 Query Patroller will not impose an elapsed time limit on the job. |
-l row_limit | Result row limit. This option enables the user to set a limit for the number of rows returned by a SQL SELECT statement. If the row limit is exceeded, the action taken by DB2 Query Patroller depends on the setting of the -L parameter. By default, DB2 Query Patroller will not impose a result row limit. |
-L {Abort | Truncate} | Result row limit action. This option enables the user to specify the action taken by DB2 Query Patroller should the job return more rows than the result row limit. If it is not specified or set to Abort, DB2 Query Patroller aborts the job. Otherwise, if it is set to Truncate, DB2 Query Patroller truncates the result table at the row limit. |
-i {Low | Normal | High} |
User Priority. This parameter enables the user to select the priority of the job. The priority value can be low, normal, or high. Only the first letter is significant. These values may also be specified as 0, 1, or 2. The user's DB2 Query Patroller profile defines the actual priority levels that correspond to these values. By default, DB2 Query Patroller assigns the user's normal priority to
the job.
|
-q | Quiet mode. This parameter directs DB2 Query Patroller to print only the job number upon successful job submission. This may be useful if the iwm_submit command is used from within a shell script. |
-j predecessor_job_id | Predecessor job number. This parameter specifies a job number of a previously submitted DB2 Query Patroller job. The new job cannot be scheduled until the predecessor job completes. |
The control command (iwm_cmd) enables the system administrator to monitor and control DB2 Query Patroller from the operating system shell. It also enables end users to monitor their jobs.
Specifically, the system administrator and end user can use iwm_cmd when:
Each function of iwm_cmd has a different syntax. The following diagrams provide the complete syntax for the iwm_cmd:
>>-iwm_cmd----+------------------------------+------------------> '--u--user--+---------------+--' '--p--password--' >-----+-+-------------+-+---+---------------+---+---------+---->< | '--s--status--' | '--x--max_jobs--' '-fields--' +-+-------------+-+ | '--S--status--' | '-+-------------+-' '--j--job_id--'
>>-iwm_cmd----+------------------------------+------------------> '--u--user--+---------------+--' '--p--password--' >-----+--c--job_id------+-------------------------------------->< +--r--+-job_id--+-+ | '-user_id-' | '--R--------------'
>>-iwm_cmd----+------------------------------+------------------> '--u--user--+---------------+--' '--p--password--' >-----+--n--node_id--+---+-------------+----------------------->< '--N-----------' '--s--status--'
>>-iwm_cmd----+---------------------------------+---------------> '--u--user_id--+---------------+--' '--p--password--' >-----+-| data_source options |-+------------------------------>< '--D----------------------' data_source options |----d--data_source----+------------------+---------------------> '-Status=--status--' >-----+-----------------------+---+------------------------+----> '-JobCostLimit=--value--' '-JobCountLimit=--value--' >-----+-----------------------+---+------------------------+----| '-NodeCpuLimit=--value--' '-NodeDiskLimit=--value--'
>>-iwm_cmd----+------------------------------+----P-------------> '--u--user--+---------------+--' '--p--password--' >-----+-----------------------+---+------------------------+----> '-JobCostLimit=--value--' '-JobCountLimit=--value--' >-----+-----------------------+---+---------------------------+-> '-JobPurgeDays=--value--' '-ResultsPurgeDays=--value--' >-----+----------------------------+--------------------------->< '-AccountingStatus=--status--'
Table 5. iwm_cmd Common Parameter Descriptions
Parameter | Description |
---|---|
-u user_id |
User identification. This parameter provides either the DB2 Query Patroller user ID for the user whose jobs will be monitored or controlled, or the DB2 Query Patroller system administrator's ID (iwm). By default, DB2 Query Patroller uses the current system user ID.
|
-p password | User password. If the user provides the -u parameter and the current user is not the DB2 Query Patroller system administrator, the password parameter must also be specified. The password must be the user's database password. |
iwm_cmd allows users to monitor their jobs and the system administrator to monitor the status of all incomplete jobs. DB2 Query Patroller provides an interface to make it easy for programs invoking iwm_cmd to process information about each job. If a user invokes iwm_cmd without any parameters, all jobs for that user display.
>>-iwm_cmd----+------------------------------+------------------> '--u--user--+---------------+--' '--p--password--' >-----+-+-------------+-+---+---------------+---+---------+---->< | '--s--status--' | '--x--max_jobs--' '-fields--' +-+-------------+-+ | '--S--status--' | '-+-------------+-' '--j--job_id--'
Table 6. iwm_cmd Parameters for Monitoring Jobs
Parameter | Description |
---|---|
-s status |
User job status. This parameter specifies that jobs belonging to the user with the given status should display. The status must be one of the following:
Only the first letter is significant. It can be in either uppercase
or lowercase. The unfinished status includes any queued, scheduled,
held, or running jobs. The finished status includes any done, aborted,
or canceled jobs.
|
-S status |
Unfinished job status. This parameter specifies that all DB2 Query Patroller jobs with the given status should display. The status must be one of the following:
Only the first letter is significant. It can be in either uppercase
or lowercase. The Unfinished status includes queued, scheduled, held,
or running jobs. This parameter may only be used by the DB2 Query
Patroller system administrator.
|
-j job_id | Job identifier. This parameter specifies that only the requested job should display. If someone other than the DB2 Query Patroller system administrator uses this parameter, the user must be the owner of the job. |
-x max_jobs | Maximum job count. This parameter specifies the maximum number of jobs to be listed. If this parameter is not specified, a maximum of 100 jobs display. If max_jobs contains the value 0, no limit is applied. |
fields | Job fields. There are two job fields: Job and Status. You can enter these fields together or separately. This parameter is case sensitive. If you provide a field parameter, the jobs do not display in an easy-to-read format. Instead, the values of the fields are written to STDOUT in a format that other programs can easily process. A horizontal tab character separates each field from the next. Newline characters separate each job's fields from the next. |
iwm_cmd allows users to cancel their jobs. It also allows the system administrator to cancel or release a job.
>>-iwm_cmd----+------------------------------+------------------> '--u--user--+---------------+--' '--p--password--' >-----+--c--job_id------+-------------------------------------->< +--r--+-job_id--+-+ | '-user_id-' | '--R--------------'
Table 7. iwm_cmd Parameters for Controlling Jobs
Parameter | Description |
---|---|
-c job_id | Cancel a job. This parameter specifies that the given job should be canceled. A job need not have finished in order for it to be canceled. If the user is not the DB2 Query Patroller system administrator, the job must be owned by the user. |
-r job_id | Release a job. This parameter specifies that the given job should be released. The job must currently have a status of held. This parameter may only be used by the DB2 Query Patroller system administrator. |
-r user_id | Release all jobs for a user. This parameter specifies that all jobs owned by a user with a current status of held should be released. This parameter may only be used by the DB2 Query Patroller system administrator. |
-R | Release all jobs. This parameter specifies that all Held jobs should be released. This parameter may only be used by the DB2 Query Patroller system administrator. |
iwm_cmd enables the DB2 Query Patroller system administrator to monitor and control the status and activity of agent nodes.
>>-iwm_cmd----+------------------------------+------------------> '--u--user--+---------------+--' '--p--password--' >-----+--n--node_id--+---+-------------+----------------------->< '--N-----------' '--s--status--'
Table 8. iwm_cmd Parameters for Monitoring and Controlling Nodes
Parameter | Description |
---|---|
-n node_id | Node identifier. This parameter specifies that the status of the given node should be displayed or be altered. |
-N | All nodes. This parameter specifies that the status of all agent nodes should be displayed or be altered. |
-s status |
Node status. This parameter specifies that the status of the node(s) should be altered and provides the new requested status. The status must be from the following list. Only the first letter is significant. It can be either uppercase or lowercase.
|
iwm_cmd enables the DB2 Query Patroller system administrator to list and change the data source parameters for one or all data sources.
Syntax:
>>-iwm_cmd----+---------------------------------+---------------> '--u--user_id--+---------------+--' '--p--password--' >-----+-| data_source options |-+------------------------------>< '--D----------------------' data_source options |---| data_source options |---d--data_source--------------------> >-----+------------------+---+-----------------------+----------> '-Status=--status--' '-JobCostLimit=--value--' >-----+------------------------+---+-----------------------+----> '-JobCountLimit=--value--' '-NodeCpuLimit=--value--' >-----+------------------------+--------------------------------| '-NodeDiskLimit=--value--'
iwm_cmd enables the DB2 Query Patroller system administrator to list and change the data source parameters for one or all data sources.
Table 9. iwm_cmd Parameters for Listing and Controlling Data Sources
iwm_cmd enables the DB2 Query Patroller system administrator to list and change system parameters.
>>-iwm_cmd----+------------------------------+----P-------------> '--u--user--+---------------+--' '--p--password--' >-----+-----------------------+---+------------------------+----> '-JobCostLimit=--value--' '-JobCountLimit=--value--' >-----+-----------------------+---+---------------------------+-> '-JobPurgeDays=--value--' '-ResultsPurgeDays=--value--' >-----+----------------------------+--------------------------->< '-AccountingStatus=--status--'
Table 10. iwm_cmd Parameters for Listing and Controlling System Parameters