mirror of
https://github.com/henrygd/beszel.git
synced 2026-03-28 08:26:18 +01:00
Compare commits
11 Commits
v0.12.1
...
57bfe72486
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57bfe72486 | ||
|
|
75f66b0246 | ||
|
|
ce93d54aa7 | ||
|
|
39dbe0eac5 | ||
|
|
7282044f80 | ||
|
|
d77c37c0b0 | ||
|
|
e362cbbca5 | ||
|
|
118544926b | ||
|
|
d4bb0a0a30 | ||
|
|
fe5e35d1a9 | ||
|
|
60a6ae2caa |
5
.github/workflows/release.yml
vendored
5
.github/workflows/release.yml
vendored
@@ -3,7 +3,7 @@ name: Make release and binaries
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -29,7 +29,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '^1.22.1'
|
||||
go-version: "^1.22.1"
|
||||
|
||||
- name: GoReleaser beszel
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
@@ -40,3 +40,4 @@ jobs:
|
||||
args: release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.TOKEN || secrets.GITHUB_TOKEN }}
|
||||
WINGET_TOKEN: ${{ secrets.WINGET_TOKEN }}
|
||||
|
||||
@@ -188,6 +188,7 @@ winget:
|
||||
publisher_support_url: "https://github.com/henrygd/beszel/issues"
|
||||
short_description: "Agent for Beszel, a lightweight server monitoring platform."
|
||||
skip_upload: auto
|
||||
token: "{{ .Env.WINGET_TOKEN }}"
|
||||
description: |
|
||||
Beszel is a lightweight server monitoring platform that includes Docker
|
||||
statistics, historical data, and alert functions. It has a friendly web
|
||||
|
||||
@@ -111,7 +111,7 @@ func main() {
|
||||
serverConfig.Addr = addr
|
||||
serverConfig.Network = agent.GetNetwork(addr)
|
||||
|
||||
agent, err := agent.NewAgent("")
|
||||
agent, err := agent.NewAgent()
|
||||
if err != nil {
|
||||
log.Fatal("Failed to create agent: ", err)
|
||||
}
|
||||
|
||||
@@ -40,13 +40,13 @@ type Agent struct {
|
||||
|
||||
// NewAgent creates a new agent with the given data directory for persisting data.
|
||||
// If the data directory is not set, it will attempt to find the optimal directory.
|
||||
func NewAgent(dataDir string) (agent *Agent, err error) {
|
||||
func NewAgent(dataDir ...string) (agent *Agent, err error) {
|
||||
agent = &Agent{
|
||||
fsStats: make(map[string]*system.FsStats),
|
||||
cache: NewSessionCache(69 * time.Second),
|
||||
}
|
||||
|
||||
agent.dataDir, err = getDataDir(dataDir)
|
||||
agent.dataDir, err = getDataDir(dataDir...)
|
||||
if err != nil {
|
||||
slog.Warn("Data directory not found")
|
||||
} else {
|
||||
|
||||
@@ -87,5 +87,5 @@ export default function AreaChartDefault({
|
||||
</ChartContainer>
|
||||
</div>
|
||||
)
|
||||
}, [chartData.systemStats.length, yAxisWidth, maxToggled])
|
||||
}, [chartData.systemStats.at(-1), yAxisWidth, maxToggled])
|
||||
}
|
||||
|
||||
@@ -174,17 +174,11 @@ export default function SystemsTable() {
|
||||
invertSorting: false,
|
||||
Icon: ServerIcon,
|
||||
cell: (info) => (
|
||||
<span className="flex gap-0.5 items-center text-base md:ps-1 md:pe-5">
|
||||
<span className="flex gap-2 items-center md:ps-1 md:pe-5">
|
||||
<IndicatorDot system={info.row.original} />
|
||||
<Button
|
||||
data-nolink
|
||||
variant={"ghost"}
|
||||
className="text-primary/90 h-7 px-1.5 gap-1.5"
|
||||
onClick={() => copyToClipboard(info.getValue() as string)}
|
||||
>
|
||||
<span className="font-medium text-sm">
|
||||
{info.getValue() as string}
|
||||
<CopyIcon className="size-2.5" />
|
||||
</Button>
|
||||
</span>
|
||||
</span>
|
||||
),
|
||||
header: sortableHeader,
|
||||
@@ -721,6 +715,10 @@ const ActionsButton = memo(({ system }: { system: SystemRecord }) => {
|
||||
</>
|
||||
)}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => copyToClipboard(name)}>
|
||||
<CopyIcon className="me-2.5 size-4" />
|
||||
<Trans>Copy name</Trans>
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={() => copyToClipboard(host)}>
|
||||
<CopyIcon className="me-2.5 size-4" />
|
||||
<Trans>Copy host</Trans>
|
||||
|
||||
@@ -16,7 +16,7 @@ It has a friendly web interface, simple configuration, and is ready to use out o
|
||||
- **Lightweight**: Smaller and less resource-intensive than leading solutions.
|
||||
- **Simple**: Easy setup with little manual configuration required.
|
||||
- **Docker stats**: Tracks CPU, memory, and network usage history for each container.
|
||||
- **Alerts**: Configurable alerts for CPU, memory, disk, bandwidth, temperature, and status.
|
||||
- **Alerts**: Configurable alerts for CPU, memory, disk, bandwidth, temperature, load average, and status.
|
||||
- **Multi-user**: Users manage their own systems. Admins can share systems across users.
|
||||
- **OAuth / OIDC**: Supports many OAuth2 providers. Password auth can be disabled.
|
||||
- **Automatic backups**: Save to and restore from disk or S3-compatible storage.
|
||||
|
||||
@@ -31,10 +31,12 @@ if ! getent passwd "$SERVICE_USER" >/dev/null; then
|
||||
--gecos "System user for $SERVICE"
|
||||
fi
|
||||
|
||||
# Enable docker
|
||||
if ! getent group docker | grep -q "$SERVICE_USER"; then
|
||||
echo "Adding $SERVICE_USER to docker group"
|
||||
usermod -aG docker "$SERVICE_USER"
|
||||
# Enable docker (only if docker group exists)
|
||||
if getent group docker >/dev/null 2>&1; then
|
||||
if ! getent group docker | grep -q "$SERVICE_USER"; then
|
||||
echo "Adding $SERVICE_USER to docker group"
|
||||
usermod -aG docker "$SERVICE_USER"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create config file if it doesn't already exist
|
||||
|
||||
@@ -5,7 +5,7 @@ is_alpine() {
|
||||
}
|
||||
|
||||
is_openwrt() {
|
||||
cat /etc/os-release | grep -q "OpenWrt"
|
||||
grep -qi "OpenWrt" /etc/os-release
|
||||
}
|
||||
|
||||
# If SELinux is enabled, set the context of the binary
|
||||
@@ -227,8 +227,8 @@ if [ "$UNINSTALL" = true ]; then
|
||||
rm -f /var/log/beszel-agent.log /var/log/beszel-agent.err
|
||||
elif is_openwrt; then
|
||||
echo "Stopping and disabling the agent service..."
|
||||
service beszel-agent stop
|
||||
service beszel-agent disable
|
||||
/etc/init.d/beszel-agent stop
|
||||
/etc/init.d/beszel-agent disable
|
||||
|
||||
echo "Removing the OpenWRT service files..."
|
||||
rm -f /etc/init.d/beszel-agent
|
||||
@@ -288,13 +288,13 @@ package_installed() {
|
||||
}
|
||||
|
||||
# Check for package manager and install necessary packages if not installed
|
||||
if is_alpine; then
|
||||
if ! package_installed tar || ! package_installed curl || ! package_installed coreutils; then
|
||||
if package_installed apk; then
|
||||
if ! package_installed tar || ! package_installed curl || ! package_installed sha256sum; then
|
||||
apk update
|
||||
apk add tar curl coreutils shadow
|
||||
fi
|
||||
elif is_openwrt; then
|
||||
if ! package_installed tar || ! package_installed curl || ! package_installed coreutils; then
|
||||
elif package_installed opkg; then
|
||||
if ! package_installed tar || ! package_installed curl || ! package_installed sha256sum; then
|
||||
opkg update
|
||||
opkg install tar curl coreutils
|
||||
fi
|
||||
@@ -335,11 +335,10 @@ else
|
||||
fi
|
||||
|
||||
# Create a dedicated user for the service if it doesn't exist
|
||||
echo "Creating a dedicated user for the Beszel Agent service..."
|
||||
if is_alpine; then
|
||||
if ! id -u beszel >/dev/null 2>&1; then
|
||||
echo "Creating a dedicated group for the Beszel Agent service..."
|
||||
addgroup beszel
|
||||
echo "Creating a dedicated user for the Beszel Agent service..."
|
||||
adduser -S -D -H -s /sbin/nologin -G beszel beszel
|
||||
fi
|
||||
# Add the user to the docker group to allow access to the Docker socket if group docker exists
|
||||
@@ -347,10 +346,37 @@ if is_alpine; then
|
||||
echo "Adding beszel to docker group"
|
||||
usermod -aG docker beszel
|
||||
fi
|
||||
|
||||
elif is_openwrt; then
|
||||
# Create beszel group first if it doesn't exist (check /etc/group directly)
|
||||
if ! grep -q "^beszel:" /etc/group >/dev/null 2>&1; then
|
||||
echo "beszel:x:999:" >> /etc/group
|
||||
fi
|
||||
|
||||
# Create beszel user if it doesn't exist (double-check to prevent duplicates)
|
||||
if ! id -u beszel >/dev/null 2>&1 && ! grep -q "^beszel:" /etc/passwd >/dev/null 2>&1; then
|
||||
echo "beszel:x:999:999::/nonexistent:/bin/false" >> /etc/passwd
|
||||
fi
|
||||
|
||||
# Add the user to the docker group if docker group exists and user is not already in it
|
||||
if grep -q "^docker:" /etc/group >/dev/null 2>&1; then
|
||||
echo "Adding beszel to docker group"
|
||||
# Check if beszel is already in docker group
|
||||
if ! grep "^docker:" /etc/group | grep -q "beszel"; then
|
||||
# Add beszel to docker group by modifying /etc/group
|
||||
# Handle both cases: group with existing members and group without members
|
||||
if grep "^docker:" /etc/group | grep -q ":.*:.*$"; then
|
||||
# Group has existing members, append with comma
|
||||
sed -i 's/^docker:\([^:]*:[^:]*:\)\(.*\)$/docker:\1\2,beszel/' /etc/group
|
||||
else
|
||||
# Group has no members, just append
|
||||
sed -i 's/^docker:\([^:]*:[^:]*:\)$/docker:\1beszel/' /etc/group
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
if ! id -u beszel >/dev/null 2>&1; then
|
||||
echo "Creating a dedicated user for the Beszel Agent service..."
|
||||
useradd --system --home-dir /nonexistent --shell /bin/false beszel
|
||||
fi
|
||||
# Add the user to the docker group to allow access to the Docker socket if group docker exists
|
||||
@@ -427,6 +453,11 @@ set_selinux_context
|
||||
# Cleanup
|
||||
rm -rf "$TEMP_DIR"
|
||||
|
||||
# Make sure /etc/machine-id exists for persistent fingerprint
|
||||
if [ ! -f /etc/machine-id ]; then
|
||||
cat /proc/sys/kernel/random/uuid | tr -d '-' > /etc/machine-id
|
||||
fi
|
||||
|
||||
# Check for NVIDIA GPUs and grant device permissions for systemd service
|
||||
detect_nvidia_devices() {
|
||||
local devices=""
|
||||
@@ -546,10 +577,7 @@ start_service() {
|
||||
procd_set_param command /opt/beszel-agent/beszel-agent
|
||||
procd_set_param user beszel
|
||||
procd_set_param pidfile /var/run/beszel-agent.pid
|
||||
procd_set_param env PORT="$PORT"
|
||||
procd_set_param env KEY="$KEY"
|
||||
procd_set_param env TOKEN="$TOKEN"
|
||||
procd_set_param env HUB_URL="$HUB_URL"
|
||||
procd_set_param env PORT="$PORT" KEY="$KEY" TOKEN="$TOKEN" HUB_URL="$HUB_URL"
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_close_instance
|
||||
@@ -573,10 +601,10 @@ EOF
|
||||
|
||||
# Enable the service
|
||||
chmod +x /etc/init.d/beszel-agent
|
||||
service beszel-agent enable
|
||||
/etc/init.d/beszel-agent enable
|
||||
|
||||
# Start the service
|
||||
service beszel-agent restart
|
||||
/etc/init.d/beszel-agent restart
|
||||
|
||||
# Auto-update service for OpenWRT using a crontab job
|
||||
if [ "$AUTO_UPDATE_FLAG" = "true" ]; then
|
||||
@@ -604,9 +632,9 @@ EOF
|
||||
esac
|
||||
|
||||
# Check service status
|
||||
if ! service beszel-agent running >/dev/null 2>&1; then
|
||||
if ! /etc/init.d/beszel-agent running >/dev/null 2>&1; then
|
||||
echo "Error: The Beszel Agent service is not running."
|
||||
service beszel-agent status
|
||||
/etc/init.d/beszel-agent status
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
@@ -217,13 +217,6 @@ function Update-ServicePath {
|
||||
throw "NSSM is not available in PATH and no valid NSSMPath was provided"
|
||||
}
|
||||
|
||||
# Stop the service
|
||||
Write-Host "Stopping beszel-agent service..."
|
||||
& $nssmCommand stop beszel-agent
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Warning: Failed to stop service, continuing anyway..." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Update the application path
|
||||
& $nssmCommand set beszel-agent Application $NewAgentPath
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
@@ -233,7 +226,25 @@ function Update-ServicePath {
|
||||
Write-Host "Service path updated to: $NewAgentPath"
|
||||
|
||||
# Start the service
|
||||
Start-BeszelAgentService -NSSMPath $nssmCommand
|
||||
}
|
||||
|
||||
# Function to start and monitor the service
|
||||
function Start-BeszelAgentService {
|
||||
param (
|
||||
[string]$NSSMPath = ""
|
||||
)
|
||||
|
||||
Write-Host "Starting beszel-agent service..."
|
||||
|
||||
# Determine the NSSM executable to use
|
||||
$nssmCommand = "nssm"
|
||||
if ($NSSMPath -and (Test-Path $NSSMPath)) {
|
||||
$nssmCommand = $NSSMPath
|
||||
} elseif (-not (Test-CommandExists "nssm")) {
|
||||
throw "NSSM is not available in PATH and no valid NSSMPath was provided"
|
||||
}
|
||||
|
||||
& $nssmCommand start beszel-agent
|
||||
$startResult = $LASTEXITCODE
|
||||
|
||||
@@ -255,7 +266,7 @@ function Update-ServicePath {
|
||||
|
||||
if ($serviceStatus -eq "SERVICE_RUNNING") {
|
||||
$serviceStarted = $true
|
||||
Write-Host "Success! The beszel-agent service is now running with the updated path." -ForegroundColor Green
|
||||
Write-Host "Success! The beszel-agent service is now running." -ForegroundColor Green
|
||||
}
|
||||
elseif ($serviceStatus -like "*PENDING*") {
|
||||
Write-Host "Service is still starting (status: $serviceStatus)... waiting" -ForegroundColor Yellow
|
||||
@@ -273,7 +284,7 @@ function Update-ServicePath {
|
||||
}
|
||||
} else {
|
||||
# NSSM start command was successful
|
||||
Write-Host "Success! The beszel-agent service is running with the updated path." -ForegroundColor Green
|
||||
Write-Host "Success! The beszel-agent service is running properly." -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +298,6 @@ $isAdmin = Test-Admin
|
||||
try {
|
||||
Write-Host "Beszel Agent Upgrade Script" -ForegroundColor Cyan
|
||||
Write-Host "===========================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# First: Check if service exists (doesn't require admin)
|
||||
$existingService = Get-Service -Name "beszel-agent" -ErrorAction SilentlyContinue
|
||||
@@ -312,6 +322,13 @@ try {
|
||||
Write-Host "Retrieving current service configuration..."
|
||||
$currentConfig = Get-ServiceConfiguration -NSSMPath $nssmPath
|
||||
|
||||
# Stop the service before upgrade
|
||||
Write-Host "Stopping beszel-agent service..."
|
||||
& $nssmPath stop beszel-agent
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "Warning: Failed to stop service, continuing anyway..." -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# Upgrade the agent (doesn't require admin)
|
||||
Write-Host "Upgrading beszel-agent..."
|
||||
$newAgentPath = $null
|
||||
@@ -340,7 +357,8 @@ try {
|
||||
|
||||
# Check if the path has changed
|
||||
if ($currentConfig.CurrentPath -eq $newAgentPath) {
|
||||
Write-Host "Agent path has not changed. Service update not needed." -ForegroundColor Green
|
||||
Write-Host "Agent path has not changed. Restarting service..." -ForegroundColor Green
|
||||
Start-BeszelAgentService -NSSMPath $nssmPath
|
||||
Write-Host "Upgrade completed successfully!" -ForegroundColor Green
|
||||
exit 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user