Skip to content

Commit 6f7b74f

Browse files
committed
Supported report interval
1 parent 71b363d commit 6f7b74f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

client/stat_client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ def get_hdd():
6666
return int(size / 1024.0 / 1024.0), int(used / 1024.0 / 1024.0)
6767

6868

69-
def get_cpu():
69+
def get_cpu(options):
7070
# blocking
71-
return psutil.cpu_percent(interval=INTERVAL)
71+
# return psutil.cpu_percent(interval=INTERVAL)
72+
return psutil.cpu_percent(interval=int(options.interval))
7273

7374

7475
def get_sys_traffic(options):
@@ -283,7 +284,7 @@ def byte_str(object):
283284

284285

285286
def sample(options, stat_base):
286-
cpu_percent = int(get_cpu())
287+
cpu_percent = int(get_cpu(options))
287288
uptime = get_uptime()
288289
load_1, load_5, load_15 = os.getloadavg(
289290
) if 'linux' in sys.platform else (0.0, 0.0, 0.0)
@@ -540,6 +541,8 @@ def main():
540541
parser.add_option("-e", "--exclude-iface", dest="exclude_iface",
541542
default="lo,docker,vnet,veth,vmbr,kube,br-",
542543
help="exclude iface [default: %default]")
544+
parser.add_option("--interval", dest="interval",
545+
default=1, help="report interval [default: %default]")
543546

544547
(options, args) = parser.parse_args()
545548

0 commit comments

Comments
 (0)