Browse Source

Use Mb/s as basic connection speed unit

check-vt100
Aleksander Kiryk 3 years ago
parent
commit
e2c08a1f25
  1. 2
      common.py
  2. 8
      graph.py
  3. 12
      watch.py

2
common.py

@ -19,7 +19,7 @@ SARGRAPH_VERSION = "2.2.1"
# Define units for use with unit_str
TIME_UNITS = ['seconds', 'minutes', 'hours']
DATA_UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB']
SPEED_UNITS = ['Mb/s', 'Gb/s', 'Tb/s', 'Pb/s']
# Print an error message and exit with non-zero status
def fail(msg):

8
graph.py

@ -207,8 +207,8 @@ def read_comments(session):
TOTAL_FS = unit_str(TOTAL_FS, DATA_UNITS)
MAX_USED_FS = unit_str(MAX_USED_FS, DATA_UNITS)
MAX_RX = unit_str(MAX_RX, DATA_UNITS)
MAX_TX = unit_str(MAX_TX, DATA_UNITS)
MAX_RX = unit_str(MAX_RX, SPEED_UNITS)
MAX_TX = unit_str(MAX_TX, SPEED_UNITS)
DURATION = unit_str(DURATION, TIME_UNITS, 60)
@ -346,9 +346,9 @@ def graph(session, fname='plot'):
# Set scale for plots displayed in absolute units
plot(f"{NAME_IFACE} received (B/s)", f"{NAME_IFACE} data received (max = {MAX_RX}/s)",
plot(f"{NAME_IFACE} received (Mb/s)", f"{NAME_IFACE} data received (max = {MAX_RX})",
session, 5, space=space, autoscale=1.2)
plot(f"{NAME_IFACE} sent (B/s)", f"{NAME_IFACE} data sent (max = {MAX_TX}/s)",
plot(f"{NAME_IFACE} sent (Mb/s)", f"{NAME_IFACE} data sent (max = {MAX_TX})",
session, 6, space=space, autoscale=1.2)
g("unset multiplot")

12
watch.py

@ -114,8 +114,8 @@ def summarize(session):
total_ram = TOTAL_RAM * 1024.0
max_used_fs = MAX_USED_FS * 1024.0 * 1024.0
total_fs = TOTAL_FS * 1024 * 1024
max_tx = MAX_TX * 1024
max_rx = MAX_RX * 1024
max_tx = MAX_TX / 128 # kB/s to Mb/s
max_rx = MAX_RX / 128 # kB/s to Mb/s
sdt = datetime.datetime.strptime(START_DATE, '%Y-%m-%d %H:%M:%S')
edt = datetime.datetime.strptime(END_DATE, '%Y-%m-%d %H:%M:%S')
@ -128,8 +128,8 @@ def summarize(session):
f"max disk used: {max_used_fs:.2f} B",
f"average load: {average_load:.2f} %",
f"observed disk: {FS_NAME}",
f"max data received: {max_rx:.2f} B",
f"max data sent: {max_tx:.2f} B",
f"max data received: {max_rx:.2f} Mb/s",
f"max data sent: {max_tx:.2f} Mb/s",
f"observed network: {IFACE_NAME}",
f"duration: {delta_t} seconds",
sep=", ", file=f)
@ -277,8 +277,8 @@ def watch(session, fsdev, iface):
cpu_data['%user'][0],
ram_data['%memused'][0],
fs_data['%fsused'][FS_SAR_INDEX],
stof(net_data['rxkB/s'][IFACE_SAR_INDEX])*1024,
stof(net_data['txkB/s'][IFACE_SAR_INDEX])*1024,
stof(net_data['rxkB/s'][IFACE_SAR_INDEX])/128, # kB/s to Mb/s
stof(net_data['txkB/s'][IFACE_SAR_INDEX])/128, # kB/s to Mb/s
file=f)
if die:

Loading…
Cancel
Save