db2fodc - Db2 first occurrence data capture command
The db2fodc utility captures symptom-based data about the Db2 instance to help in problem determination situations. It is intended to collect information about potential hangs, severe performance issues, and various types of errors.
Purpose
The db2fodc command is used to collect performance data on issues that do not trigger automatic FODC (first occurrence data capture).
The command is used in two main ways. The first method collects data immediately by running the db2fodc command as the issue occurs. The second method, available in Version 9.7 Fix Pack 5 and later fix packs, triggers data collection when the environment reaches the state you described with threshold parameters.
You build the command with three basic components: one main data collection parameter, secondary data collection parameters, and threshold parameters.
Begin by choosing the main data collection parameter and its data collection mode: either basic or full. You can run the command in this state to immediately collect data.
Or you can add secondary data collection parameters to choose what part or parts of the system you want to scan. In addition, you can specify where the output goes and set a timeout value. Data is collected immediately, if you run the command this way.
Or you can add threshold parameters, available in Version 9.7 Fix Pack 5 and later fix packs. Specify the -detect parameter, along with one or more threshold rules, to set a conditional threshold. The system is monitored and data is collected when the thresholds are met.
If you choose to add threshold parameters, the command continues to run until the user ID the
command is running against is logged off or the environment reaches the state that is described by
the threshold parameters. To keep the command active in the background regardless of user's
subsequent logout, add nohup to the start of the command and &
to the end. For example, nohup db2fodc -memory basic -detect "avm>=5242880"
&.
Regardless of the collection method, the captured data is placed inside an FODC package directory. This directory is created either in the default diagnostic path or in an FODC directory path you specify with the -fodcpath parameter.
You can review the output or you can send the directory, with the collected diagnostic data, to IBM support for analysis.
Authorization
- On Linux® and UNIX systems, the SYSADM authority level. You must also be the instance owner.
- On Windows operating systems, the SYSADM authority level.
Command syntax
Main data collection parameters
Choose only one main data collection parameter per command.
- -hang
- Collects FODC data that is related to a potential hang situation or a serious performance issue. The -hang parameter is intended for use when the instance is considered unusable and needs restarting. Data is collected as quickly as possible, although, the process might not complete if the instance or database is already hanging. The full or basic collection mode can be used without user interaction.
- -perf
- Collects data that is related to a performance issue. The -perf parameter is similar to the-hang parameter, but uses less resources. Therefore, this option is employed when the instance is still usable and restarting is not needed. The full or the basic collection mode can be run without user interaction.
- -profile profileName
- Collects FODC data on a potential hang situation. Data is collected based on the parameters that you specify in the db2fodc.profile file in the ~/sqllib/cfg directory. You can modify one of the existing profiles or add a new one. The full list of parameters that can be specified is in the sqllib/bin/db2cos_hang script. It is recommended that you use the -profile parameter only under the guidance of IBM® support.
- -cpu
- In Version 9.7 Fix Pack 5 and later fix packs, collects processor-related performance and diagnostic data. The data can be used to diagnose problems that are related to high processor use, a high number of running processes, or high processor wait times. The full or the basic collection mode can be run without user interaction.
- -memory
- In Version 9.7 Fix Pack 5 and later fix packs, collects memory-related diagnostic data. Problems such as no free memory available, swap space that is used at a high rate, excessive paging or a suspected a memory leak can be diagnosed. The full or the basic collection mode can be run without user interaction.
- -connections
- In Version 9.7 Fix Pack 5 and later fix packs, collects connection-related diagnostic data. The data can be used to diagnose problems such as spikes in the number of applications in the executing or compiling state and new database connections that were denied.
- -clp
- In Version 9.7 Fix Pack 5 and later fix packs, collects operating system and configuration information that is related to instance creation. The command does not support the -member parameter, but does support the -host parameter. The -clp parameter is supported only on Linux and UNIX operating systems. If you issue this command on a Windows operating system, no data is collected.
- -preupgrade
- In Version 9.7 Fix Pack 5 and later fix packs, collects performance-related information before a critical upgrade or update. The use of the -preupgrade parameter is precautionary. After the upgrade or update, any problems that might occur can be potentially diagnosed with the assistance of the collected data and IBM support. To obtain sufficient performance data to troubleshoot any future problems issue the command several times, both at peak and idle usage times. This parameter must be specified with a database and can take a long time to complete.
- -hadr
- In Version 9.7 Fix Pack 7 and later fix packs, collects diagnostic data that is related to HADR
problems. You can use this parameter with the -detect option to detect HADR
congestion and automatically collect the related diagnostic information. If the
-hadr and -detect options are both specified, you cannot
use any threshold rules. Threshold options for the -hadr option have different
defaults and only the following are available:
Table 1. . Default values for -HADR parameter threshold options Available threshold options Default value iteration= 1 interval= 30 sleeptime= 0 triggercount= 10 -nocollect n/a off n/a - -fodcerror FODC_[Index|Data|Col]Error_directory
- FODC_[Index|Data|Col]Error_directory collects data that is
related to:
- an index error (FODC_IndexError_directory),
- a database manager error (FODC_DataError_directory), or
- a column-organized table error (FODC_ColError_directory).
The FODC_[Index|Data|Col]Error_directory folder is required and must contain the db2cos_[index|data|col]error_short(.bat) script or the db2cos_[index|data|col]error_long(.bat) script. For example, the db2cos_[index|data|col]error_short(.bat) script or the db2cos_[index|data|col]error_long(.bat).
The BASIC mode invokes db2cos_[index|data|col]error_short script. The FULL mode invokes db2cos_[index|data|col]error_short and db2cos_[index|data|col]error_long scripts. If the mode is not specified, the BASIC mode is the default.
Do not rename or move the FODC_[Index|Data|Col]Error_directory directory. The db2dart commands in the scripts need this directory path to correctly generate reports.
- -help
- Displays help information. When this option is specified, all other options are ignored, and only the help information is displayed.
Main data collection parameter modes
You can specify the collection mode as a suboption for some of the main data collection parameters.
- basic
- The basic collection mode is run, without user interaction. Less data is collected than in the full mode, but with less resources used.
- full
- The full collection mode is run, without user interaction. This option requires more resources and time to run than basic collection mode, but gathers more data.
Secondary data collection parameters
One or more of the following secondary data collection parameters can be specified with one of the main data collection parameters.
- -db dbname
- Collects FODC data that is related to the specified database or databases. Multiple databases can be specified in a comma-separated list.
- -alldbs
- Collects FODC data that is related to all active databases. This option is active by default.
- -member member_number|member_range
- In Version 9.7 Fix Pack 5 and later fix packs, specifies the member or members on which the command is issued. If this option is not specified, the command is issued on the current member. Multiple members can be specified as a comma-separated list, as a range of members, or any combination thereof.
- -allmembers
- Specifies that this command is to run on all members of the local host. To illustrate the difference between the -allmember parameter and the -all suboption for the -member parameter, consider the following example:
- -dbp-dbpartitionnum
- Collects FODC data that is related to all the specified database partition numbers. The -dbp parameter is equal to the -member parameter, except that the -dbp parameter is suitable for use in non-pureScale environments.
- -alldbp-alldbpartitionnums
- Specifies that the command is to run on all active database partition servers in the instance. Data is collected from the database partition servers on the same physical computer that the db2fodc command is being run. The -alldbp parameter is equal to the -allmember parameter, except that the -alldbp parameter is suitable for use in non-pureScale environments.
- -timeout timeout_value
- Specifies a timeout period for the callout script that is started by the db2fodc command. If the timeout is reached before the callout script completes diagnostic data collection, the script process is stopped. There is no default timeout. Therefore, if no timeout value is specified, the command runs in perpetuity. The timeout is specified as nh ym xs, where n represents hours, y represents minutes, and x represents seconds. If no h, m, or n suffix is specified, the timeout is in seconds.
- -fodcpath fodc_path_name
- In Version 9.7 Fix Pack 4 and later fix packs, specifies the full path to the directory where the FODC data package is created. The path that you specify must be writable by the members on the database and by the fmp processes running on the member or partition. If you do not specify the -fodcpath parameter and do not specify a list of partitions or members in your command, the -fodcpath parameter setting for the current partition or member is used. If this value is not set, the instance level setting is used. If this value is not set, FODC data is sent to the current diagnostic directory path (diagpath or alt_diagpath).
- -host hostname
- In Version 9.7 Fix Pack 4 and later fix packs, specifies the host or hosts on which the command is issued. The command is issued for all members that are on the specified host. If a host name is not specified, the command is issued on the local host for the default member. Multiple host can be specified as a comma-separated list of hosts. If you run the command on a remote host, the collection mode (basic or full) must be specified. Also, ensure that $HOME/.rhosts is set up between hosts. The -host option cannot be combined with the -member option.
Threshold parameters
To collect data when the environment reaches certain thresholds, use the -detect parameter and one or more threshold parameters.
- -detect threshold_rule "<comparison_operator> threshold_value" threshold_options
- In Version 9.7 Fix Pack 5 and later fix packs, specifies a set of conditions that must exist before data collection is triggered. The -detect parameter can be combined with one or more variables of a threshold rule that is combined with a threshold value and separated by a comparison operator. Data collection is further specified with the addition of threshold options. For example of threshold options is the number of times a threshold must be detected or the length of time for which a threshold must be detected before data collection is triggered. At least one valid threshold rule must be specified, except for -hadr data collection. Detection is logged in the db2diag log files.
| Operating system | AIX | Linux | Windows |
|---|---|---|---|
| Command used | vmstat | vmstst -a | db2pd -vmstat |
| Run queue (rqueue) | r | r | r |
| Block queue (bqueue) | b | b | Not applicable |
| Active memory (avm) | avm | active | used |
| Free memory (free) | fre | free | free |
| Paging in (pi) | pi | Not applicable | pi |
| Paging out (po) | po | Not applicable | po |
| Swapping in (si) | Not applicable | si | Not applicable |
| Swapping out (so) | Not applicable | so | Not applicable |
| Page scanned (sr) | sr | Not applicable | Not applicable |
| User CPU (us) | us | us | usr |
| System CPU (sy) | sy | sy | sys |
| User and system CPU (us_sy) | us+sy | us+sy | us+sy |
| Idle CPU (id) | id | id | idl |
| Context switches (cs) | cs | cs | cs/s |
| Operating system | Command used | Used swap space (swapused) |
|---|---|---|
| AIX | lsps -s | Percentage value that is located under the Percent Used column |
| Linux | free | (total swap space/used swap space)*100% |
| Windows | Not applicable | Not applicable |

Immediate collection examples
These basic examples of the db2fodc command illustrate how to manually collect diagnostic data, as the problems occurs.-hang
Consider a potential hang situation. Db2 software is running stable, but when you update or select multiple records from a particular table, the application hangs. You restart Db2 software and again the system is stable. However, one week later the same situation occurs.
db2fodc -hang –alldbsBy adding the -hang
parameter basic operating system, configuration, and diagnostic information is collected that can
assist IBM support in analyzing the potential hang.- To collect data on a potential hang situation in a specific database, SAMPLE, with the full data
collection mode, run the following command:
The full main data collection parameter mode is started. This option requires more resources and time to run than the basic collection mode. Data collection is restricted to the database SAMPLE.db2fodc -hang full -db SAMPLE - To collect data during a potential hang situation on all the hosts that are defined in
db2nodes.cfg file, run the following
command:
The basic main data collection parameter mode is started.db2fodc -hang basic -host all
-profile
[collectstack]
db2pdstack_iterations=9
db2pdstack_sleep=30
<end>After
you create your profile, specify the name of the profile in the command while the performance issue
is occurring, such as in the following
example:db2fodc -profile collectstackAs a result, a stack trace is generated
with 9 iterations and 30 seconds of sleep time. The full list of parameters that can be specified in
the profile can be found in the sqllib/bin/db2cos_hang script. It is
recommended that the profile parameters be used only with the guidance of IBM support.-perf
db2fodc -db SAMPLE -perf fullSnapshots, stacktraces, virtual memory,
input and output information, and traces are some of the data that is collected when you include the
-perf parameter. In this example, the full data collection mode is started and is
restricted to the database SAMPLE. The full mode requires more resources and can
take longer to run. db2fodc -perf -member 10-13,15in this example, the db2fodc
-perf command is started in the default basic collection mode on members 10, 12, 13, and
15.-cpu
db2fodc –cpu fullYou run the command several more times during
peak use and during idle time to generate an accurate conclusion about whether the symptoms are
persisting over time. The full data collection mode is started and the default
DB2FODC registry variables and parameters are used.-memory
db2fodc –memory full -member 3In this example, the full data
collection mode is started and is restricted to the third member.-connections
db2fodc –connections-clp
db2fodc –clp fullThis
command collects environment and configuration-related information that is targeted to diagnosing an
instance creation problem. After collection is completed the information is stored in a newly
created directory named
FODC_Clp_timestamp_member, which can be
sent to IBM support for analysis.-preupgrade
db2fodc -preupgrade -db SAMPLE -par DYN_SQL_FILE=sqlFileWhere,
SAMPLE is the name of the database from which you are collecting information
from. Where sqlFile is a file that contains the SQL statements that are most
representative of your workload. If you do not include -par
DYN_SQL_FILE=sqlFile option with the -upgrade parameter, 20 dynamic
queries are retrieved from the dynamic SQL cache. To gather optimal performance information, you can
issue the db2fodc -preupgrade command multiple times, at high usage times and at
idle times. After the upgrade, run the same command again. If there is a performance issue after you
upgrade, compare the output of the command before and after the upgrade. For more assistance,
contact IBM Support.-hadr
- To manually collect HADR-related data, run the following
command:
This command starts the db2cos_hadr (db2cos_hadr.bat on Windows) script and places the collected data in thedb2fodc -hadr -db sampleFODC_Hadr_timestamp_hostname_Primary|Standby|Standarddirectory, which is created in theDIAGPATHdirectory. - To collect HADR diagnostic data on all hosts, run the following
command:
This command collects data on all hosts and places the collected data in the DIAGPATH directory on each host.db2fodc –hadr –db sample –host all - To collect HADR diagnostic data on specifically the primary and standby hosts, run the following
command:
db2fodc –hadr –db sample –host hostA,hostB - To collect HADR diagnostic data on hostB and places the
FODC_Hadr package into DIAGPATH directory on
hostB, run the following command on
hostA:
db2fodc –hadr –db sample –host hostB - To place the
FODC_Hadrpackage into another directory, the/TMP/hadrdata/directory for example, run the following command:db2fodc –hadr –db sample –host all –fodcpath /TMP/hadrdata/
-fodcerror FODC_IndexError_directory
db2fodc -fodcerror FOCE_IndexError_directoryThe basic
data collection mode is started, as it is the default. Data is collected into one or more files that
are deposited into the FODC_IndexError_directory directory. Review the output
for possible factors that can lead to an index error or send the directory to IBM support for analysis.Threshold collection examples
By specifying the -detect parameter, along with one or more threshold rules, you can set a value against cpu performance, memory, and connections. The system is monitored and data is collected when the threshold rules are met.
The following examples illustrate the use of the -detect parameter to collect diagnostic information:
-cpu
- To detect an intermittent issue with the processor that might be tied to the number of processes
in the run queue, run the following
command:
You can specify your own rules for the -detect parameter to determine when to start diagnostic data collection. In this example, both (db2fodc -cpu basic -detect us">=90" rqueue">=1000" condition="AND" triggercount="3" interval="2" iteration="4" sleeptime="100" duration="500" -member allcondition="AND"is the default) trigger conditions (us">=90" rqueue">=1000"rqueue">=1000") must exist for 6 seconds (triggercount="3" X interval="2"= 6 seconds) to trigger diagnostic data collection on all members. If the trigger conditions occur, then diagnostic data is collected. If the trigger conditions do not occur, trigger condition detection continues within the iteration. The iteration option is set to four to specify that trigger condition detection followed by diagnostic data collection is performed four times, with a sleep time of 100 seconds in between. The command exits after all four iterations are successfully completed or after 500 hours. (duration="500") - If you suspect that your processor is not performing well because of an issue with processor
time spent running kernel and user code, run the following
command:
The -detect parameter, which is combined with the threshold rules, delays the collection of processor-related information until the trigger conditions specified by the threshold rule are detected. The operator OR is chosen, which means only one of the thresholds must be tripped to trigger data collection. Because the trigger count value and interval value are not specified, the default values (db2fodc -cpu full -detect us”>=20” sy”>=10” condition=”OR”triggercount=5andinterval=1) are used. Therefore, if one of the threshold rules is met five consecutive times in 5 seconds (triggercount=5Xinterval=1), CPU-related data collection is triggered. If the threshold rules are never met, the command runs indefinitely. To stop the process, run the following command:
The db2fodc -detect off command stops all threshold detection and turns off any currently active threshold rules. This process can take up to 60 seconds to complete and stops all db2fodc -detect commands that are running on the server.db2fodc -detect off
-memory
- Consider a situation in which your system is performing poorly because the total number of
virtual-memory working segment pages on your AIX operating
system might be too high. You can run the following
command:
In this example, thenohup db2fodc -memory basic -detect "avm>=5242880" duration=1000 &nohupmode enables the command to ignore the HUP (hang up) signal so that the subsequent logout does not stop the command from running in the background. For that reason, the duration of 1000 hours is specified in the command. The duration parameter does not have a default, so, if duration is not specified, the command runs forever, if the conditions are never met. - You can detect a threshold condition and trigger automatic diagnostic data collection when the
threshold condition is exceeded multiple times. Consider the following command
example:
This example monitors the number of free memory blocks (db2fodc -memory basic -detect free"<=10" connections">=1000" interval=10 triggercount=4 duration=5 sleeptime=30 iteration=10 -member 3free"<=10") AND the number of application connections to the database (connections">=1000"). The operator is AND by default. Only member 3 is monitored for the conditions (-member 3). There are 10 iterations with 30 seconds of rest between each iteration. Data collection is tripped if both conditions are met four consecutive times over 40 seconds (triggercount=4Xinterval=10). - To trigger data collection when the amount of free memory drops to a specified amount, run the
following example
command:
If the number of free memory pages drops to or below 386236, and the amount of memory that is swapped out is greater than zero, the following output is an example of the data collection:db2fodc -memory basic -detect free"<=386236" so">=0" sleeptime=30 iteration=10 interval=10 triggercount=4 duration=5> db2fodc -memory basic -detect free"<=386236" so">=0" sleeptime=30 iteration=10 interval=10 triggercount=4 duration=5 "db2fodc": List of active databases: "SAMPLE" "db2fodc": Starting detection ... "db2fodc": "4" consecutive threshold hits are detected. "db2fodc": Triggering collection "1". Script is running with following parameters COLLECTION_MODE : LIGHT COLLECTION_TYPE : MEMORY COLLECTION_DURATION : 5 COLLECTION_ITERATION : 5 DATABASE/MEMBER : -alldbs FODC_PATH : /home/inst1/sqllib/db2dump/FODC_Memory_2013-04-02-15.47.56.969013_0000 db2pd_options : -agent -apinfo -active -tran -locks -bufferpools -dbptnmem -memset -mempool -sort -fcm hwm -dyn SNAPSHOT : 2 STACKTRACE : 2 TRACELIMIT : 20 SNAPSHOT_TYPE : ALL ... In db2diag.log: 2013-04-02-15.47.55.154348-240 I200475E548 LEVEL: Event PID : 8944 TID : 46912890796352 KTID : 8944 PROC : db2fodc INSTANCE: inst1 NODE : 000 HOSTNAME: coralxib11 FUNCTION: DB2 UDB, RAS/PD component, pdFodcDetectAndRunCollection, probe:100 CHANGE : Hostname: coralxib11 Member(s): 0 Iteration: 1 Thresholds hit 0: so(0)>=0 free(159972)<=386236 Thresholds hit 1: so(0)>=0 free(157872)<=386236 Thresholds hit 2: so(0)>=0 free(129572)<=386236 Thresholds hit 3: so(0)>=0 free(142952)<=386236 ..... 2013-04-02-15.47.56.969683-240 E201708E703 LEVEL: Warning PID : 9519 TID : 46912890796352 KTID : 9519 PROC : db2fodc INSTANCE: inst1 NODE : 000 HOSTNAME: coralxib11 FUNCTION: DB2 UDB, RAS/PD component, pdDb2FODCMain, probe:30 MESSAGE : ADM14003W FODC has been invoked by the user from db2fodc tool for symptom "memory" and diagnostic information has been recorded in directory "/home/inst1/sqllib/db2dump/FODC_Memory_2013-04-02-15.47.56.969013_0 000". Please look in this directory for detailed evidence about what happened and contact IBM support if necessary to diagnose the problem.
-hadr
- To automatically start diagnostic data collection if HADR congestion is detected, run the
following command:
The command starts a process that monitors the HADR database to see whether there is enough HADR congestion to start data collection. If there is enough HADR congestion, the db2cos_hadr (db2doc_hadr.bat on Windows operating systems) script is started and diagnostic data collection occurs. The process ends after diagnostic data collection completes. If not enough HADR congestion is ever detected, the monitor runs until the detection duration exceeds the duration parameter value, or the user ends it by issuing the following command:db2fodc –hadr –db sample –detectdb2fodc -detect off - To automatically start diagnostic data collection on all hosts if a certain amount of HADR
congestion is detected on the local host, run the following
command:
If congestion is detected, HADR diagnostic data is collected on all hosts.db2fodc –hadr –db sample -detect -host all - Consider that you might want to know whether HADR congestion is occurring, however, you do not
want to slow down your system by collecting diagnostic data. Run the following command
example:
Diagnostic data is not collected. However, if HADR congestion is detected, the event is logged in thedb2fodc -hadr -db sample -detect -nocollectdb2diaglog files. - To check for HADR congestion over a specific amount of time, run the following
command:
HADR congestion is monitored for 24 hours (db2fodc -hadr -db sample -detect duration=24duration=24). Because the default for iteration is 1, for triggercount is 10, and for interval is 30, if HADR congestion is detected 10 consecutive times over 300 seconds, data is collected and the command exits. - Threshold options can be applied to the –hadr parameter. For example,
run the following
command:
The effect of this threshold rule is as follows:db2fodc -hadr -db sample -detect iteration=2 sleeptime=3600 triggercount=8 interval=15 duration=24- HADR congestion is monitored for at most two iterations, with sleep time for 1 hour between each iteration.
- If the threshold rules are met eight consecutive times, every 15 seconds, then data is collected and the iteration exits. If it is the first iteration, then the monitoring process sleeps for 1 hour before next iteration. If it is the second iteration, then the monitoring process exits.
- The detection monitoring process runs for 24 hours maximum.
- If HADR congestion is not detected after 24 hours, the detection process stops and exits the monitoring process.
- If no HADR congestion is detected, the first iteration runs for 24 hours and then exits. If that happens, the 1 hour sleeptime and the second iteration never run.
-connections
db2fodc –connections –db sample –detect connections">=10" connstatus=CompilingIf
the number of applications that are connected to the SAMPLE database in a compiling state is equal
to or greater than 10, then connection-related diagnostic data is collected. Multi-partitioned environments
The db2fodc -hang and db2fodc -perf commands can be run in a multi-partitioned environment with multiple physical nodes. In this environment, the following example runs successfully:db2fodc -perf full -member all other_options Or
db2fodc -perf -alldbpartitionnums other_optionsDuring a potential hang or
severe performance issue, in a partitioned database environment, these parameters can be used to
start the db2fodc command at all nodes in a single invocation. Options
-alldbpartitionnums and -dbpartitionnum are suitable for
only logical partition numbers. If the -dbp or -member
options are not specified, by default, only information from the current partition number is
collected.db2_all "<<+node#< db2fodc -fodcerror FODC_IndexError_directory [basic | full]Where
the node# is the number of the specific node. This number is the last number in the
directory
FODC_IndexError_timestamp_PID_EDUID_Node#.
An absolute path must be used, if you ran the db2fodc -fodcerror
FODC_IndexError_directory command with the db2_all command.
The output and log files are in the db2diag log file. The
FODC_IndexError_directory folder is required and must contain the
db2cos_indexerror_short(.bat) script or the
db2cos_indexerror_long(.bat) script. Do not rename or move the
FODC_IndexError_directory directory. The db2dart commands in the
scripts need this directory path to correctly generate reports. If you must run db2fodc
-fodcerror
FODC_IndexError_directory manually, check the
FODC_IndexError_directory directory for any existing db2dart
reports. Reports have the extension .rpt and .rpthex. If there are
reports in the directory, rename them or move them to a subdirectory under the
FODC_IndexError_directory directory before you start db2fodc
-fodcerror
FODC_IndexError_directory manually. 