zoukankan      html  css  js  c++  java
  • 内存采集

    __author__ = 'Administrator'
    import xlsxwriter  as writer
    import xlrd as read
    import linecache
    import re
    CPUFile='jcc.txt'
    CPUfiles=['jcc.txt','jcc2.txt']
    
    def getKeyline(CPUFile):
        Keyline=0
        fin=open(CPUFile,'r')
        KeyLine=[]
        for num,line in enumerate(fin):
            if "sh 30" in line:
               Keyline=str(num)
               #print "Keyline="+Keyline
            if "pool used size" in line and Keyline>0:
                KeyLine.append(num+1)
            if "T_TREE" in line and Keyline>0:
                KeyLine.append(num+1)
            if "B_TREE" in line and Keyline>0:
                KeyLine.append(num+1)
            if "U_WMCINFO" in line and Keyline>0:
                KeyLine.append(num)
        return KeyLine
    
    def Getkeyword(Filenum,Theline):
        workbook = writer.Workbook('jcc2.xls')
        worksheet = workbook.add_worksheet('Cpuinfo')
        #p=re.compile(r"(:)d+B|( )d+ ")
        print Theline,
    
        if "T_TREE" in Theline:
            p=re.compile(r"(:)d+B")
            for m in p.finditer(Theline):
                print m.group()
                print Filenum
                worksheet.write(Filenum, 2, m.group())
    
        if "B_TREE" in Theline:
            p=re.compile(r"(:)d+B")
            for m in p.finditer(Theline):
                worksheet.write(Filenum, 3, m.group())
    
        if "pool used size" in Theline:
            p=re.compile(r"( )d+ ")
            for m in p.finditer(Theline):
                worksheet.write(Filenum, 1, m.group())
    
        
    
        workbook.close()
    
    
    def main():
        for j in CPUfiles:
            x=1
            for i in getKeyline(j):
                Theline=linecache.getline(j,i)
                Getkeyword(x,Theline)
            x=x+1 #print Theline
    
    if __name__=="__main__":
        main()
  • 相关阅读:
    SQL 查询第n条到第m条的数据
    Linq 中查询一个表中指定的字段
    归并排序与逆序对
    补码拾遗
    堆排序
    It is time to cut the Gordian Knot!
    蛋疼
    [引]Microsoft Visual Studio .NET 2005 预发行版
    关于VS2005中自动生成TableAdapter的事务处理
    关于释放ASPNET进程的内存占用问题.
  • 原文地址:https://www.cnblogs.com/stonerainjc/p/6886598.html
Copyright © 2011-2022 走看看