zoukankan      html  css  js  c++  java
  • A python tool to static sim.log duration time

    When working ALU IMS Patch team, we need to static the SU duration to add it to the patch report, the duration time alway is hard work, so I write the follow tool to auto do this work.

     1 #!/usr/bin/python2.6
     2 import re,datetime
     3 file_name='/home/alzhong/logs/qtat1/R2860.01.13/sim-applycommitrollback-bld1.log'
     4 file=open(file_name,'r')
     5 acnum=[];time_res=[];lnum=0
     6 def trans_time(time):
     7     t1=datetime.datetime.strptime(time,'%y/%m/%d %H:%M:%S')
     8     return t1
     9 for (num,line) in enumerate(file):
    10 
    11     if(re.search(r'^(.*)BEGINNING SIM PROCEDURE(.*)$',line)):
    12         m=re.search(r'^(.*)BEGINNING SIM PROCEDURE(.*)$',line)
    13         print 'Step %d:'%(lnum), m.group(0);lnum+=1
    14         acnum.append(trans_time(line[0:17]))
    15     elif(re.search(r'^(.*)CP_W(.*)$', line)):
    16         m=re.search(r'^(.*)CP_W(.*)$', line)
    17         print 'Step %d:'%(lnum), m.group(0);lnum+=1
    18         acnum.append(trans_time(line[0:17]))
    19     elif(re.search(r"^(.*)VERIFY_S(.*)$", line)):
    20         m=re.search(r"^(.*)VERIFY_S(.*)$", line)
    21         print 'Step %d:'%(lnum), m.group(0);lnum+=1
    22         acnum.append(trans_time(line[0:17]))
    23     elif(re.search(r"^(.*)--action commit(.*)$",line)):
    24         m=re.search(r"^(.*)--action commit(.*)$",line)
    25         print 'Step %d:'%(lnum), m.group(0);lnum+=1
    26         acnum.append(trans_time(line[0:17]))
    27     elif(re.search(r"^(.*)COMPLETED SIM PROCEDURE(.*)$",line)):
    28         m=re.search(r"^(.*)COMPLETED SIM PROCEDURE(.*)$",line)
    29         print 'Step %d:'%(lnum), m.group(0);lnum+=1
    30         acnum.append(trans_time(line[0:17]))
    31     elif(re.search(r"^(.*)RESUMING SIM PROCEDURE(.*)$",line)):
    32         m=re.search(r"^(.*)RESUMING SIM PROCEDURE(.*)$",line)
    33         print 'Step %d:'%(lnum), m.group(0);lnum+=1
    34         acnum.append(trans_time(line[0:17]))
    35 
    36 file.close()
    37 if(re.search(r"^(.*)backout(.*)$",file_name)):
    38     time_res.append((acnum[2]-acnum[0]).seconds/60)
    39     time_res.append((acnum[4]-acnum[3]).seconds/60)
    40     time_res.append((acnum[6]-acnum[5]).seconds/60)
    41     time_res.append(((acnum[8]-acnum[7])+(acnum[10]-acnum[9])+(acnum[13]-acnum[11])).seconds/60)
    42     print "
    3). sim --proc update --action apply to "CP_WARNING" %s mins" %(time_res[0])
    43     print "4). sim --proc update --action resume to  "VERIFY_SOFTWARE" %s mins"%(time_res[1])
    44     print "5). sim --proc update --action resume to  "COMMIT" %s mins"%(time_res[2])
    45     print "8). Backout from RXX to RXX  %s mins"%(time_res[3])
    46 elif(re.search(r"^(.*)rollback(.*)$",file_name)):
    47     time_res.append((acnum[2]-acnum[0]).seconds/60)
    48     time_res.append((acnum[4]-acnum[3]).seconds/60)
    49     time_res.append((acnum[6]-acnum[5]).seconds/60)
    50     time_res.append((acnum[8]-acnum[7]).seconds/60)
    51     time_res.append(((acnum[10]-acnum[9])+(acnum[12]-acnum[11])+(acnum[15]-acnum[13])).seconds/60)
    52     print "
    3). sim --proc update --action apply to "CP_WARNING" %s mins" %(time_res[0])
    53     print "4). sim --proc update --action resume to  "VERIFY_SOFTWARE" %s mins"%(time_res[1])
    54     print "5). sim --proc update --action resume to  "COMMIT" %s mins"%(time_res[2])
    55     print "6). sim --proc update --action commit to end of Patch %s mins"%(time_res[3])
    56     print "8). Rollback from RXX to RXX %s mins" %(time_res[4])
    57 if __name__ == '__main__':
    58     pass
    

    The output of the script as follows:

    <lsslogin1-alzhong>/home/alzhong/tools: ls
    simt
    <lsslogin1-alzhong>/home/alzhong/tools: ./simt
    Step 0: 14/06/16 12:31:32 BEGINNING SIM PROCEDURE 'update apply' type=hot ...
    Step 1: 14/06/16 13:18:42 RESUMING SIM PROCEDURE 'update apply' type=hot ...
    Step 2: 14/06/16 13:30:43 SIM0317 PAUSE_REQUEST: (PROCEDURE) [PAUSE(CP_WARNING): Use 'sim --proc update --action resume' to continue...] (update:1435)
    Step 3: 14/06/16 13:43:40 RESUMING SIM PROCEDURE 'update apply' type=hot ...
    Step 4: 14/06/16 13:47:49 SIM0343 PAUSE_REQUEST: (PROCEDURE) [PAUSE(VERIFY_SOFTWARE): Use 'sim --proc update --action resume' to continue...] (update:1634)
    Step 5: 14/06/16 13:54:26 RESUMING SIM PROCEDURE 'update apply' type=hot ...
    Step 6: 14/06/16 14:25:41 SIM0496 PAUSE_REQUEST: (COMMIT) [PAUSE(COMMIT): Use 'sim --proc update --action commit' to continue...] (update:2579)
    Step 7: 14/06/16 14:41:51 RESUMING SIM PROCEDURE 'update commit' type=hot ...
    Step 8: 14/06/16 15:18:34 COMPLETED SIM PROCEDURE 'update commit' type=hot
    Step 9: 14/06/16 15:31:35 BEGINNING SIM PROCEDURE 'update rollback' type=hot level=9999 ...
    Step 10: 14/06/16 15:47:34 SIM0091 PAUSE_REQUEST: (PROCEDURE) [PAUSE(CP_WARNING): Use 'sim --proc update --action resume' to continue...] (update_rlbk:421)
    Step 11: 14/06/16 15:53:30 RESUMING SIM PROCEDURE 'update rollback' type=hot level=9999 ...
    Step 12: 14/06/16 16:02:03 SIM0135 PAUSE_REQUEST: (PROCEDURE) [PAUSE(VERIFY_SOFTWARE): Use 'sim --proc update --action resume' to continue...] (update_rlbk:564)
    Step 13: 14/06/16 16:04:22 RESUMING SIM PROCEDURE 'update rollback' type=hot level=9999 ...
    Step 14: 14/06/16 16:09:42 RESUMING SIM PROCEDURE 'update rollback' type=hot level=9999 ...
    Step 15: 14/06/16 16:26:56 COMPLETED SIM PROCEDURE 'update rollback' type=hot level=9999
    
    3). sim --proc update --action apply to "CP_WARNING" 59 mins
    4). sim --proc update --action resume to  "VERIFY_SOFTWARE" 4 mins
    5). sim --proc update --action resume to  "COMMIT" 31 mins
    6). sim --proc update --action commit to end of Patch 36 mins
    8). Rollback from RXX to RXX 47 mins
  • 相关阅读:
    SQL Server 数据库部分常用语句小结(三)
    SQL Server 数据库部分常用语句小结(四)
    通过存储过程(SP)实现SQL Server链接服务器(LinkServer)的添加
    pcb布线强弱电间隔距离
    程序占用内存大小
    Offer来了(原理篇)笔记之第三章并发编程
    Offer来了(原理篇)笔记之第一章JVM原理
    西瓜视频奇妙的bug
    mongodb忘记了admin的账号密码
    MongoDB更改默认端口
  • 原文地址:https://www.cnblogs.com/allenz/p/4755974.html
Copyright © 2011-2022 走看看