discover.py 文件源码

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

项目:docker-monitoring-zabbix-agent 作者: digiapulssi 项目源码 文件源码
def uptime(args):
    with os.popen("docker inspect -f '{{json .State}}' " + args.container + " 2>&1") as pipe:
        status = pipe.read().strip()
    if "No such image or container" in status:
        print "0"
    else:
        statusjs = json.loads(status)
        if statusjs["Running"]:
            uptime = statusjs["StartedAt"]
            start = time.strptime(uptime[:19], "%Y-%m-%dT%H:%M:%S")
            print int(time.time() - time.mktime(start))
        else:
            print "0"

# get the approximate disk usage
# alt docker inspect -s -f {{.SizeRootFs}} 49219085bdaa
# alt docker exec " + args.container + " du -s -b / 2> /dev/null
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号