diff --git a/rootfs/standard/etc/systemd/system/background.service b/rootfs/standard/etc/systemd/system/background.service new file mode 100644 index 00000000..43efc734 --- /dev/null +++ b/rootfs/standard/etc/systemd/system/background.service @@ -0,0 +1,20 @@ +# myNode background service +# /etc/systemd/system/background.service + +[Unit] +Description=myNode Background Checks +Wants=mynode.service +After=mynode.service + +[Service] +Type=simple +KillMode=control-group +TimeoutSec=30 +Restart=always +RestartSec=30 +ExecStart=/usr/bin/mynode_background.sh +User=root +Group=root + +[Install] +WantedBy=multi-user.target diff --git a/rootfs/standard/usr/bin/mynode_background.sh b/rootfs/standard/usr/bin/mynode_background.sh new file mode 100755 index 00000000..b4c60835 --- /dev/null +++ b/rootfs/standard/usr/bin/mynode_background.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -e +set -x + +source /usr/share/mynode/mynode_config.sh +source /usr/share/mynode/mynode_app_versions.sh + +COUNTER=0 + +while true; do + + # Check for under voltage, throttling, etc... every 2 min on Raspis + if [ $(( $COUNTER % 2 )) -eq 0 ]; then + if [ $IS_RASPI -eq 1 ]; then + STATUS=$(vcgencmd get_throttled) + STATUS=${STATUS#*=} + echo $STATUS > /tmp/get_throttled_data + fi + fi + + + # Increment counter and sleep 1 min + COUNTER=$((COUNTER+1)) + sleep 1m +done diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index c50c0552..ca8e5a30 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -630,6 +630,7 @@ apt-get clean # Enable any new/required services systemctl enable check_in +systemctl enable background systemctl enable docker systemctl enable bitcoind systemctl enable seed_bitcoin_peers diff --git a/rootfs/standard/var/www/mynode/device_info.py b/rootfs/standard/var/www/mynode/device_info.py index f1df7b1b..5335b4ca 100644 --- a/rootfs/standard/var/www/mynode/device_info.py +++ b/rootfs/standard/var/www/mynode/device_info.py @@ -79,6 +79,32 @@ def check_and_mark_reboot_action(tmp_marker): raise RequestRedirect("/") os.system("touch /tmp/{}".format(tmp_marker)) +def reload_throttled_data(): + global cached_data + if os.path.isfile("/tmp/get_throttled_data"): + cached_data["get_throttled_data"] = get_file_contents("/tmp/get_throttled_data") + +def get_throttled_data(): + global cached_data + if "get_throttled_data" in cached_data: + data = cached_data["get_throttled_data"] + hex_data = int(data, 16) + r = {} + r["RAW_DATA"] = data + r["UNDERVOLTED"] = 1 if hex_data & 0x1 else 0 + r["CAPPED"] = 1 if hex_data & 0x2 else 0 + r["THROTTLED"] = 1 if hex_data & 0x4 else 0 + r["SOFT_TEMPLIMIT"] = 1 if hex_data & 0x8 else 0 + r["HAS_UNDERVOLTED"] = 1 if hex_data & 0x10000 else 0 + r["HAS_CAPPED"] = 1 if hex_data & 0x20000 else 0 + r["HAS_THROTTLED"] = 1 if hex_data & 0x40000 else 0 + r["HAS_SOFT_TEMPLIMIT"] = 1 if hex_data & 0x80000 else 0 + return r + else: + r = {} + r["RAW_DATA"] = "MISSING" + return r + #================================== # Manage Versions and Upgrades #================================== diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index 690a0a81..f37649f6 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -1,5 +1,5 @@ from config import * -from flask import Blueprint, render_template, session, abort, Markup, request, redirect, send_from_directory, url_for, flash +from flask import Blueprint, render_template, session, abort, Markup, request, redirect, send_from_directory, url_for, flash, current_app from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException from bitcoind import is_bitcoind_synced from bitcoin_info import using_bitcoin_custom_config @@ -111,6 +111,7 @@ def page_settings(): "uptime": uptime, "date": date, "local_ip": local_ip, + "throttled_data": get_throttled_data(), "drive_usage": get_drive_usage(), "cpu_usage": get_cpu_usage(), "ram_usage": get_ram_usage(), @@ -269,6 +270,7 @@ def page_status(): "uptime": uptime, "date": date, "local_ip": local_ip, + "throttled_data": get_throttled_data(), "drive_usage": get_drive_usage(), "cpu_usage": get_cpu_usage(), "ram_usage": get_ram_usage(), diff --git a/rootfs/standard/var/www/mynode/templates/includes/info_table.html b/rootfs/standard/var/www/mynode/templates/includes/info_table.html new file mode 100644 index 00000000..b39f2e1e --- /dev/null +++ b/rootfs/standard/var/www/mynode/templates/includes/info_table.html @@ -0,0 +1,66 @@ +
Serial Number | +{{serial_number}} | +
Product Key | ++ {% if product_key_skipped %} + {{product_key}} + Enter Product Key + {% else %} + + + Change + {% endif %} + | +
Device Type | +{{device_type}} | +
Device RAM | +{{device_ram}} GB | +
Local IP | +{{local_ip}} | +
Active Throttling Data | +
+ {% if throttled_data['UNDERVOLTED'] %}Undervolted {% endif %} + {% if throttled_data['CAPPED'] %}Capped CPU {% endif %} + {% if throttled_data['THROTTLED'] %}Throttled CPU {% endif %} + {% if throttled_data['SOFT_TEMPLIMIT'] %}Hit Soft Temp Limit {% endif %} + |
+
Historic Throttling Data *Occurred since last reboot |
+
+ {% if throttled_data['HAS_UNDERVOLTED'] %}Undervolted {% endif %} + {% if throttled_data['HAS_CAPPED'] %}Capped CPU {% endif %} + {% if throttled_data['HAS_THROTTLED'] %}Throttled CPU {% endif %} + {% if throttled_data['HAS_SOFT_TEMPLIMIT'] %}Hit Soft Temp Limit {% endif %} + |
+
Server | +Error contacting mynodebtc.com via Tor! You may have issues checking for new versions or saving product keys. |
+
Details | ++ {% if is_netdata_enabled %} + {% if is_bitcoin_synced %} + {% if not is_installing_docker_images %} + Open Netdata + {% else %} + Netdata - Waiting on Docker + {% endif %} + {% else %} + Netdata - Waiting on Bitcoin + {% endif %} + {% endif %} + Open Glances + | +
Manage | ++ Linux Terminal + | +
Disk Usage | +{{drive_usage}} | +
CPU | +{{cpu_usage}} | +
RAM | +{{ram_usage}} | +
Temperature | +{{device_temp}} °C | +
Uptime | +{{uptime}} | +
Date | +{{date}} | +
Serial Number | -{{serial_number}} | -
Product Key | -- {% if product_key_skipped %} - {{product_key}} - Enter Product Key - {% else %} - - - Change - {% endif %} - | -
Device Type | -{{device_type}} | -
Device RAM | -{{device_ram}} GB | -
Local IP | -{{local_ip}} | -
Server | -Error contacting mynodebtc.com via Tor! You may have issues checking for new versions or saving product keys. |
-
Details | -- {% if is_netdata_enabled %} - {% if is_bitcoin_synced %} - {% if not is_installing_docker_images %} - Open Netdata - {% else %} - Netdata - Waiting on Docker - {% endif %} - {% else %} - Netdata - Waiting on Bitcoin - {% endif %} - {% endif %} - Open Glances - | -
Manage | -- Linux Terminal - | -
Disk Usage | -{{drive_usage}} | -
CPU | -{{cpu_usage}} | -
RAM | -{{ram_usage}} | -
Temperature | -{{device_temp}} °C | -
Uptime | -{{uptime}} | -
Date | -{{date}} | -
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}} | -
Server | -Error contacting mynodebtc.com via Tor! You may have issues checking for new versions or saving product keys. |
-
Details | -- {% if is_netdata_enabled %} - {% if is_bitcoin_synced %} - {% if not is_installing_docker_images %} - Open Netdata - {% else %} - Netdata - Waiting on Docker - {% endif %} - {% else %} - Netdata - Waiting on Bitcoin - {% endif %} - {% endif %} - Open Glances - | -
Manage | -- Linux Terminal - | -
Disk Usage | -{{drive_usage}} | -
CPU | -{{cpu_usage}} | -
RAM | -{{ram_usage}} | -
Temperature | -{{device_temp}} °C | -
Uptime | -{{uptime}} | -
Date | -{{date}} | -