node.js dashboard works

This commit is contained in:
2025-11-30 22:17:14 -08:00
parent c6d51f2a49
commit ebbc5ac5cf
22 changed files with 829 additions and 196 deletions

View File

@ -1,12 +0,0 @@
services:
{{ container_name }}:
container_name: {{ container_name }}
image: php:8.0-apache
ports:
- {{ container_http_port }}:80
volumes:
- ./html:/var/www/html/
{{ extra_volumes }}
network_mode: bridge
restart: always

View File

@ -0,0 +1,28 @@
services:
web_dash:
container_name: web_dash
image: php:8.0-apache
ports:
- 80:80
volumes:
- ./html:/var/www/html/
network_mode: bridge
restart: always
ws_node:
container_name: ws_node
image: ws_node
ports:
- 3000:3000
network_mode: bridge
restart: always
depends_on:
- redis
redis:
image: redis:7-alpine
network_mode: bridge
restart: always
ports:
- 172.17.0.1:6379:6379

View File

@ -1,14 +1,28 @@
#!/bin/bash
# this is a big loop
# it shows SSD health data
SERVICE_MODE = {{ service_mode }}
exec 2> /dev/null
while true; do
clear
# Show IP Info
if ! $SERVICE_MODE; then
echo ===Visit the IP in your browser to view history======
fi
ip -o -4 ad | grep -v -e docker -e 127.0.0.1 -e br- | awk '{print $2 "," $4}' | column -s , -t
# get all disks
DISK_LIST=$(ls -lo /dev/sd? | awk '{print $9}')
# process each disk
IFS=$'\n' read -rd '' -a DISK_ARRAY <<< "$DISK_LIST"
for DISK in "${DISK_ARRAY[@]}"; do
# update active drives more frequently
if ! $SERVICE_MODE; then
echo "Issuing request to update drive database"
fi
curl -s "http://172.17.0.1:5000/refresh_active_drives"
# store smartctl data once
SMART_DATA=$(smartctl -x $DISK)
NVME_CHECK=$(echo "$SMART_DATA" | grep "NVMe Version")
@ -28,20 +42,22 @@ while true; do
SMART=$(echo "$SMART_DATA" | grep "self-assessment test result" | cut -d ":" -f 2 | xargs)
FLAVOR="SATA SSD"
DRIVE_EXISTS=$(curl -s "http://172.17.0.1:5000/check?serial_lookup=$SERIAL" | jq .serial_number_exists)
# Display drive data
echo "============ $DISK Disk Info - SSD: ============"
#echo "DRIVE_EXISTS: $DRIVE_EXISTS"
echo "Serial Number: $SERIAL"
echo "Model String: $MODEL"
echo "SMART Check: $SMART"
echo "Disk capacity: $CAPACITY"
echo "TB Written: $TBW TB"
if [ -z "$PLR" ] ; then
echo "Percent Lifetime Remaining data not available"
else
echo "$DISK has $PLR% lifetime remaining"
if ! $SERVICE_MODE; then
# Display drive data
echo "============ $DISK Disk Info - SSD: ============"
#echo "DRIVE_EXISTS: $DRIVE_EXISTS"
echo "Serial Number: $SERIAL"
echo "Model String: $MODEL"
echo "SMART Check: $SMART"
echo "Disk capacity: $CAPACITY"
echo "TB Written: $TBW TB"
if [ -z "$PLR" ] ; then
echo "Percent Lifetime Remaining data not available"
else
echo "$DISK has $PLR% lifetime remaining"
fi
echo
fi
echo
if [ -x "$TBW"] ; then
TBW="unknown"
fi
@ -66,18 +82,20 @@ while true; do
SMART=$(echo "$SMART_DATA" | grep "self-assessment test result" | cut -d ":" -f 2 | xargs)
FLAVOR="NVMe"
DRIVE_EXISTS=$(curl -s "http://172.17.0.1:5000/check?serial_lookup=$SERIAL" | jq .serial_number_exists)
# Display Disk Info
echo "============ $DISK Disk Info - NVMe: ============"
#echo "DRIVE_EXISTS: $DRIVE_EXISTS"
echo "Serial Number: $SERIAL"
echo "Model String: $MODEL"
echo "SMART Check: $SMART"
echo "Disk capacity: $CAPACITY"
echo "TB Written: $TBW TB"
echo "NAND spare blocks: $AVAIL_SPARE"
echo
if [ -x "$TBW"] ; then
TBW="unknown"
if ! $SERVICE_MODE; then
# Display Disk Info
echo "============ $DISK Disk Info - NVMe: ============"
#echo "DRIVE_EXISTS: $DRIVE_EXISTS"
echo "Serial Number: $SERIAL"
echo "Model String: $MODEL"
echo "SMART Check: $SMART"
echo "Disk capacity: $CAPACITY"
echo "TB Written: $TBW TB"
echo "NAND spare blocks: $AVAIL_SPARE"
echo
if [ -x "$TBW"] ; then
TBW="unknown"
fi
fi
# database handler
if [ "$DRIVE_EXISTS" == "false" ] ; then
@ -90,10 +108,14 @@ while true; do
fi
fi
else
echo "Skipping $DISK, not SATA SSD or NVMe"
if ! $SERVICE_MODE; then
echo "Skipping $DISK, not SATA SSD or NVMe"
fi
fi
done
# wait {{ sleep_time }} seconds, loop again
echo "Sleeping {{ sleep_time }} seconds"
if ! $SERVICE_MODE; then
echo "Sleeping {{ sleep_time }} seconds"
fi
sleep {{ sleep_time }}
done

View File

@ -2,6 +2,7 @@
[Unit]
Description={{ service_name }}
After=network.target
{{ extra_options }}
[Service]
User=root