mirror of
https://github.com/unraid/api.git
synced 2026-05-02 13:12:01 -05:00
feat: add cpu power query & subscription (#1745)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Per-package CPU power and temperature displayed in hardware info (total and per-package values). * CPU package topology (cores/threads per package) included in CPU info. * Real-time per-package CPU telemetry exposed via a new system metrics subscription. * **Chores** * Added an automated deployment script and npm deploy script for the shared package. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Signed-off-by: Simon Fairweather <simon.n.fairweather@gmail.com> Co-authored-by: Simon Fairweather <simon.n.fairweather@gmail.com> Co-authored-by: SimonFair <39065407+SimonFair@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
Executable
+68
@@ -0,0 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Arguments
|
||||
# $1: SSH server name (required)
|
||||
|
||||
# Check if the server name is provided
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "Error: SSH server name is required."
|
||||
echo "Usage: $0 <server_name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set server name from command-line argument
|
||||
server_name="$1"
|
||||
|
||||
# Build the package
|
||||
echo "Building unraid-shared package..."
|
||||
pnpm build
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Build failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Source directory path
|
||||
source_directory="./dist"
|
||||
|
||||
# Check if dist directory exists
|
||||
if [ ! -d "$source_directory" ]; then
|
||||
echo "The dist directory does not exist after build!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Destination directory path - deploy to node_modules/@unraid/shared/dist
|
||||
destination_directory="/usr/local/unraid-api/node_modules/@unraid/shared"
|
||||
|
||||
# Create destination directory on remote server
|
||||
ssh root@"${server_name}" "mkdir -p $destination_directory"
|
||||
|
||||
# Replace the value inside the rsync command with the user's input
|
||||
rsync_command="rsync -avz --delete --progress --stats -e ssh \"$source_directory/\" \"root@${server_name}:$destination_directory/\""
|
||||
|
||||
echo "Executing the following command:"
|
||||
echo "$rsync_command"
|
||||
|
||||
# Execute the rsync command and capture the exit code
|
||||
eval "$rsync_command"
|
||||
exit_code=$?
|
||||
|
||||
# Chown the directory
|
||||
ssh root@"${server_name}" "chown -R root:root /usr/local/unraid-api/node_modules/@unraid/"
|
||||
|
||||
# Run unraid-api restart on remote host
|
||||
ssh root@"${server_name}" 'INTROSPECTION=true LOG_LEVEL=trace unraid-api restart'
|
||||
|
||||
# Play built-in sound based on the operating system
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS
|
||||
afplay /System/Library/Sounds/Glass.aiff
|
||||
elif [[ "$OSTYPE" == "linux-gnu" ]]; then
|
||||
# Linux
|
||||
paplay /usr/share/sounds/freedesktop/stereo/complete.oga
|
||||
elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
|
||||
# Windows
|
||||
powershell.exe -c "(New-Object Media.SoundPlayer 'C:\Windows\Media\Windows Default.wav').PlaySync()"
|
||||
fi
|
||||
|
||||
# Exit with the rsync command's exit code
|
||||
exit $exit_code
|
||||
@@ -21,7 +21,8 @@
|
||||
"build": "rimraf dist && tsc --project tsconfig.build.json",
|
||||
"prepare": "npm run build",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest"
|
||||
"test:watch": "vitest",
|
||||
"unraid:deploy": "./deploy.sh"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Lime Technology, Inc. <unraid.net>",
|
||||
|
||||
@@ -5,6 +5,7 @@ export const GRAPHQL_PUBSUB_TOKEN = "GRAPHQL_PUBSUB";
|
||||
export enum GRAPHQL_PUBSUB_CHANNEL {
|
||||
ARRAY = "ARRAY",
|
||||
CPU_UTILIZATION = "CPU_UTILIZATION",
|
||||
CPU_TELEMETRY = "CPU_TELEMETRY",
|
||||
DASHBOARD = "DASHBOARD",
|
||||
DISPLAY = "DISPLAY",
|
||||
INFO = "INFO",
|
||||
|
||||
Reference in New Issue
Block a user