Browse Source

Save all values in bytes and seconds

check-vt100
Aleksander Kiryk 4 years ago
parent
commit
24d8688666
  1. 24
      watch.py

24
watch.py

@ -74,7 +74,7 @@ def initialize(session, machine):
global TOTAL_RAM
with open("/proc/meminfo") as f:
TOTAL_RAM = int(scan("MemTotal:\s+(\d+)", float, f.read())/1024/1024)
TOTAL_RAM = int(scan("MemTotal:\s+(\d+)", float, f.read()))
uname = machine.split(" ")[0:2]
uname = f"{uname[0]} {uname[1]}"
@ -105,21 +105,23 @@ def summarize(session):
return
average_load = TOTAL_LOAD / float(SAMPLE_NUMBER)
max_used_ram = MAX_USED_RAM / 1024.0 / 1024.0
max_used_fs = MAX_USED_FS / 1024.0
max_used_ram = MAX_USED_RAM * 1024.0
total_ram = TOTAL_RAM * 1024.0
max_used_fs = MAX_USED_FS * 1024.0 * 1024.0
total_fs = TOTAL_FS * 1024 * 1024
sdt = datetime.datetime.strptime(START_DATE, '%Y-%m-%d %H:%M:%S')
edt = datetime.datetime.strptime(END_DATE, '%Y-%m-%d %H:%M:%S')
delta_t = ((edt - sdt).total_seconds()) / 60.0
delta_t = (edt - sdt).total_seconds()
with open(f"{session}.txt", "a") as f:
print(f"# total ram: {TOTAL_RAM:.2f} GB",
f"total disk space: {TOTAL_FS:.2f} GB",
f"max ram used: {max_used_ram:.2f} GB",
f"max disk used: {max_used_fs:.2f} GB",
print(f"# total ram: {total_ram:.2f} B",
f"total disk space: {total_fs:.2f} B",
f"max ram used: {max_used_ram:.2f} B",
f"max disk used: {max_used_fs:.2f} B",
f"average load: {average_load:.2f} %",
f"observed disk: {FS_NAME}",
f"duration: {delta_t:.2f} minutes",
f"duration: {delta_t} seconds",
sep=", ", file=f)
@ -209,7 +211,7 @@ def watch(session, fsdev):
# Read and process RAM data
ram_data = read_table(p.stdout)
if TOTAL_RAM == 0:
TOTAL_RAM = (int(ram_data['kbmemused'][0]) + int(ram_data['kbmemfree'][0])) / 1024.0 / 1024.0
TOTAL_RAM = (int(ram_data['kbmemused'][0]) + int(ram_data['kbmemfree'][0]))
if MAX_USED_RAM < int(ram_data['kbmemused'][0]):
MAX_USED_RAM = int(ram_data['kbmemused'][0])
@ -228,7 +230,7 @@ def watch(session, fsdev):
if FS_NAME is None:
FS_NAME = fs_data["FILESYSTEM"][FS_SAR_INDEX]
if TOTAL_FS == 0:
TOTAL_FS = (stof(fs_data['MBfsused'][FS_SAR_INDEX]) + stof(fs_data['MBfsfree'][FS_SAR_INDEX])) / 1024.0
TOTAL_FS = (stof(fs_data['MBfsused'][FS_SAR_INDEX]) + stof(fs_data['MBfsfree'][FS_SAR_INDEX]))
if MAX_USED_FS < int(fs_data['MBfsused'][FS_SAR_INDEX]):
MAX_USED_FS = int(fs_data['MBfsused'][FS_SAR_INDEX])

Loading…
Cancel
Save