From be0702c8524208468fbdf4f3f590c1de96c5f7b2 Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Wed, 5 Jun 2024 00:28:05 -0500 Subject: [PATCH] Improve efficiency of gathering drive storage info --- .../var/www/mynode/thread_functions.py | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/rootfs/standard/var/www/mynode/thread_functions.py b/rootfs/standard/var/www/mynode/thread_functions.py index b0ba3f9b..5fa3aa41 100644 --- a/rootfs/standard/var/www/mynode/thread_functions.py +++ b/rootfs/standard/var/www/mynode/thread_functions.py @@ -58,28 +58,32 @@ def update_device_info(): cpu_info = psutil.cpu_times_percent(interval=5.0, percpu=False) cpu_usage = "{:.1f}%".format(100.0 - cpu_info.idle) - # Update every 24 hrs (start at ~5 min) - if device_info_call_count % (60*24) == 5: - os_drive_usage_details = "" - os_drive_usage_details += "" - os_drive_usage_details += "App Storage
" - os_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /opt/mynode/", ignore_failure=True) + "

" - os_drive_usage_details += "User Storage
" - os_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /home/", ignore_failure=True) + "

" - os_drive_usage_details += "Rust Toolchain Storage
" - if os.path.isdir("/root/.cargo/"): - os_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /root/.cargo/", ignore_failure=True) + "

" - if os.path.isdir("/home/admin/.cargo/"): - os_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /home/admin/.cargo/", ignore_failure=True) + "

" - os_drive_usage_details += "
" + # Update every 3 days (72 hrs) (start at ~15 min) + if device_info_call_count % (60*24*3) == 15: + if not os.path.isfile(BITCOIN_SYNCED_FILE): + os_drive_usage_details = "Waiting on Bitcoin sync..." + data_drive_usage_details = "Waiting on Bitcoin sync..." + else: + os_drive_usage_details = "" + os_drive_usage_details += "" + os_drive_usage_details += "App Storage
" + os_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /opt/mynode/", ignore_failure=True) + "

" + os_drive_usage_details += "User Storage
" + os_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /home/", ignore_failure=True) + "

" + os_drive_usage_details += "Rust Toolchain Storage
" + if os.path.isdir("/root/.cargo/"): + os_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /root/.cargo/", ignore_failure=True) + "

" + if os.path.isdir("/home/admin/.cargo/"): + os_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /home/admin/.cargo/", ignore_failure=True) + "

" + os_drive_usage_details += "
" - data_drive_usage_details = "" - data_drive_usage_details += "" - data_drive_usage_details += "Disk Format" - data_drive_usage_details += "

" + get_current_drive_filesystem_type() + "

" - data_drive_usage_details += "Data Storage
" - data_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /mnt/hdd/mynode/", ignore_failure=True) + "

" - data_drive_usage_details += "
" + data_drive_usage_details = "" + data_drive_usage_details += "" + data_drive_usage_details += "Disk Format" + data_drive_usage_details += "

" + get_current_drive_filesystem_type() + "

" + data_drive_usage_details += "Data Storage
" + data_drive_usage_details += "
" + run_linux_cmd("du -h -d1 /mnt/hdd/mynode/", ignore_failure=True) + "

" + data_drive_usage_details += "
" except Exception as e: log_message("CAUGHT update_device_info EXCEPTION: " + str(e)) @@ -102,7 +106,7 @@ def update_bitcoin_main_info_thread(): bitcoin_block_height = get_bitcoin_block_height() mynode_block_height = get_mynode_block_height() remaining = bitcoin_block_height - mynode_block_height - if remaining == 0 and bitcoin_block_height > 820000: + if remaining == 0 and bitcoin_block_height > 845000: synced = True if not os.path.isfile(BITCOIN_SYNCED_FILE): open(BITCOIN_SYNCED_FILE, 'a').close() # touch file