DB2安装后自带的缺省db2cos脚本有着简单的流程。DB2调用它的时候会同时传递给它一些参数。db2cos脚本通过这些参数得知调用自己的实例,进程,时间点和函数等等信息。还有一个传入的参数叫做typeReason,它告诉db2cos被调用的原因是什么,例如数据损坏(DATA_COR),锁超时(LOCKTIMEOUT),死锁(DEADLOCK)或者其他错误代码(SQLCODE)。 常见的传入参数有下面几个: # instance : instance name # database : database name # dbpart : database partition number # pid : process ID # tid : thread ID # function : function name of function that called the panic script # component : component of the function # probe : probe point # timestamp : timestamp of when the script was called # appid : application ID # apphld : application handle db2cos会遍历上面的参数,记录下他们的值,然后根据typeReason参数的定义,执行对应的动作。每次db2cos被调用,db2diag.log中都会有相应的记录。例如: