mirror of
https://github.com/mynodebtc/mynode.git
synced 2024-11-12 08:29:16 +00:00
Add detection for undervoltage and throttling on Raspis
This commit is contained in:
parent
62f1e28cfc
commit
5437bc0170
20
rootfs/standard/etc/systemd/system/background.service
Normal file
20
rootfs/standard/etc/systemd/system/background.service
Normal file
|
@ -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
|
26
rootfs/standard/usr/bin/mynode_background.sh
Executable file
26
rootfs/standard/usr/bin/mynode_background.sh
Executable file
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
#==================================
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
<div class="settings_block_subheader">
|
||||
Info
|
||||
</div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>Serial Number</td>
|
||||
<td style="padding-left: 20px;">{{serial_number}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Product Key</td>
|
||||
<td style="padding-left: 20px;">
|
||||
{% if product_key_skipped %}
|
||||
{{product_key}}
|
||||
<a href="/product-key" class="ui-button ui-widget ui-corner-all settings_button_small">Enter Product Key</a>
|
||||
{% else %}
|
||||
<button id="show_product_key" class="ui-button ui-widget ui-corner-all settings_button_small">Show</button>
|
||||
<span id="product_key" style="display: none;">{{product_key}}</span>
|
||||
<a href="/product-key" class="ui-button ui-widget ui-corner-all settings_button_small">Change</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Device Type</td>
|
||||
<td style="padding-left: 20px;">{{device_type}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Device RAM</td>
|
||||
<td style="padding-left: 20px;">{{device_ram}} GB</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Local IP</td>
|
||||
<td style="padding-left: 20px;">{{local_ip}}</td>
|
||||
</tr>
|
||||
{% if throttled_data['RAW_DATA'] != "0x0" and throttled_data['RAW_DATA'] != "MISSING" %}
|
||||
{% if throttled_data['UNDERVOLTED'] or throttled_data['CAPPED'] or throttled_data['THROTTLED'] or throttled_data['SOFT_TEMPLIMIT'] %}
|
||||
<tr>
|
||||
<td>Active Throttling Data</td>
|
||||
<td style="padding-left: 20px; color: red; font-size: 10px">
|
||||
{% if throttled_data['UNDERVOLTED'] %}Undervolted<br/>{% endif %}
|
||||
{% if throttled_data['CAPPED'] %}Capped CPU<br/>{% endif %}
|
||||
{% if throttled_data['THROTTLED'] %}Throttled CPU<br/>{% endif %}
|
||||
{% if throttled_data['SOFT_TEMPLIMIT'] %}Hit Soft Temp Limit<br/>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if throttled_data['HAS_UNDERVOLTED'] or throttled_data['HAS_CAPPED'] or throttled_data['HAS_THROTTLED'] or throttled_data['HAS_SOFT_TEMPLIMIT'] %}
|
||||
<tr>
|
||||
<td>Historic Throttling Data<br/><span style="font-size: 10px;">*Occurred since last reboot</span></td>
|
||||
<td style="padding-left: 20px; color: red; font-size: 10px;">
|
||||
{% if throttled_data['HAS_UNDERVOLTED'] %}Undervolted<br/>{% endif %}
|
||||
{% if throttled_data['HAS_CAPPED'] %}Capped CPU<br/>{% endif %}
|
||||
{% if throttled_data['HAS_THROTTLED'] %}Throttled CPU<br/>{% endif %}
|
||||
{% if throttled_data['HAS_SOFT_TEMPLIMIT'] %}Hit Soft Temp Limit<br/>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if has_checkin_error %}
|
||||
<tr>
|
||||
<td>Server</td>
|
||||
<td style="padding-left: 20px; color: red;"><b>Error contacting mynodebtc.com via Tor!</b><br/>You may have issues checking for new versions or saving product keys.</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
</table>
|
||||
<div class="divider"></div>
|
|
@ -0,0 +1,53 @@
|
|||
<div class="settings_block_subheader">Status</div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>Details</td>
|
||||
<td style="padding-left: 20px;">
|
||||
{% if is_netdata_enabled %}
|
||||
{% if is_bitcoin_synced %}
|
||||
{% if not is_installing_docker_images %}
|
||||
<a id="netdata" class="ui-button ui-widget ui-corner-all settings_button_small" href="#">Open Netdata</a>
|
||||
{% else %}
|
||||
<a class="ui-button ui-widget ui-corner-all settings_button_small" href="#" disabled>Netdata - Waiting on Docker</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a class="ui-button ui-widget ui-corner-all settings_button_small" href="#" disabled>Netdata - Waiting on Bitcoin</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a id="glances" class="ui-button ui-widget ui-corner-all settings_button_small" href="#">Open Glances</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Manage</td>
|
||||
<td style="padding-left: 20px;">
|
||||
<a id="linux_terminal" class="ui-button ui-widget ui-corner-all settings_button_small" href="#">Linux Terminal</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Disk Usage</td>
|
||||
<td style="padding-left: 20px;">{{drive_usage}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CPU</td>
|
||||
<td style="padding-left: 20px;">{{cpu_usage}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RAM</td>
|
||||
<td style="padding-left: 20px;">{{ram_usage}}</td>
|
||||
</tr>
|
||||
{% if device_temp != '...' %}
|
||||
<tr>
|
||||
<td>Temperature</td>
|
||||
<td style="padding-left: 20px;">{{device_temp}} °C</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td>Uptime</td>
|
||||
<td style="padding-left: 20px;">{{uptime}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Date</td>
|
||||
<td style="padding-left: 20px;">{{date}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="divider"></div>
|
|
@ -446,103 +446,9 @@
|
|||
|
||||
<div class="divider"></div>
|
||||
|
||||
{% include 'includes/info_table.html' %}
|
||||
|
||||
<div class="settings_block_subheader">
|
||||
Info
|
||||
</div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>Serial Number</td>
|
||||
<td style="padding-left: 20px;">{{serial_number}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Product Key</td>
|
||||
<td style="padding-left: 20px;">
|
||||
{% if product_key_skipped %}
|
||||
{{product_key}}
|
||||
<a href="/product-key" class="ui-button ui-widget ui-corner-all settings_button_small">Enter Product Key</a>
|
||||
{% else %}
|
||||
<button id="show_product_key" class="ui-button ui-widget ui-corner-all settings_button_small">Show</button>
|
||||
<span id="product_key" style="display: none;">{{product_key}}</span>
|
||||
<a href="/product-key" class="ui-button ui-widget ui-corner-all settings_button_small">Change</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Device Type</td>
|
||||
<td style="padding-left: 20px;">{{device_type}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Device RAM</td>
|
||||
<td style="padding-left: 20px;">{{device_ram}} GB</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Local IP</td>
|
||||
<td style="padding-left: 20px;">{{local_ip}}</td>
|
||||
</tr>
|
||||
{% if has_checkin_error %}
|
||||
<tr>
|
||||
<td>Server</td>
|
||||
<td style="padding-left: 20px; color: red;"><b>Error contacting mynodebtc.com via Tor!</b><br/>You may have issues checking for new versions or saving product keys.</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
</table>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="settings_block_subheader">Status</div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>Details</td>
|
||||
<td style="padding-left: 20px;">
|
||||
{% if is_netdata_enabled %}
|
||||
{% if is_bitcoin_synced %}
|
||||
{% if not is_installing_docker_images %}
|
||||
<a id="netdata" class="ui-button ui-widget ui-corner-all settings_button_small" href="#">Open Netdata</a>
|
||||
{% else %}
|
||||
<a class="ui-button ui-widget ui-corner-all settings_button_small" href="#" disabled>Netdata - Waiting on Docker</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a class="ui-button ui-widget ui-corner-all settings_button_small" href="#" disabled>Netdata - Waiting on Bitcoin</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a id="glances" class="ui-button ui-widget ui-corner-all settings_button_small" href="#">Open Glances</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Manage</td>
|
||||
<td style="padding-left: 20px;">
|
||||
<a id="linux_terminal" class="ui-button ui-widget ui-corner-all settings_button_small" href="#">Linux Terminal</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Disk Usage</td>
|
||||
<td style="padding-left: 20px;">{{drive_usage}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CPU</td>
|
||||
<td style="padding-left: 20px;">{{cpu_usage}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RAM</td>
|
||||
<td style="padding-left: 20px;">{{ram_usage}}</td>
|
||||
</tr>
|
||||
{% if device_temp != '...' %}
|
||||
<tr>
|
||||
<td>Temperature</td>
|
||||
<td style="padding-left: 20px;">{{device_temp}} °C</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td>Uptime</td>
|
||||
<td style="padding-left: 20px;">{{uptime}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Date</td>
|
||||
<td style="padding-left: 20px;">{{date}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="divider"></div>
|
||||
{% include 'includes/status_table.html' %}
|
||||
|
||||
<div class="settings_block_subheader">Change Log</div>
|
||||
<button id="show_mynode_changelog" class="ui-button ui-widget ui-corner-all settings_button">View Change Log</button>
|
||||
|
|
|
@ -175,100 +175,9 @@
|
|||
</table>
|
||||
<div class="divider"></div>
|
||||
|
||||
{% include 'includes/info_table.html' %}
|
||||
|
||||
<div class="settings_block_subheader">Info</div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>Serial Number</td>
|
||||
<td style="padding-left: 20px;">{{serial_number}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Product Key</td>
|
||||
<td style="padding-left: 20px;">
|
||||
{% if product_key_skipped %}
|
||||
{{product_key}}
|
||||
{% else %}
|
||||
<button id="show_product_key" class="ui-button ui-widget ui-corner-all settings_button_small">Show</button>
|
||||
<span id="product_key" style="display: none;">{{product_key}}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Device Type</td>
|
||||
<td style="padding-left: 20px;">{{device_type}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Device RAM</td>
|
||||
<td style="padding-left: 20px;">{{device_ram}} GB</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Local IP</td>
|
||||
<td style="padding-left: 20px;">{{local_ip}}</td>
|
||||
</tr>
|
||||
{% if has_checkin_error %}
|
||||
<tr>
|
||||
<td>Server</td>
|
||||
<td style="padding-left: 20px; color: red;"><b>Error contacting mynodebtc.com via Tor!</b><br/>You may have issues checking for new versions or saving product keys.</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
</table>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="settings_block_subheader">Status</div>
|
||||
<table border="0">
|
||||
<tr>
|
||||
<td>Details</td>
|
||||
<td style="padding-left: 20px;">
|
||||
{% if is_netdata_enabled %}
|
||||
{% if is_bitcoin_synced %}
|
||||
{% if not is_installing_docker_images %}
|
||||
<a id="netdata" class="ui-button ui-widget ui-corner-all settings_button_small" href="#">Open Netdata</a>
|
||||
{% else %}
|
||||
<a class="ui-button ui-widget ui-corner-all settings_button_small" href="#" disabled>Netdata - Waiting on Docker</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<a class="ui-button ui-widget ui-corner-all settings_button_small" href="#" disabled>Netdata - Waiting on Bitcoin</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<a id="glances" class="ui-button ui-widget ui-corner-all settings_button_small" href="#">Open Glances</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Manage</td>
|
||||
<td style="padding-left: 20px;">
|
||||
<a id="linux_terminal" class="ui-button ui-widget ui-corner-all settings_button_small" href="#">Linux Terminal</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Disk Usage</td>
|
||||
<td style="padding-left: 20px;">{{drive_usage}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>CPU</td>
|
||||
<td style="padding-left: 20px;">{{cpu_usage}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RAM</td>
|
||||
<td style="padding-left: 20px;">{{ram_usage}}</td>
|
||||
</tr>
|
||||
{% if device_temp != '...' %}
|
||||
<tr>
|
||||
<td>Temperature</td>
|
||||
<td style="padding-left: 20px;">{{device_temp}} °C</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td>Uptime</td>
|
||||
<td style="padding-left: 20px;">{{uptime}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Date</td>
|
||||
<td style="padding-left: 20px;">{{date}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div class="divider"></div>
|
||||
{% include 'includes/status_table.html' %}
|
||||
|
||||
<div class="settings_block_subheader">Settings</div>
|
||||
<a href="/settings" class="ui-button ui-widget ui-corner-all settings_button">Settings</a>
|
||||
|
|
|
@ -54,6 +54,9 @@ def update_device_info():
|
|||
|
||||
# Get drive info
|
||||
try:
|
||||
# Get throttled info (raspi only)
|
||||
reload_throttled_data()
|
||||
|
||||
# Get drive actual usage
|
||||
#results = subprocess.check_output(["du","-sh","/mnt/hdd/mynode/"])
|
||||
#drive_usage = results.split()[0]
|
||||
|
|
|
@ -719,6 +719,7 @@ fi
|
|||
# Setup myNode Startup Script
|
||||
systemctl daemon-reload
|
||||
systemctl enable check_in
|
||||
systemctl enable background
|
||||
systemctl enable docker
|
||||
systemctl enable mynode
|
||||
systemctl enable quicksync
|
||||
|
|
Loading…
Reference in New Issue
Block a user