IBM Books

DB2 Query Patroller Administration Guide


Using the Command-Line Interface

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.


Command-Line Interface Environment

The command-line interface requires the following items for successful execution:


Submit Command (iwm_submit)

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.


Control Command (iwm_cmd)

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:

Common Parameters


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.

Monitoring Jobs

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.

Syntax:

>>-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:

  • Q - Queued

  • S - Scheduled

  • H - Held

  • R - Running

  • U - Unfinished

  • D - Done

  • A - Aborted

  • C - Canceled

  • F - Finished

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:

  • Q - Queued

  • S - Scheduled

  • H - Held

  • R - Running

  • U - Unfinished

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.

Controlling Jobs

iwm_cmd allows users to cancel their jobs. It also allows the system administrator to cancel or release a job.

Syntax:

>>-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.

Monitoring and Controlling Nodes

iwm_cmd enables the DB2 Query Patroller system administrator to monitor and control the status and activity of agent nodes.

Syntax:

>>-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.

  • Active. The server component can schedule new jobs to run on the node.

  • Quiesced. Jobs already scheduled to run on the node continue to run, but no more will be scheduled.

  • Inactive. Jobs already scheduled to run on the node continue to run, but no more will be scheduled to run on the node. After all previously scheduled jobs complete, the node manager process running on the node will terminate.

  • Force. The node manager process running on the node will terminate immediately without waiting for jobs already running on the node to complete.

Listing and Controlling Data Sources

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
Parameter Description
-d data_source Data source name. This parameter specifies the name of the data source to be listed or altered. In the current release, the only valid value is IWM.
Status=status

Data source status. This parameter specifies that the status of the data source should be altered and provides the new status. The status must be one of the following:

  • Active. Jobs will be scheduled normally.

  • Hold. All incoming jobs will be held, but any jobs already in the queue will be allowed to proceed.

  • Inactive. All requests to submit a new job will be rejected.

  • ReleaseAll. All jobs in the data source with a status of held will be released and the data source status will be set to active.

  • HoldAll. All jobs in the data source that are not yet running will be held. The status of the data source will be set to hold.

JobCostLimt=value Alter job cost limit. This parameter specifies that the limit of the total estimated cost of running jobs against this data source should be altered. The new value must be at least zero.
JobCountLimt=value Alter job count limit. This parameter specifies that the limit of the total number of jobs running against this data source should be altered. The new value must be at least zero. If zero, scheduling of new jobs is disabled.
NodeCpuLimt=value Alter node CPU limit. This parameter specifies that the per-node CPU utilization maximum for scheduling new jobs against this data source should be altered. The new value must be between 0 and 100. If CPU utilization is not being collected, the value of this parameter is ignored.
NodeDiskLimit=value Alter node disk space limit. This parameter specifies that the per-node disk space minimum for scheduling new jobs against this data source should be altered. The value is in bytes and must be at least zero. If disk space utilization is not being collected, the value of this parameter is ignored.
-D List data sources. This parameter specifies that summary information on all data sources should display.

Listing and Controlling System Parameters

iwm_cmd enables the DB2 Query Patroller system administrator to list and change system parameters.

Syntax:

>>-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
Parameter Description
-P System parameters. This parameter specifies whether or not the values of the DB2 Query Patroller system parameters should be displayed or altered.
JobCostLimt=value Alter job cost limit. This parameter specifies that the limit of the total estimated cost of running jobs should be altered. The new value must be at least zero.
JobCountLimt=value Alter job count limit. This parameter specifies that the limit of the total number of running jobs should be altered. The new value must be at least zero. If zero, scheduling of new jobs is disabled.
JobPurgeDays=value Alter job information purging. This parameter specifies that the purge age for DB2 Query Patroller jobs should be altered. The new value must be between 0 and 999. If zero, automatic purging of job information is disabled. If not zero, the value of JobPurgeDays must be equal to or greater than the value of ResultsPurgeDays.
ResultsPurgeDays=value Alter result table purging. This parameter specifies that the purge age for result tables should be altered. The new value must be between 0 and 999. If zero, automatic purging of result tables information is disabled. If the value of JobPurgeDays does not equal zero, it must be equal to or greater than the value of ResultsPurgeDays.
AccountingStatus=status Alter job accounting status. This parameter specifies that the status of the DB2 Query Patroller job accounting feature should be altered. The status must be either active or inactive. If Active, DB2 Query Patroller inserts a row into the job accounting table as each job completes, aborts, or is canceled.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]

[ DB2 List of Books | Search the DB2 Books ]