Skip to content

Commit

Permalink
fix system_info.py for RAM usage
Browse files Browse the repository at this point in the history
  • Loading branch information
Frix-x authored Jan 6, 2025
2 parents 635d62a + 49a9086 commit a1201ca
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scripts/system_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
###### BASIC SYSTEM INFO SCRIPT ######
######################################
# Written by Frix_x#0161 #
# @version: 1.0
# @version: 1.1

# CHANGELOG:
# v1.0: first version of the script to get some system info printed in the klippy.log
# v1.1: fix get_ram_info, Fixed an issue where Available RAM was displayed in "Used RAM".


# Be sure to make this script executable using SSH: type 'chmod +x ./system_info.py' when in the folder !
Expand Down Expand Up @@ -72,8 +73,8 @@ def get_os_kernel_info():
def get_ram_info():
try:
total_ram = subprocess.check_output(['free', '-m'], universal_newlines=True).split('\n')[1].split()[1]
available_ram = subprocess.check_output(['free', '-m'], universal_newlines=True).split('\n')[1].split()[6]
return total_ram, available_ram
used_ram = subprocess.check_output(['free', '-m'], universal_newlines=True).split('\n')[1].split()[2]
return total_ram, used_ram
except subprocess.CalledProcessError:
return None, None

Expand Down Expand Up @@ -112,12 +113,13 @@ def print_system_info():
print(f"System information: {get_unknown_board_info()}")


total_ram, available_ram = future_ram_info.result()
if total_ram is None or available_ram is None:
total_ram, used_ram = future_ram_info.result()
if total_ram is None or used_ram is None:
print("RAM information not found...")
else:
print(f"Used RAM: {available_ram}/{total_ram} MB")
print(f"Used RAM: {used_ram}/{total_ram} MB")


if __name__ == "__main__":
print_system_info()

0 comments on commit a1201ca

Please sign in to comment.