Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

change to KB

  • Loading branch information...
commit 8cfa898201bf6ecc509152a2e4fe5b2aa5198519 1 parent f1dbb53
@hokerffb hokerffb authored
Showing with 7 additions and 7 deletions.
  1. +7 −7 kanyun/worker/plugin_traffic_accounting.py
View
14 kanyun/worker/plugin_traffic_accounting.py
@@ -65,7 +65,7 @@ def get_hostname():
def get_traffic_accounting_info():
"""
- return value format example:
+ return value format example:{'key': ('ip', time, KB)}
{'116@swsdevp': ('10.0.0.95', 1334555143, '0')}
"""
@@ -81,21 +81,21 @@ def get_traffic_accounting_info():
instance_id = record.split()[9] + hostname
instance_ip = record.split()[10]
- val = int(out_bytes)
+ val = float(out_bytes)
global _ip_bytes
if instance_id in _ip_bytes:
prev_out_bytes = _ip_bytes[instance_id]
- val = int(out_bytes) - prev_out_bytes
+ val = float(out_bytes) - prev_out_bytes
if val < 0:
- val = int(out_bytes)
+ val = float(out_bytes)
else:
- val = int(out_bytes)
+ val = float(out_bytes)
- _ip_bytes[instance_id] = int(out_bytes)
+ _ip_bytes[instance_id] = float(out_bytes)
- ret[instance_id] = (instance_ip, int(time.time()), str(val))
+ ret[instance_id] = (instance_ip, int(time.time()), str(val / 1024))
return ret
Please sign in to comment.
Something went wrong with that request. Please try again.