From 2d4c5bc1bda29a6a0f55dab6743b3d9ff66611de Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Sat, 25 Apr 2020 20:37:16 -0500 Subject: [PATCH] Add initial status page --- rootfs/standard/var/www/mynode/settings.py | 108 ++++- .../www/mynode/templates/includes/footer.html | 2 +- .../var/www/mynode/templates/main.html | 5 +- .../var/www/mynode/templates/settings.html | 230 ----------- .../var/www/mynode/templates/status.html | 379 ++++++++++++++++++ 5 files changed, 479 insertions(+), 245 deletions(-) create mode 100644 rootfs/standard/var/www/mynode/templates/status.html diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index b30ecc79..9330bb36 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -110,15 +110,6 @@ def page_settings(): except: bitcoin_status_log = "ERROR" - # Get Status - lnd_status_log = get_journalctl_log("lnd") - lndhub_status_log = get_journalctl_log("lndhub") - tor_status_log = get_journalctl_log("tor@default") - electrs_status_log = get_journalctl_log("electrs") - netdata_status_log = get_journalctl_log("netdata") - rtl_status_log = get_journalctl_log("rtl") - docker_status_log = get_journalctl_log("docker") - docker_image_build_status_log = get_journalctl_log("docker_images") # Get QuickSync Rates upload_rate = 100 @@ -147,6 +138,100 @@ def page_settings(): "product_key_skipped": pk_skipped, "product_key_error": pk_error, "changelog": changelog, + "is_bitcoin_synced": is_bitcoind_synced(), + "firewall_rules": get_firewall_rules(), + "is_quicksync_disabled": not quicksync_enabled, + "is_netdata_enabled": is_netdata_enabled(), + "is_uploader_device": is_uploader(), + "download_rate": download_rate, + "upload_rate": upload_rate, + "is_btc_lnd_tor_enabled": is_btc_lnd_tor_enabled(), + "uptime": uptime, + "date": date, + "public_ip": public_ip, + "local_ip": local_ip, + "drive_usage": get_drive_usage(), + "cpu_usage": get_cpu_usage(), + "ram_usage": get_ram_usage(), + "device_temp": get_device_temp(), + "ui_settings": read_ui_settings() + } + return render_template('settings.html', **templateData) + +@mynode_settings.route("/status") +def page_status(): + check_logged_in() + + current_version = get_current_version() + latest_version = get_latest_version() + current_beta_version = get_current_beta_version() + latest_beta_version = get_latest_beta_version() + + changelog = get_device_changelog() + serial_number = get_device_serial() + device_type = get_device_type() + device_ram = get_device_ram() + product_key = get_product_key() + pk_skipped = skipped_product_key() + pk_error = not is_valid_product_key() + uptime = get_system_uptime() + date = get_system_date() + local_ip = get_local_ip() + public_ip = get_public_ip() + + + # Get Startup Status + startup_status_log = get_journalctl_log("mynode") + + # Get QuickSync Status + quicksync_enabled = is_quicksync_enabled() + quicksync_status = "Disabled" + quicksync_status_color = "gray" + quicksync_status_log = "DISABLED" + if quicksync_enabled: + quicksync_status = get_service_status_basic_text("quicksync") + quicksync_status_color = get_service_status_color("quicksync") + try: + quicksync_status_log = subprocess.check_output(["mynode-get-quicksync-status"]).decode("utf8") + except: + quicksync_status_log = "ERROR" + + # Get Bitcoin Status + bitcoin_status_log = "" + try: + bitcoin_status_log = subprocess.check_output(["tail","-n","200","/mnt/hdd/mynode/bitcoin/debug.log"]).decode("utf8") + lines = bitcoin_status_log.split('\n') + lines.reverse() + bitcoin_status_log = '\n'.join(lines) + except: + bitcoin_status_log = "ERROR" + + # Get Status + lnd_status_log = get_journalctl_log("lnd") + lndhub_status_log = get_journalctl_log("lndhub") + tor_status_log = get_journalctl_log("tor@default") + electrs_status_log = get_journalctl_log("electrs") + netdata_status_log = get_journalctl_log("netdata") + rtl_status_log = get_journalctl_log("rtl") + docker_status_log = get_journalctl_log("docker") + docker_image_build_status_log = get_journalctl_log("docker_images") + + templateData = { + "title": "myNode Status", + "password_message": "", + "current_version": current_version, + "latest_version": latest_version, + "current_beta_version": current_beta_version, + "latest_beta_version": latest_beta_version, + "upgrade_error": did_upgrade_fail(), + "upgrade_logs": get_recent_upgrade_logs(), + "serial_number": serial_number, + "device_type": device_type, + "device_ram": device_ram, + "product_key": product_key, + "product_key_skipped": pk_skipped, + "product_key_error": pk_error, + "changelog": changelog, "startup_status_log": startup_status_log, "startup_status": get_service_status_basic_text("mynode"), "startup_status_color": get_service_status_color("mynode"), @@ -196,9 +281,6 @@ def page_settings(): "firewall_rules": get_firewall_rules(), "is_quicksync_disabled": not quicksync_enabled, "is_netdata_enabled": is_netdata_enabled(), - "is_uploader_device": is_uploader(), - "download_rate": download_rate, - "upload_rate": upload_rate, "is_btc_lnd_tor_enabled": is_btc_lnd_tor_enabled(), "uptime": uptime, "date": date, @@ -210,7 +292,7 @@ def page_settings(): "device_temp": get_device_temp(), "ui_settings": read_ui_settings() } - return render_template('settings.html', **templateData) + return render_template('status.html', **templateData) @mynode_settings.route("/settings/upgrade") def upgrade_page(): diff --git a/rootfs/standard/var/www/mynode/templates/includes/footer.html b/rootfs/standard/var/www/mynode/templates/includes/footer.html index f5af8fca..0552a3a3 100644 --- a/rootfs/standard/var/www/mynode/templates/includes/footer.html +++ b/rootfs/standard/var/www/mynode/templates/includes/footer.html @@ -1,3 +1,3 @@ diff --git a/rootfs/standard/var/www/mynode/templates/main.html b/rootfs/standard/var/www/mynode/templates/main.html index 7ddc2cc3..4cb6691b 100644 --- a/rootfs/standard/var/www/mynode/templates/main.html +++ b/rootfs/standard/var/www/mynode/templates/main.html @@ -201,7 +201,10 @@
Settings
-
Settings
+
+ Status + Settings +
diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index 511abc9e..064e3ad5 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -192,91 +192,6 @@ } }); - $("#show_startup_status").on("click", function() { - $("#show_startup_status").hide(0); - $("#startup_status").show(); - }); - - $("#show_quicksync_status").on("click", function() { - $("#show_quicksync_status").hide(0); - $("#quicksync_status").show(); - }); - - $("#show_bitcoin_status").on("click", function() { - $("#show_bitcoin_status").hide(0); - $("#bitcoin_status").show(); - }); - - $("#show_lnd_status").on("click", function() { - $("#show_lnd_status").hide(0); - $("#lnd_status").show(); - }); - - $("#show_lndhub_status").on("click", function() { - $("#show_lndhub_status").hide(0); - $("#lndhub_status").show(); - }); - - $("#show_tor_status").on("click", function() { - $("#show_tor_status").hide(0); - $("#tor_status").show(); - }); - - $("#show_electrs_status").on("click", function() { - $("#show_electrs_status").hide(0); - $("#electrs_status").show(); - }); - - $("#show_rtl_status").on("click", function() { - $("#show_rtl_status").hide(0); - $("#rtl_status").show(); - }); - - $("#show_docker_status").on("click", function() { - $("#show_docker_status").hide(0); - $("#docker_status").show(); - }); - - $("#show_docker_image_build_status").on("click", function() { - $("#show_docker_image_build_status").hide(0); - $("#docker_image_build_status").show(); - }); - - $("#show_netdata_status").on("click", function() { - $("#show_netdata_status").hide(0); - $("#netdata_status").show(); - }); - - $("#show_dojo_status").on("click", function() { - $("#show_dojo_status").hide(0); - $("#dojo_status").show(); - }); - - $("#show_btcpayserver_status").on("click", function() { - $("#show_btcpayserver_status").hide(0); - $("#btcpayserver_status").show(); - }); - - $("#show_mempoolspace_status").on("click", function() { - $("#show_mempoolspace_status").hide(0); - $("#mempoolspace_status").show(); - }); - - $("#show_upgrade_status").on("click", function() { - $("#show_upgrade_status").hide(0); - $("#upgrade_status").show(); - }); - - $("#show_upgrade_status_beta").on("click", function() { - $("#show_upgrade_status_beta").hide(0); - $("#upgrade_status_beta").show(); - }); - - $("#show_firewall_status").on("click", function() { - $("#show_firewall_status").hide(0); - $("#firewall_status").show(); - }); - $("#show_firewall_rules").on("click", function() { $("#show_firewall_rules").hide(0); $("#firewall_rules").show(); @@ -586,151 +501,6 @@ - -
-
Service Status
- -
myNode Startup Status
-
-
- {{ startup_status }} -
- - -
- -
QuickSync Status
-
-
- {{ quicksync_status }} -
- - -
- -
Tor Status
-
-
- {{ tor_status }} -
- - -
- -
Bitcoin Status
-
-
- {{ bitcoin_status }} -
- - -
- - {% if is_bitcoin_synced %} - -
LND Status
-
-
- {{ lnd_status }} -
- - -
- -
Electrum Server Status
-
-
- {{ electrs_status }} -
- - -
- -
LNDHub Status
-
-
- {{ lndhub_status }} -
- - -
- -
RTL Status
-
-
- {{ rtl_status }} -
- - -
- -
Docker Status
-
-
- {{ docker_status }} -
- - -
- -
Docker Image Build Status
-
-
- {{ docker_image_build_status }} -
- - -
- -
Dojo Status
-
-
- {{ dojo_status }} -
- - -
- -
BTCPay Server Status
-
-
- {{ btcpayserver_status }} -
- - -
- -
Mempool Status
-
-
- {{ mempoolspace_status }} -
- - -
- - {% if is_netdata_enabled %} -
Netdata Status
-
-
- {{ netdata_status }} -
- - -
- {% endif %} - - {% endif %} - -
Firewall Status
-
-
- {{ firewall_status }} -
- - - -
diff --git a/rootfs/standard/var/www/mynode/templates/status.html b/rootfs/standard/var/www/mynode/templates/status.html new file mode 100644 index 00000000..0c949ba5 --- /dev/null +++ b/rootfs/standard/var/www/mynode/templates/status.html @@ -0,0 +1,379 @@ + + + {{ title }} + {% include 'includes/head.html' %} + + + + + + {% include 'includes/logo_header.html' %} +
+ home  +
+ +
Status
+ + {% include 'includes/message_display.html' %} + +
+
+
myNode
+ +
Version
+ + + + + + +
Current Version{{current_version}}
+
+ + +
Info
+ + + + + + + + + + + + + + + + + + + + + + + +
Serial Number{{serial_number}}
Product Key + {% if product_key_skipped %} + {{product_key}} + {% else %} + + + {% endif %} +
Device Type{{device_type}}
Device RAM{{device_ram}} GB
Local IP{{local_ip}}
+
+ +
Status
+ + + + + + + + + + + + + + + + + + + + + + {% if device_temp != '...' %} + + + + + {% endif %} + + + + + + + + +
Details + {% if is_netdata_enabled and is_bitcoin_synced %} + Open Netdata + {% endif %} + Open Glances +
Manage + Linux Terminal +
Disk Usage{{drive_usage}}
CPU{{cpu_usage}}
RAM{{ram_usage}}
Temperature{{device_temp}} °C
Uptime{{uptime}}
Date{{date}}
+
+ +
+
Service Status
+ +
myNode Startup Status
+
+
+ {{ startup_status }} +
+ + +
+ +
QuickSync Status
+
+
+ {{ quicksync_status }} +
+ + +
+ +
Tor Status
+
+
+ {{ tor_status }} +
+ + +
+ +
Bitcoin Status
+
+
+ {{ bitcoin_status }} +
+ + +
+ + {% if is_bitcoin_synced %} + +
LND Status
+
+
+ {{ lnd_status }} +
+ + +
+ +
Electrum Server Status
+
+
+ {{ electrs_status }} +
+ + +
+ +
LNDHub Status
+
+
+ {{ lndhub_status }} +
+ + +
+ +
RTL Status
+
+
+ {{ rtl_status }} +
+ + +
+ +
Docker Status
+
+
+ {{ docker_status }} +
+ + +
+ +
Docker Image Build Status
+
+
+ {{ docker_image_build_status }} +
+ + +
+ +
Dojo Status
+
+
+ {{ dojo_status }} +
+ + +
+ +
BTCPay Server Status
+
+
+ {{ btcpayserver_status }} +
+ + +
+ +
Mempool Status
+
+
+ {{ mempoolspace_status }} +
+ + +
+ + {% if is_netdata_enabled %} +
Netdata Status
+
+
+ {{ netdata_status }} +
+ + +
+ {% endif %} + + {% endif %} + +
Firewall Status
+
+
+ {{ firewall_status }} +
+ + +
+ + + {% include 'includes/footer.html' %} + +