From 779129c9de892a5560eed28417e68648f9b83d6c Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Mon, 11 Nov 2019 20:35:05 -0600 Subject: [PATCH] Add glances --- .../etc/systemd/system/glances.service | 18 ++++++++++ rootfs/standard/usr/bin/mynode_firewall.sh | 1 + .../standard/usr/bin/mynode_post_upgrade.sh | 3 +- rootfs/standard/var/www/mynode/settings.py | 5 +++ .../var/www/mynode/templates/settings.html | 33 ++++++++++++++++++- setup/setup_device.sh | 3 +- 6 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 rootfs/standard/etc/systemd/system/glances.service diff --git a/rootfs/standard/etc/systemd/system/glances.service b/rootfs/standard/etc/systemd/system/glances.service new file mode 100644 index 00000000..1892e392 --- /dev/null +++ b/rootfs/standard/etc/systemd/system/glances.service @@ -0,0 +1,18 @@ +# myNode glances service (system monitoring) +# /etc/systemd/system/glances.service + +[Unit] +Description=Glances +After=network.target + +[Service] +ExecStart=/usr/bin/glances -w +User=root +Group=root +TimeoutSec=300 +Restart=always +RestartSec=60 +Nice=5 + +[Install] +WantedBy=multi-user.target \ No newline at end of file diff --git a/rootfs/standard/usr/bin/mynode_firewall.sh b/rootfs/standard/usr/bin/mynode_firewall.sh index 3c2e905b..5376c97d 100755 --- a/rootfs/standard/usr/bin/mynode_firewall.sh +++ b/rootfs/standard/usr/bin/mynode_firewall.sh @@ -28,6 +28,7 @@ ufw allow 56881 comment 'allow myNode QuickSync' ufw allow 51413 comment 'allow myNode QuickSync' ufw allow 6771 comment 'allow myNode QuickSync (LPD)' ufw allow 51194 comment 'allow VPN' +ufw allow 61208 comment 'allow glances' ufw allow from 127.0.0.1 comment 'allow from localhost' ufw allow from ::1 comment 'allow from localhost' diff --git a/rootfs/standard/usr/bin/mynode_post_upgrade.sh b/rootfs/standard/usr/bin/mynode_post_upgrade.sh index 82be4710..a6e521a9 100755 --- a/rootfs/standard/usr/bin/mynode_post_upgrade.sh +++ b/rootfs/standard/usr/bin/mynode_post_upgrade.sh @@ -12,7 +12,7 @@ systemctl stop bitcoind # Install any new software apt -y install pv sysstat network-manager unzip pkg-config libfreetype6-dev libpng-dev -apt -y install libatlas-base-dev libffi-dev libssl-dev glances +apt -y install libatlas-base-dev libffi-dev libssl-dev glances bottle # Install any pip software pip install tzupdate @@ -206,6 +206,7 @@ systemctl enable firewall systemctl enable invalid_block_check systemctl enable usb_driver_check systemctl enable https +systemctl enable glances # Disable any old services sudo systemctl disable hitch diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index abf02b50..b9cf6ffe 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -6,6 +6,7 @@ from threading import Timer from thread_functions import * from user_management import check_logged_in from lightning_info import * +from thread_functions import * import pam import json import time @@ -138,6 +139,10 @@ def page_settings(): "uptime": uptime, "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) diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index 321fdd49..d8dbf307 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -227,6 +227,11 @@ ); }); + $("#glances").on("click", function() { + url = 'http://'+location.hostname+':61208' + window.open(url,'_blank'); + }) + $( function() { var downloadHandle = $( "#download-handle" ); var uploadHandle = $( "#upload-handle" ); @@ -342,6 +347,32 @@ Local IP {{local_ip}} + + +
+ +
Status
+ + + + + + + + + + + + + + + + + + + + + @@ -377,7 +408,7 @@
-
Status
+
Service Status
QuickSync Status
diff --git a/setup/setup_device.sh b/setup/setup_device.sh index 64de6f84..80222d9f 100755 --- a/setup/setup_device.sh +++ b/setup/setup_device.sh @@ -73,7 +73,7 @@ apt-get -y install inotify-tools libssl-dev tor tmux screen apt-get -y install python-grpcio python3-grpcio apt-get -y install pv sysstat network-manager rsync parted unzip pkg-config apt-get -y install libfreetype6-dev libpng-dev libatlas-base-dev -apt-get -y install libffi-dev libssl-dev glances +apt-get -y install libffi-dev libssl-dev glances bottle # Install other things without recommendation @@ -419,6 +419,7 @@ systemctl enable rtl systemctl enable tor systemctl enable invalid_block_check systemctl enable usb_driver_check +systemctl enable glances # Regenerate MAC Address for Rock64
DetailsOpen Glances
Disk Usage{{drive_usage}}
CPU{{cpu_usage}}
RAM{{ram_usage}}
Temperature{{device_temp}} °C
Uptime {{uptime}}