DB2数据库运维脚本,在不断的持续更新中

由于个人的需要,写了一份数据库运维脚本。  写本脚本的用意是:
   写一个自动收集数据库信息的脚本,这个脚本能把想要的数据保存到一个表格文件 中,方便excel等图表软件的处理。这些数据可以利用图表软件和word生 成定期的 维护报告。本脚本的终极目标是自己动手实现数据库日常运维的自动化。
   脚本主要定时收集数据库大小、数据库缓冲池、数据库表空间、锁、排 序、应用链接、自动存储路径的信息。

欢迎大家提出宝贵建议!{:3_57:}

附件:

附件图标test.sh (11.92 KB)

附件图标DPR.zip (2.66 MB)

附件图标checker.sh (12.02 KB)

附件图标collector.sh (19.84 KB)

附件图标getevmon.ksh (1.24 KB)

附件图标getsnap.ksh (1.46 KB)

附件图标dbcheck.sh (16.83 KB)

附件图标DBA脚本.doc (89.5 KB)

附件图标ibm_db-2.0.4.1-py2.7-win-amd64.egg (421.22 KB)

参与136

81同行回答

thuanqinthuanqin  其它 , ibm
顶一个~有需要可以参考下这个,大部分SQL直接拿去用就行了:显示全部
顶一个~有需要可以参考下这个,大部分SQL直接拿去用就行了:收起
互联网服务 · 2014-03-27
浏览2712
thuanqinthuanqin  其它 , ibm
还有这两个,也是以前写的,也可以拿去参考下:可以找到下面的数据:collector_tablespace;collector_table_status;collector_rows_selected_div_read;collector_rows_selected_div_select_sql;collector_execution_number_top_10;collector_sort_number_top_10;collector_log_w...显示全部
还有这两个,也是以前写的,也可以拿去参考下:

可以找到下面的数据:
collector_tablespace;
collector_table_status;
collector_rows_selected_div_read;
collector_rows_selected_div_select_sql;
collector_execution_number_top_10;
collector_sort_number_top_10;
collector_log_write_speed;
collector_catalog_cache;
collector_lock;
collector_application;
collector_sort;
collector_bufferpool_hit;
collector_db2diag;
collector_backupcheck;
collector_OS;收起
互联网服务 · 2014-03-27
浏览2157
taylor840326taylor840326  数据库管理员 , 中国百盛集团
第一版,还很不完善。这个脚本在红帽子5系统和DB2 V9.5.4上测试通过。可以正常执行。显示全部
第一版,还很不完善。这个脚本在红帽子5系统和DB2 V9.5.4上测试通过。可以正常执行。收起
互联网服务 · 2014-03-21
浏览2453
张东焕张东焕  技术总监 , IBM官方授权讲师
DB2中最基本的收集信息的工具是snapshot和event monitor,而且与数据库版本基本无关,提供两个脚本用于自动收集每间隔一段时间执行snapshot及执行event monitor的脚本。DB2 snapshot和eventmonitor收集脚本。...显示全部
DB2中最基本的收集信息的工具是snapshot和event monitor,而且与数据库版本基本无关,提供两个脚本用于自动收集每间隔一段时间执行snapshot及执行event monitor的脚本。

DB2 snapshot和eventmonitor收集脚本。


收起
IT咨询服务 · 2014-03-27
浏览2117
张东焕张东焕  技术总监 , IBM官方授权讲师
DB2 V9.7之后有monreport。[tsminst1@prod-tsm01 ~]$ db2 call monreport.dbsummary \(600\)  Result set 1  --------------  TEXT                       ...显示全部
DB2 V9.7之后有monreport。[tsminst1@prod-tsm01 ~]$ db2 call monreport.dbsummary \(600\)



  Result set 1
  --------------

  TEXT                                                                                                                    
  --------------------------------------------------------------------------------
  --------------------------------------------------------------------------------
  Monitoring report - database summary                                                                                    
  --------------------------------------------------------------------------------
  Database:                                 TSMDB1                                                                        
  Generated:                                03/26/2014 10:08:07                                                           
  Interval monitored:                       600                                                                           

  ================================================================================
  Part 1 - System performance                                                                                             

  Work volume and throughput                                                                                             
  --------------------------------------------------------------------------------
                                    Per second             Total                                                         
                                    ---------------------  -----------------------
  TOTAL_APP_COMMITS                 4                      2569                                                           
  ACT_COMPLETED_TOTAL               15                     9476                                                           
  APP_RQSTS_COMPLETED_TOTAL         24                     14872                                                         

  TOTAL_CPU_TIME                    = 2686539                                                                             
  TOTAL_CPU_TIME per request        = 180                                                                                 

  Row processing                                                                                                         
    ROWS_READ/ROWS_RETURNED         = 2 (26789/10800)                                                                     
    ROWS_MODIFIED                   = 4313                                                                                

  Wait times                                                                                                              
  --------------------------------------------------------------------------------

  -- Wait time as a percentage of elapsed time --                                                                        

                                           %    Wait time/Total time                                                      
                                           ---  ----------------------------------
  For requests                             0    2811/301714                                                               
  For activities                           34   1044/3070                                                                 

  -- Time waiting for next client request --                                                                              

  CLIENT_IDLE_WAIT_TIME               = 48337500                                                                          
  CLIENT_IDLE_WAIT_TIME per second    = 80562                                                                             

  -- Detailed breakdown of TOTAL_WAIT_TIME --                                                                             

                                %    Total                                                                                
                                ---  ---------------------------------------------
  TOTAL_WAIT_TIME               100  2811                                                                                 

  I/O wait time                                                                                                           
    POOL_READ_TIME              0    10                                                                                   
    POOL_WRITE_TIME             0    24                                                                                   
    DIRECT_READ_TIME            20   568                                                                                 
    DIRECT_WRITE_TIME           0    4                                                                                    
    LOG_DISK_WAIT_TIME          74   2088                                                                                 
  LOCK_WAIT_TIME                0    0                                                                                    
  AGENT_WAIT_TIME               0    0                                                                                    
  Network and FCM                                                                                                         
    TCPIP_SEND_WAIT_TIME        0    0                                                                                    
    TCPIP_RECV_WAIT_TIME        0    0                                                                                    
    IPC_SEND_WAIT_TIME          3    96                                                                                   
    IPC_RECV_WAIT_TIME          0    19                                                                                   
    FCM_SEND_WAIT_TIME          0    0                                                                                    
    FCM_RECV_WAIT_TIME          0    0                                                                                    
  WLM_QUEUE_TIME_TOTAL          0    0                                                                                    

  Component times                                                                                                         
  --------------------------------------------------------------------------------
  -- Detailed breakdown of processing time --                                                                             

                                      %                 Total                                                            
                                      ----------------  --------------------------
  Total processing                    100               298903                                                            

  Section execution                                                                                                      
    TOTAL_SECTION_PROC_TIME           0                 882                                                               
      TOTAL_SECTION_SORT_PROC_TIME    0                 77                                                               
  Compile                                                                                                                 
    TOTAL_COMPILE_PROC_TIME           0                 1480                                                              
    TOTAL_IMPLICIT_COMPILE_PROC_TIME  0                 108                                                               
  Transaction end processing                                                                                             
    TOTAL_COMMIT_PROC_TIME            0                 60                                                               
    TOTAL_ROLLBACK_PROC_TIME          0                 1                                                                 
  Utilities                                                                                                               
    TOTAL_RUNSTATS_PROC_TIME          0                 39                                                               
    TOTAL_REORGS_PROC_TIME            0                 0                                                                 
    TOTAL_LOAD_PROC_TIME              0                 0                                                                 

  Buffer pool                                                                                                            
  --------------------------------------------------------------------------------
  Buffer pool hit ratios                                                                                                  

  Type             Ratio            Reads (Logical/Physical)                                                              
  ---------------  ---------------  ----------------------------------------------
  Data             99               17186/1                                                                              
  Index            100              29910/0                                                                              
  XDA              0                0/0                                                                                   
  Temp data        100              870/0                                                                                 
  Temp index       0                0/0                                                                                   
  Temp XDA         0                0/0                                                                                   

  I/O                                                                                                                     
  --------------------------------------------------------------------------------
  Buffer pool writes                                                                                                      
    POOL_DATA_WRITES      = 18                                                                                            
    POOL_XDA_WRITES       = 0                                                                                             
    POOL_INDEX_WRITES     = 7                                                                                             
  Direct I/O                                                                                                              
    DIRECT_READS          = 631730                                                                                       
    DIRECT_READ_REQS      = 28                                                                                            
    DIRECT_WRITES         = 1204                                                                                          
    DIRECT_WRITE_REQS     = 144                                                                                          
  Log I/O                                                                                                                 
    LOG_DISK_WAITS_TOTAL  = 753                                                                                          

  Locking                                                                                                                 
  --------------------------------------------------------------------------------
                          Per activity                    Total                                                           
                          ------------------------------  ----------------------                                          
  LOCK_WAIT_TIME          0                               0                                                               
  LOCK_WAITS              0                               0                                                               
  LOCK_TIMEOUTS           0                               0                                                               
  DEADLOCKS               0                               0                                                               
  LOCK_ESCALS             0                               0                                                               

  Routines                                                                                                               
  --------------------------------------------------------------------------------
                                Per activity              Total                                                           
                                ------------------------  ------------------------
  TOTAL_ROUTINE_INVOCATIONS     0                         145                                                            
  TOTAL_ROUTINE_TIME            0                         1149                                                            

  TOTAL_ROUTINE_TIME per invocation   = 7                                                                                 

  Sort                                                                                                                    
  --------------------------------------------------------------------------------
  TOTAL_SORTS                         = 1212                                                                              
  SORT_OVERFLOWS                      = 0                                                                                 
  POST_THRESHOLD_SORTS                = 0                                                                                 
  POST_SHRTHRESHOLD_SORTS             = 0                                                                                 

  Network                                                                                                                 
  --------------------------------------------------------------------------------
  Communications with remote clients                                                                                      
  TCPIP_SEND_VOLUME per send          = 0          (0/0)                                                                  
  TCPIP_RECV_VOLUME per receive       = 0          (0/0)                                                                  

  Communications with local clients                                                                                       
  IPC_SEND_VOLUME per send            = 259        (3331322/12815)                                                        
  IPC_RECV_VOLUME per receive         = 181        (2324670/12812)                                                        

  Fast communications manager                                                                                             
  FCM_SEND_VOLUME per send            = 0          (0/0)                                                                  
  FCM_RECV_VOLUME per receive         = 0          (0/0)                                                                  

  Other                                                                                                                  
  --------------------------------------------------------------------------------
  Compilation                                                                                                            
    TOTAL_COMPILATIONS                = 621                                                                              
    PKG_CACHE_INSERTS                 = 782                                                                              
    PKG_CACHE_LOOKUPS                 = 9665                                                                              
  Catalog cache                                                                                                           
    CAT_CACHE_INSERTS                 = 7                                                                                 
    CAT_CACHE_LOOKUPS                 = 1532                                                                              
  Transaction processing                                                                                                  
    TOTAL_APP_COMMITS                 = 2569                                                                              
    INT_COMMITS                       = 63                                                                                
    TOTAL_APP_ROLLBACKS               = 99                                                                                
    INT_ROLLBACKS                     = 0                                                                                 
  Log buffer                                                                                                              
    NUM_LOG_BUFFER_FULL               = 0                                                                                 
  Activities aborted/rejected                                                                                             
    ACT_ABORTED_TOTAL                 = 2                                                                                 
    ACT_REJECTED_TOTAL                = 0                                                                                 
  Workload management controls                                                                                            
    WLM_QUEUE_ASSIGNMENTS_TOTAL       = 0                                                                                 
    WLM_QUEUE_TIME_TOTAL              = 0                                                                                 

  DB2 utility operations                                                                                                  
  --------------------------------------------------------------------------------
    TOTAL_RUNSTATS                    = 2                                                                                 
    TOTAL_REORGS                      = 0                                                                                 
    TOTAL_LOADS                       = 0                                                                                 

  ================================================================================
  Part 2 - Application performance drill down                                                                             

  Application performance database-wide                                                                                   
  --------------------------------------------------------------------------------
  TOTAL_CPU_TIME          TOTAL_       TOTAL_APP_     ROWS_READ +                                                         
  per request             WAIT_TIME %  COMMITS        ROWS_MODIFIED                                                      
  ----------------------  -----------  -------------  ----------------------------
  180                     0            2569           31102                                                               

  Application performance by connection                                                                                   
  --------------------------------------------------------------------------------
  APPLICATION_   TOTAL_CPU_TIME        TOTAL_         TOTAL_APP_     ROWS_READ +                                          
  HANDLE         per request           WAIT_TIME %    COMMITS        ROWS_MODIFIED
  -------------  -------------------   -----------    -------------  -------------
  110            0                     0              0              0                                                   
  208            34                    70             113            1017                                                
  210            0                     0              0              0                                                   
  460            26                    11             60             0                                                   
  461            0                     0              0              0                                                   
  462            0                     0              0              0                                                   
  463            0                     0              0              0                                                   
  464            0                     0              0              0                                                   
  465            0                     0              0              0                                                   
  466            0                     0              0              0                                                   
  467            0                     0              0              0                                                   
  468            0                     0              0              0                                                   
  469            0                     0              0              0                                                   
  470            0                     0              0              0                                                   
  471            0                     0              0              0                                                   
  472            0                     0              0              0                                                   
  473            0                     0              0              0                                                   
  475            0                     0              0              0                                                   
  480            0                     0              0              0                                                   
  481            0                     0              0              0                                                   
  501            0                     0              0              0                                                   
  656            0                     0              0              0                                                   
  674            0                     0              0              0                                                   
  678            269                   5              2              246                                                  
  680            0                     0              0              0                                                   
  701            0                     0              0              0                                                   
  719            108                   9              23             394                                                  
  741            0                     0              0              0                                                   
  742            0                     0              0              0                                                   
  743            0                     0              0              0                                                   
  744            0                     0              0              0                                                   
  745            0                     0              0              0                                                   
  746            0                     0              0              0                                                   
  747            0                     0              0              0                                                   
  748            0                     0              0              0                                                   
  750            0                     0              0              0                                                   
  751            0                     0              0              0                                                   
  756            368                   8              1              4121                                                
  760            252                   6              2              12                                                   
  1206           0                     0              0              0                                                   
  5199           0                     0              0              0                                                   
  5478           0                     0              0              0                                                   
  35881          0                     0              0              0                                                   
  39057          0                     0              0              0                                                   
  39059          0                     0              0              0                                                   
  39112          0                     0              0              0                                                   
  39138          0                     0              0              0                                                   
  39144          0                     0              0              0                                                   
  39157          0                     0              0              0                                                   
  39159          0                     0              0              0                                                   
  39161          0                     0              0              0                                                   
  39185          0                     0              0              0                                                   
  39361          0                     0              0              0                                                   
  50546          128                   56             152            698                                                  
  51964          64                    14             119            1                                                   

  Application performance by service class                                                                                
  --------------------------------------------------------------------------------
  SERVICE_       TOTAL_CPU_TIME        TOTAL_         TOTAL_APP_     ROWS_READ +                                          
  CLASS_ID       per request           WAIT_TIME %    COMMITS        ROWS_MODIFIED
  --------       -------------------   -----------    -------------  -------------
  11             0                     0              0              0                                                   
  12             20                    36             16             4371                                                
  13             184                   0              2553           26776                                                

  Application performance by workload                                                                                    
  --------------------------------------------------------------------------------
  WORKLOAD_      TOTAL_CPU_TIME          TOTAL_       TOTAL_APP_     ROWS_READ +                                          
  NAME           per request             WAIT_TIME %  COMMITS        ROWS_MODIFIED
  -------------  ----------------------  -----------  -------------  -------------
  SYSDEFAULTADM  0                       0            0              0                                                   
  SYSDEFAULTUSE  247                     0            2553           26776                                                

  ================================================================================
  Part 3 - Member level information                                                                                       

  - I/O wait time is                                                                                                      
    (POOL_READ_TIME + POOL_WRITE_TIME + DIRECT_READ_TIME + DIRECT_WRITE_TIME).                                            

          TOTAL_CPU_TIME          TOTAL_       RQSTS_COMPLETED_  I/O                                                      
  MEMBER  per request             WAIT_TIME %  TOTAL             wait time                                                
  ------  ----------------------  -----------  ----------------  -----------------
  0       182                     0            14885             823                                                      


  280 record(s) selected.

  Return Status = 0
[tsminst1@prod-tsm01 ~]$收起
IT咨询服务 · 2014-03-27
浏览2135
hchaohchao  网站运营经理 , TWT
非常不错,也加金币鼓励。大家有这种脚本,也欢迎一起分享。显示全部
非常不错,也加金币鼓励。

大家有这种脚本,也欢迎一起分享。收起
互联网服务 · 2014-03-21
浏览2461
FelixFelix  数据仓库工程师 , 亚信联创科技(北京)有限公司
做事的方式值得推崇,赞一个!显示全部
做事的方式值得推崇,赞一个!收起
软件开发 · 2014-03-21
浏览2503
jeffbeckjeffbeck  数据库管理员 , 某银行
很不错的脚本,学习了显示全部
很不错的脚本,学习了收起
银行 · 2014-03-21
浏览2469
zllhczllhc  项目经理 , 王强
不错支持原创!excel这边不太会 要不和你一起弄!显示全部
不错支持原创!excel这边不太会 要不和你一起弄!收起
互联网服务 · 2014-03-21
浏览2470
mytribalmytribal  数据库管理员 , DB2
导出的TXT文件怎么通过图表文件展现的?显示全部

导出的TXT文件怎么通过图表文件展现的?

收起
互联网服务 · 2015-11-20
浏览4555

提问者

taylor840326
数据库管理员中国百盛集团

相关问题

相关资料

相关文章

问题状态

  • 发布时间:2014-03-21
  • 关注会员:14 人
  • 问题浏览:126410
  • 最近回答:2021-02-24
  • X社区推广