@@ -66,9 +66,10 @@ def get_hdd():
66
66
return int (size / 1024.0 / 1024.0 ), int (used / 1024.0 / 1024.0 )
67
67
68
68
69
- def get_cpu ():
69
+ def get_cpu (options ):
70
70
# blocking
71
- return psutil .cpu_percent (interval = INTERVAL )
71
+ # return psutil.cpu_percent(interval=INTERVAL)
72
+ return psutil .cpu_percent (interval = int (options .interval ))
72
73
73
74
74
75
def get_sys_traffic (options ):
@@ -283,7 +284,7 @@ def byte_str(object):
283
284
284
285
285
286
def sample (options , stat_base ):
286
- cpu_percent = int (get_cpu ())
287
+ cpu_percent = int (get_cpu (options ))
287
288
uptime = get_uptime ()
288
289
load_1 , load_5 , load_15 = os .getloadavg (
289
290
) if 'linux' in sys .platform else (0.0 , 0.0 , 0.0 )
@@ -540,6 +541,8 @@ def main():
540
541
parser .add_option ("-e" , "--exclude-iface" , dest = "exclude_iface" ,
541
542
default = "lo,docker,vnet,veth,vmbr,kube,br-" ,
542
543
help = "exclude iface [default: %default]" )
544
+ parser .add_option ("--interval" , dest = "interval" ,
545
+ default = 1 , help = "report interval [default: %default]" )
543
546
544
547
(options , args ) = parser .parse_args ()
545
548
0 commit comments