Skip to content

Instantly share code, notes, and snippets.

@rom1504
Last active July 25, 2022 17:59
Show Gist options
  • Save rom1504/b8797ff2379d06f738831e049c5575d7 to your computer and use it in GitHub Desktop.
Save rom1504/b8797ff2379d06f738831e049c5575d7 to your computer and use it in GitHub Desktop.
monitor_efa_aws.py
from glob import glob
import time
import datetime
def get_read_bytes():
return sum([int(open(f"{p}/ports/1/hw_counters/rdma_read_bytes", "r").read().strip()) for p in glob("/sys/class/infiniband/*")])
from os.path import expanduser
home = expanduser("~")
with open(f"{home}/speed_measure", "a") as f:
while 1:
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
start = get_read_bytes()
time.sleep(1)
end = get_read_bytes()
s = now+"\t"+str((end-start)/(10**9)) + "\t" + "GB/s" + "\n"
f.write(s)
print(s, end='')
f.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment