monitor.py 文件源码

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

项目:docklet 作者: unias 项目源码 文件源码
def net_billings(self, username, now_bytes_total):
        global monitor_vnodes
        if not username in self.net_lastbillings.keys():
            self.net_lastbillings[username] = 0
        elif int(now_bytes_total/self.bytes_per_beans) < self.net_lastbillings[username]:
            self.net_lastbillings[username] = 0
        diff = int(now_bytes_total/self.bytes_per_beans) - self.net_lastbillings[username]
        if diff > 0:
            auth_key = env.getenv('AUTH_KEY')
            data = {"owner_name":username,"billing":diff, "auth_key":auth_key}
            header = {'Content-Type':'application/x-www-form-urlencoded'}
            http = Http()
            [resp,content] = http.request("http://"+self.master_ip+"/billing/beans/","POST",urlencode(data),headers = header)
            logger.info("response from master:"+content.decode('utf-8'))
        self.net_lastbillings[username] += diff
        monitor_vnodes[username]['net_stats']['net_billings'] = self.net_lastbillings[username]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号