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.

 #!/usr/bin/python2.6
 import re,datetime
 file_name='/home/alzhong/logs/qtat1/R2860.01.13/sim-applycommitrollback-bld1.log'
 file=open(file_name,'r')
 acnum=[];time_res=[];lnum=0
 def trans_time(time):
     t1=datetime.datetime.strptime(time,'%y/%m/%d %H:%M:%S')
     return t1
 for (num,line) in enumerate(file):

     if(re.search(r'^(.*)BEGINNING SIM PROCEDURE(.*)$',line)):
         m=re.search(r'^(.*)BEGINNING SIM PROCEDURE(.*)$',line)
         print 'Step %d:'%(lnum), m.group(0);lnum+=1
         acnum.append(trans_time(line[0:17]))
     elif(re.search(r'^(.*)CP_W(.*)$', line)):
         m=re.search(r'^(.*)CP_W(.*)$', line)
         print 'Step %d:'%(lnum), m.group(0);lnum+=1
         acnum.append(trans_time(line[0:17]))
     elif(re.search(r"^(.*)VERIFY_S(.*)$", line)):
         m=re.search(r"^(.*)VERIFY_S(.*)$", line)
         print 'Step %d:'%(lnum), m.group(0);lnum+=1
         acnum.append(trans_time(line[0:17]))
     elif(re.search(r"^(.*)--action commit(.*)$",line)):
         m=re.search(r"^(.*)--action commit(.*)$",line)
         print 'Step %d:'%(lnum), m.group(0);lnum+=1
         acnum.append(trans_time(line[0:17]))
     elif(re.search(r"^(.*)COMPLETED SIM PROCEDURE(.*)$",line)):
         m=re.search(r"^(.*)COMPLETED SIM PROCEDURE(.*)$",line)
         print 'Step %d:'%(lnum), m.group(0);lnum+=1
         acnum.append(trans_time(line[0:17]))
     elif(re.search(r"^(.*)RESUMING SIM PROCEDURE(.*)$",line)):
         m=re.search(r"^(.*)RESUMING SIM PROCEDURE(.*)$",line)
         print 'Step %d:'%(lnum), m.group(0);lnum+=1
         acnum.append(trans_time(line[0:17]))

 file.close()
 if(re.search(r"^(.*)backout(.*)$",file_name)):
     time_res.append((acnum[2]-acnum[0]).seconds/60)
     time_res.append((acnum[4]-acnum[3]).seconds/60)
     time_res.append((acnum[6]-acnum[5]).seconds/60)
     time_res.append(((acnum[8]-acnum[7])+(acnum[10]-acnum[9])+(acnum[13]-acnum[11])).seconds/60)
     print "\n3). sim --proc update --action apply to \"CP_WARNING\" %s mins" %(time_res[0])
     print "4). sim --proc update --action resume to  \"VERIFY_SOFTWARE\" %s mins"%(time_res[1])
     print "5). sim --proc update --action resume to  \"COMMIT\" %s mins"%(time_res[2])
     print "8). Backout from RXX to RXX  %s mins"%(time_res[3])
 elif(re.search(r"^(.*)rollback(.*)$",file_name)):
     time_res.append((acnum[2]-acnum[0]).seconds/60)
     time_res.append((acnum[4]-acnum[3]).seconds/60)
     time_res.append((acnum[6]-acnum[5]).seconds/60)
     time_res.append((acnum[8]-acnum[7]).seconds/60)
     time_res.append(((acnum[10]-acnum[9])+(acnum[12]-acnum[11])+(acnum[15]-acnum[13])).seconds/60)
     print "\n3). sim --proc update --action apply to \"CP_WARNING\" %s mins" %(time_res[0])
     print "4). sim --proc update --action resume to  \"VERIFY_SOFTWARE\" %s mins"%(time_res[1])
     print "5). sim --proc update --action resume to  \"COMMIT\" %s mins"%(time_res[2])
     print "6). sim --proc update --action commit to end of Patch %s mins"%(time_res[3])
     print "8). Rollback from RXX to RXX %s mins" %(time_res[4])
 if __name__ == '__main__':
     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

A python tool to static sim.log duration time的更多相关文章

  1. Python Tool Visual Studio简单使用

    由于一直在做.NET的开发,一直用的IDE是VS系列的,所以想用VS也能开发Python,刚好微软提供一个插件PTVS(Python Tool Visual Studio)专门应用于Python开发的 ...

  2. hadoop 多表join:Map side join及Reduce side join范例

    最近在准备抽取数据的工作.有一个id集合200多M,要从另一个500GB的数据集合中抽取出所有id集合中包含的数据集.id数据集合中每一个行就是一个id的字符串(Reduce side join要在每 ...

  3. hadoop编程技巧(4)---总体情况key按类别搜索TotalOrderPartitioner

    Hadoop代码测试版:Hadoop2.4 原理:携带MR该程序随机抽样提取前的输入数据,样本分类,然后,MR该过程的中间Partition此值用于当样品排序分组数据.这使得可以实现全球排名的目的. ...

  4. 利用python 提取log 文件里的关键句子,并进行统计分析

    利用python开发了一个提取sim.log 中的各个关键步骤中的时间并进行统计的程序: #!/usr/bin/python2.6 import re,datetime file_name='/hom ...

  5. Android log 管理工具

    1.logger 项目地址: https://github.com/orhanobut/logger 2.KLog 项目地址:https://github.com/ZhaoKaiQiang/KLog ...

  6. python Web开发框架-Django (2)

    接上篇文章,介绍一些实用的技巧和注意点.首次用MarkDown编辑,感觉行空隙太大,不是那么好看. GET/POST 前后端会有数据交互,使用JQuery来实现get/post请求 GET 方法1:通 ...

  7. Embeding Python &amp; Extending Python with FFPython

    Introduction ffpython is a C++ lib, which is to simplify tasks that embed Python and extend Python. ...

  8. Storm(2) - Log Stream Processing

    Introduction This chapter will present an implementation recipe for an enterprise log storage and a ...

  9. Top free and open source log management software

    As mentioned in the previous post, in my quest to find an alternative to Kiwi Syslog, I looked at a ...

随机推荐

  1. String常用方法测试

    String.Equals()使用方法 用来比较String两个对象所表示的字符串是否相同 public class StringEquals { public static void main(St ...

  2. 基于时间延迟的Python验证脚本

    自己写的一段Python脚本,经常拿来验证一些sqlmap等工具跑不出数据的网站. GET类型: import urllib import urllib2 import time payloads = ...

  3. Hot OS&#39;15 summary

    My OS Ought to Know Me Better: In-app Behavioural Analytics as an OS Service   Earlence Fernandes, U ...

  4. echarts 各种细节问题

    1.最大值最小值异常 //如果数组中的数字是字符串的形式的话,echarts计算最大最小值不正确,故将String的数字转化成Number类型 //将包含字符串的数组转化为浮点数数组 function ...

  5. 8.实现(Realization)

    实现关系是用来描述接口和实现接口的类或者构建结构之间的关系,接口是操作的集合,而这些操作就用于规定类或者构建结构的一种服务. 在接口和类之间的实现关系中,类实现了接口,类中的操作实现了接口中所声明的操 ...

  6. log4net日志文件名输出格式化

    日志文件输出格式: 20130626.txt20130627.txt20130628.txt20130629.txt <appender name="rolling" typ ...

  7. How does database indexing work?

    When data is stored on disk based storage devices, it is stored as blocks of data. These blocks are ...

  8. BZOJ 1600: [Usaco2008 Oct]建造栅栏

    1600: [Usaco2008 Oct]建造栅栏 Time Limit: 5 Sec  Memory Limit: 64 MB Description 勤奋的Farmer John想要建造一个四面的 ...

  9. (六)unity4.6Ugui中国教程文档-------概要-UGUI Animation Integration

     大家好,我是太阳广东.   转载请注明出处:http://write.blog.csdn.net/postedit/38922399 更全的内容请看我的游戏蛮牛地址:mod=guide& ...

  10. 用vue官方提供的模板vue-cli搭建一个helloWorld案例

    安装环境 安装node.js并配置环境变量 安装淘宝镜像,npm install -g cnpm --registry=https://registry.npm.taobao.org 安装webpac ...