No description
  • Go 70.6%
  • templ 28.4%
  • Makefile 0.8%
  • Shell 0.2%
Find a file
eugene b330415b91
Some checks are pending
Release / goreleaser (push) Waiting to run
Refactor dashboard update mechanism and improve agent configuration
- Reduced default agent heartbeat and metrics intervals for improved responsiveness.
- Enhanced the dashboard update system by introducing a new type for update sections, allowing more granular control over live updates.
- Updated the SubscribeToDashboard handler to utilize the new update sections, improving the efficiency of client notifications.
- Modified dashboard templates to support individual live update sections, ensuring timely and relevant data is displayed.

These changes optimize the dashboard's performance and enhance the user experience with more precise updates.
2026-07-02 15:17:43 +03:00
.cursor/rules Enhance host management dialogs and UI components 2026-06-24 11:55:59 +03:00
.github/workflows Add GoReleaser configuration and GitHub Actions workflow for automated releases 2026-06-28 11:12:21 +03:00
.vscode Initialize hosthalla project with basic authentication and host management features 2026-06-23 02:14:54 +03:00
cmd/hosthalla Refactor CLI and web components to unify command structure and enhance functionality 2026-07-01 01:04:31 +03:00
docs Add UI templ documentation and components reference 2026-06-24 01:52:17 +03:00
infra/dev Initialize hosthalla project with basic authentication and host management features 2026-06-23 02:14:54 +03:00
internal Refactor dashboard update mechanism and improve agent configuration 2026-07-02 15:17:43 +03:00
migrations Resolve agent-host consistency gaps and remove dead host note code. 2026-06-29 00:44:05 +03:00
scripts Update WebSocket handling and add installation script for hosthalla 2026-07-02 14:23:09 +03:00
ui Refactor dashboard update mechanism and improve agent configuration 2026-07-02 15:17:43 +03:00
.gitignore Update .gitignore and improve error logging in API handlers 2026-06-28 10:07:44 +03:00
.goreleaser.yaml Refactor CLI command structure and update documentation 2026-07-01 01:11:04 +03:00
go.mod Enhance dashboard functionality with WebSocket support and live updates 2026-07-02 13:32:53 +03:00
go.sum Enhance dashboard functionality with WebSocket support and live updates 2026-07-02 13:32:53 +03:00
LICENSE Add LICENSE and README files for Hosthalla project 2026-06-23 20:39:03 +03:00
Makefile Refactor CLI and web components to unify command structure and enhance functionality 2026-07-01 01:04:31 +03:00
README.md Implement user and agent management commands in CLI 2026-07-01 16:49:12 +03:00

Hosthalla

Self-hosted infrastructure dashboard for managing hosts, SSH credentials, and monitoring agents.

  • Host inventory — add hosts by IP, group them with tags, store SSH access methods
  • ICMP monitoring — ping individual hosts or all at once directly from the UI
  • Remote agents — install a lightweight agent on any Linux machine; it streams system info and live metrics (CPU, memory, disk, network) back to the dashboard
  • API tokens — issue scoped tokens for agent registration and API access

Tech Stack

Layer Technology
Language Go 1.26
HTTP net/http (Go 1.22+ routing)
Database PostgreSQL 18
UI Templ + HTMX
Auth Cookie sessions + bcrypt
API auth hht_-prefixed tokens (SHA-256 stored)
Agent metrics gopsutil/v4

Requirements

  • PostgreSQL 18+ (for running the app)
  • Go 1.26+ (only if you build from source)

Install Script

#!/usr/bin/env bash
set -euo pipefail

REPO="yazmeyaa/hosthalla"
ARCHIVE_PATTERN="linux_amd64"

URL=$(curl -s https://api.github.com/repos/$REPO/releases/latest \
  | jq -r --arg pattern "$ARCHIVE_PATTERN" '.assets[] | select(.name | test($pattern)) | .browser_download_url' \
  | head -n 1)

if [ -z "$URL" ] || [ "$URL" = "null" ]; then
  echo "Could not find release asset for pattern: $ARCHIVE_PATTERN" >&2
  exit 1
fi

TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT

curl -L -o "$TMP/pkg.tar.gz" "$URL"
tar -xzf "$TMP/pkg.tar.gz" -C "$TMP"

for bin in hosthalla; do
  if [ -f "$TMP/$bin" ]; then
    sudo install -m 0755 "$TMP/$bin" "/usr/local/bin/$bin"
  fi
done

Quick Start

1. Install binary

Run the install script above, or download the latest release asset and place hosthalla in your PATH.

2. Generate app config

hosthalla config generate

Default path: ~/.hosthalla/config.yaml.

3. Fill the config

web:
  host: 0.0.0.0
  port: 8080
database:
  host: <postgres-host>
  port: 5432
  user: <postgres-user>
  password: <postgres-password>
  database: <postgres-database>
log_level: warning   # debug | info | warning | error
security:
  secret_encryption_key: <secret_encryption_key>

4. Apply migrations

hosthalla db migrate

5. Start Hosthalla

hosthalla serve

The UI is available at http://localhost:8080.

6. (Optional) Create first user from CLI

hosthalla users create <username> <password>

Building

make build

Builds the binary locally:

  • dist/hosthalla

Release binaries include version, commit, and build timestamp via ldflags.

CLI Reference

The hosthalla binary exposes the server, local agent, and administration commands through one explicit command tree. Legacy command aliases are not supported.

Help

hosthalla help
# or
hosthalla --help

Config commands

# Generate default config at ~/.hosthalla/config.yaml
hosthalla config generate [--path <file>] [--overwrite]

# Print the current config
hosthalla config show [--path <file>]

# Validate the current config
hosthalla config validate [--path <file>]

User management

hosthalla users create <username> <password>
hosthalla users list [--json]
hosthalla users show <user-id-or-username> [--json]
hosthalla users password set <user-id-or-username> <password>
hosthalla users delete <user-id-or-username>

Database commands

# Apply all pending migrations
hosthalla db migrate

# Print current migration version
hosthalla db status [--json]

# Roll back one migration
hosthalla db rollback

Token management

hosthalla tokens list [--user <user-id-or-username>] [--json]
hosthalla tokens create --user <user-id-or-username> --name <name> [--scope <scope>] [--ttl <duration>] [--json]
hosthalla tokens show <token-id> [--json]
hosthalla tokens revoke <token-id>

tokens create prints the plain token once. Store it immediately; later commands show only token metadata.

Host and agent administration

hosthalla hosts list [--json]
hosthalla hosts show <host-id> [--json]
hosthalla hosts delete <host-id>

hosthalla agents list [--json]
hosthalla agents show <agent-id> [--json]
hosthalla agents delete <agent-id>

Agent commands

# Register this machine as an agent for a host
# (The recommended way is to use the "Register Agent" button in the UI,
#  which generates the full command with a pre-filled token.)
hosthalla agent register \
  --host <server-url> \
  --host-id <uuid> \
  --token <hht_...>

# Start the agent worker (heartbeat + metrics loop)
hosthalla agent run [--config <file>]

Agent config is saved to ~/.hosthalla/agent.yaml by default. The agent sends a heartbeat every 5 seconds and metrics every 30 seconds.

Monitoring Agents

  1. Open the dashboard and navigate to a host.
  2. Click Register Agent — a shell command with a scoped API token is generated.
  3. Run hosthalla agent register ... on the target machine.
  4. Run hosthalla agent run on the target machine (or set it up as a systemd service).

The dashboard then shows live CPU, memory, disk, and network metrics for the host.

Agent Quick Start

# 1) Register agent on target host
hosthalla agent register --host <server-url> --host-id <uuid> --token <hht_...>

# 2) Start agent loop
hosthalla agent run

Make Targets

Target Description
make migrate-up Apply all pending migrations
make migrate-down Roll back the last migration
make templ-generate Regenerate *_templ.go files
make help Show available Make targets
make build Build Hosthalla binary
make build-hosthalla Build binary to dist/hosthalla
make dev-web Regenerate Templ files + run the web server

Project Structure

cmd/
  hosthalla/    # Unified CLI entry point
internal/
  agent/        # Agent model, config, gopsutil metrics, worker loop
  api/          # REST API for agents (/api/v1/...)
  authentication/ # Sessions, API tokens, bcrypt passwords
  cli/          # CLI command tree runner
  commands/     # Hosthalla command implementations
  config/       # App config struct, load/save
  host/         # Host domain: model, service, repository interfaces
  logger/       # slog setup
  version/      # Version string injected via ldflags
  web/          # Server-rendered UI handlers and middleware
migrations/     # SQL migration pairs (up/down)
ui/             # Templ components (Feature-Sliced Design)
  app/layout/
  entities/
  features/
  pages/
  shared/ui/
  widgets/
infra/dev/      # local development infrastructure files

License

MIT — see LICENSE.