Skip to content

Commit

Permalink
Supported report interval
Browse files Browse the repository at this point in the history
  • Loading branch information
zdz committed Feb 10, 2023
1 parent 71b363d commit 6f7b74f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions client/stat_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def get_hdd():
return int(size / 1024.0 / 1024.0), int(used / 1024.0 / 1024.0)


def get_cpu():
def get_cpu(options):
# blocking
return psutil.cpu_percent(interval=INTERVAL)
# return psutil.cpu_percent(interval=INTERVAL)
return psutil.cpu_percent(interval=int(options.interval))


def get_sys_traffic(options):
Expand Down Expand Up @@ -283,7 +284,7 @@ def byte_str(object):


def sample(options, stat_base):
cpu_percent = int(get_cpu())
cpu_percent = int(get_cpu(options))
uptime = get_uptime()
load_1, load_5, load_15 = os.getloadavg(
) if 'linux' in sys.platform else (0.0, 0.0, 0.0)
Expand Down Expand Up @@ -540,6 +541,8 @@ def main():
parser.add_option("-e", "--exclude-iface", dest="exclude_iface",
default="lo,docker,vnet,veth,vmbr,kube,br-",
help="exclude iface [default: %default]")
parser.add_option("--interval", dest="interval",
default=1, help="report interval [default: %default]")

(options, args) = parser.parse_args()

Expand Down

0 comments on commit 6f7b74f

Please sign in to comment.