discover.py 文件源码

python
阅读 46 收藏 0 点赞 0 评论 0

项目:docker-monitoring-zabbix-agent 作者: digiapulssi 项目源码 文件源码
def single_stat_update(args, container_dir, filename):

    pipe = os.popen("docker exec " + args.container + " cat " + container_dir + "/" + filename  + " 2>&1")
    for line in pipe:
        stat = line
    pipe.close()
    # test that the docker command succeeded and pipe contained data
    if not 'stat' in locals():
        stat = ""
    try:
        f = open(args.container + "/" + filename,"w")
        f.write(stat)
        f.close()
    except Exception, e:
        if not os.path.isdir(args.container):
            os.mkdir(args.container)
        with open(args.container + "/" + filename, "w") as f:
            f.write(stat)

    return stat

# helper function to gather stat type data (multiple rows of key value pairs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号