zoukankan      html  css  js  c++  java
  • python分包存放java堆栈信息

    # coding=utf-8
    import os
    import time
    
    path = os.getcwd()
    index = 0
    
    while True:
        
        # 当前时间戳
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
        
        # java堆栈
        jstack = os.popen('/mnt/jdk8/bin/jstack 30668').read()
        
        # 第一个堆栈文件
        fp = path + '/jstack' + str(index) + '.log'
       
        # 将java堆栈写入文件
        with open(fp, 'a+') as f:
            f.write(timestamp + '
    ' + jstack + '
    ')
        
        # 判断存放堆栈文件大小以,大于100M后分包
        fs = round(os.path.getsize(fp)/float(1024*1024), 2)
        if fs >= 100:
            index += 1
    
        time.sleep(1)
  • 相关阅读:
    ➡️➡️➡️IELTS reading by Simon on Bili
    lc0502
    lc0331
    lc0329
    lc0327
    lc0326
    lc0324
    lc0320
    lc0319
    lc0316
  • 原文地址:https://www.cnblogs.com/FengZiQ/p/13088235.html
Copyright © 2011-2022 走看看