Add drive usage details
This commit is contained in:
parent
28f7c629f0
commit
a5c501090b
|
@ -106,7 +106,9 @@ def page_settings():
|
|||
"oom_error": has_oom_error(),
|
||||
"oom_info": get_oom_error_info(),
|
||||
"data_drive_usage": get_data_drive_usage(),
|
||||
"data_drive_usage_details": Markup(get_data_drive_usage_details()),
|
||||
"os_drive_usage": get_os_drive_usage(),
|
||||
"os_drive_usage_details": Markup(get_os_drive_usage_details()),
|
||||
"cpu_usage": get_cpu_usage(),
|
||||
"ram_usage": get_ram_usage(),
|
||||
"device_temp": get_device_temp(),
|
||||
|
@ -299,7 +301,9 @@ def page_status():
|
|||
"oom_error": has_oom_error(),
|
||||
"oom_info": get_oom_error_info(),
|
||||
"data_drive_usage": get_data_drive_usage(),
|
||||
"data_drive_usage_details": Markup(get_data_drive_usage_details()),
|
||||
"os_drive_usage": get_os_drive_usage(),
|
||||
"os_drive_usage_details": Markup(get_os_drive_usage_details()),
|
||||
"cpu_usage": get_cpu_usage(),
|
||||
"ram_usage": get_ram_usage(),
|
||||
"device_temp": get_device_temp(),
|
||||
|
|
|
@ -25,11 +25,33 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<th>Data Disk Usage</th>
|
||||
<td>{{data_drive_usage}}</td>
|
||||
<td>
|
||||
{{data_drive_usage}}
|
||||
{% set data_drive_usage_num = data_drive_usage | replace("%", "") | int %}
|
||||
{% if data_drive_usage_num >= 90 %}
|
||||
<i class="fas fa-exclamation-triangle" title="Drive is nearly full!"></i>
|
||||
{% endif %}
|
||||
<button id="show_data_drive_usage_details" class="ui-button ui-widget ui-corner-all settings_button_small" style="margin-left: 20px;">Show Details</button>
|
||||
<span id="data_drive_usage_details" style="display: none">
|
||||
<br/><br/>
|
||||
{{data_drive_usage_details}}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>OS Disk Usage</th>
|
||||
<td>{{os_drive_usage}}</td>
|
||||
<td>
|
||||
{{os_drive_usage}}
|
||||
{% set os_drive_usage_num = os_drive_usage | replace("%", "") | int %}
|
||||
{% if os_drive_usage_num >= 90 %}
|
||||
<i class="fas fa-exclamation-triangle" title="Drive is nearly full!"></i>
|
||||
{% endif %}
|
||||
<button id="show_os_drive_usage_details" class="ui-button ui-widget ui-corner-all settings_button_small" style="margin-left: 20px;">Show Details</button>
|
||||
<span id="os_drive_usage_details" style="display: none">
|
||||
<br/><br/>
|
||||
{{os_drive_usage_details}}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>CPU</th>
|
||||
|
|
|
@ -240,6 +240,26 @@
|
|||
$("#product_key").show();
|
||||
});
|
||||
|
||||
$("#show_os_drive_usage_details").on("click", function() {
|
||||
if($("#os_drive_usage_details").is(":visible")){
|
||||
$("#show_os_drive_usage_details").text("Show Details")
|
||||
$("#os_drive_usage_details").hide();
|
||||
} else {
|
||||
$("#show_os_drive_usage_details").text("Hide Details")
|
||||
$("#os_drive_usage_details").show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#show_data_drive_usage_details").on("click", function() {
|
||||
if($("#data_drive_usage_details").is(":visible")){
|
||||
$("#show_data_drive_usage_details").text("Show Details")
|
||||
$("#data_drive_usage_details").hide();
|
||||
} else {
|
||||
$("#show_data_drive_usage_details").text("Hide Details")
|
||||
$("#data_drive_usage_details").show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#show_mynode_changelog").on("click", function() {
|
||||
if (showChangelog)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,26 @@
|
|||
$("#product_key").show();
|
||||
});
|
||||
|
||||
$("#show_os_drive_usage_details").on("click", function() {
|
||||
if($("#os_drive_usage_details").is(":visible")){
|
||||
$("#show_os_drive_usage_details").text("Show Details")
|
||||
$("#os_drive_usage_details").hide();
|
||||
} else {
|
||||
$("#show_os_drive_usage_details").text("Hide Details")
|
||||
$("#os_drive_usage_details").show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#show_data_drive_usage_details").on("click", function() {
|
||||
if($("#data_drive_usage_details").is(":visible")){
|
||||
$("#show_data_drive_usage_details").text("Show Details")
|
||||
$("#data_drive_usage_details").hide();
|
||||
} else {
|
||||
$("#show_data_drive_usage_details").text("Hide Details")
|
||||
$("#data_drive_usage_details").show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#glances").on("click", function() {
|
||||
port="61208";
|
||||
if (location.protocol == "https:") {
|
||||
|
|
|
@ -19,6 +19,8 @@ has_updated_btc_info = False
|
|||
cpu_usage = "..."
|
||||
ram_usage = "..."
|
||||
swap_usage = "..."
|
||||
os_drive_usage_details = "..."
|
||||
data_drive_usage_details = "..."
|
||||
public_ip = "not_detected"
|
||||
|
||||
# Getters
|
||||
|
@ -28,13 +30,23 @@ def get_has_updated_btc_info():
|
|||
def get_cpu_usage():
|
||||
global cpu_usage
|
||||
return cpu_usage
|
||||
def get_os_drive_usage_details():
|
||||
global os_drive_usage_details
|
||||
return os_drive_usage_details
|
||||
def get_data_drive_usage_details():
|
||||
global data_drive_usage_details
|
||||
return data_drive_usage_details
|
||||
def get_public_ip():
|
||||
global public_ip
|
||||
return public_ip
|
||||
|
||||
# Updates device info every 60 seconds
|
||||
device_info_call_count = 0
|
||||
def update_device_info():
|
||||
global cpu_usage
|
||||
global os_drive_usage_details
|
||||
global data_drive_usage_details
|
||||
global device_info_call_count
|
||||
|
||||
# Get drive info
|
||||
try:
|
||||
|
@ -45,10 +57,33 @@ def update_device_info():
|
|||
cpu_info = psutil.cpu_times_percent(interval=10.0, percpu=False)
|
||||
cpu_usage = "{:.1f}%".format(100.0 - cpu_info.idle)
|
||||
|
||||
# Update every 24 hrs
|
||||
if device_info_call_count % 60*24 == 0:
|
||||
os_drive_usage_details = ""
|
||||
os_drive_usage_details += "<small>"
|
||||
os_drive_usage_details += "<b>App Storage</b><br/>"
|
||||
os_drive_usage_details += "<pre>" + run_linux_cmd("du -h -d1 /opt/mynode/", ignore_failure=True) + "</pre><br/>"
|
||||
os_drive_usage_details += "<b>User Storage</b><br/>"
|
||||
os_drive_usage_details += "<pre>" + run_linux_cmd("du -h -d1 /home/", ignore_failure=True) + "</pre><br/>"
|
||||
os_drive_usage_details += "<b>Rust Toolchain Storage</b><br/>"
|
||||
if os.path.isdir("/root/.cargo/"):
|
||||
os_drive_usage_details += "<pre>" + run_linux_cmd("du -h -d1 /root/.cargo/", ignore_failure=True) + "</pre><br/>"
|
||||
if os.path.isdir("/home/admin/.cargo/"):
|
||||
os_drive_usage_details += "<pre>" + run_linux_cmd("du -h -d1 /home/admin/.cargo/", ignore_failure=True) + "</pre><br/>"
|
||||
os_drive_usage_details += "</small>"
|
||||
|
||||
data_drive_usage_details = ""
|
||||
data_drive_usage_details += "<small>"
|
||||
data_drive_usage_details += "<b>Data Storage</b><br/>"
|
||||
data_drive_usage_details += "<pre>" + run_linux_cmd("du -h -d1 /mnt/hdd/mynode/", ignore_failure=True) + "</pre><br/>"
|
||||
data_drive_usage_details += "</small>"
|
||||
|
||||
except Exception as e:
|
||||
log_message("CAUGHT update_device_info EXCEPTION: " + str(e))
|
||||
return
|
||||
|
||||
device_info_call_count = device_info_call_count + 1
|
||||
|
||||
# Updates main bitcoin info every 30 seconds
|
||||
def update_bitcoin_main_info_thread():
|
||||
global has_updated_btc_info
|
||||
|
|
Loading…
Reference in New Issue
Block a user