# Beszel - Server Monitoring Dashboard

## Overview

- **Hub URL:** https://dashboard.georgsen.dk (or http://10.5.0.10:8090)
- **Credentials:** `~/.config/beszel/credentials`
- **Backend:** PocketBase (REST API)
- **Retention:** 30 days (automatic averaging)

## Architecture

```
Hub (Dockge 10.5.0.10:8090)
  ├── core (10.5.0.254:45876) - PVE host
  └── pbs (10.5.0.6:45876) - Backup server + Synology mount
```

## Helper Script

```bash
~/bin/beszel list                        # List all systems
~/bin/beszel status                      # Show system metrics
~/bin/beszel add <name> <host> [port]    # Add a system
~/bin/beszel delete <id>                 # Delete a system
~/bin/beszel alerts                      # List alerts
```

## Adding a New System

### 1. Install Agent

```bash
# Download binary
curl -sL "https://github.com/henrygd/beszel/releases/latest/download/beszel-agent_linux_amd64.tar.gz" | tar -xzf - -C /usr/local/bin beszel-agent
chmod +x /usr/local/bin/beszel-agent

# Create systemd service
cat > /etc/systemd/system/beszel-agent.service << 'EOF'
[Unit]
Description=Beszel Agent
After=network.target

[Service]
Environment="KEY=<SSH_KEY_FROM_CREDENTIALS>"
Environment="PORT=45876"
ExecStart=/usr/local/bin/beszel-agent
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

# Enable and start
systemctl daemon-reload
systemctl enable beszel-agent
systemctl start beszel-agent
```

### 2. Add to Hub

```bash
~/bin/beszel add <name> <host>
```

## Monitoring Extra Filesystems

To monitor additional mounts (e.g., NFS, CIFS):

```bash
# Add to systemd service
Environment="EXTRA_FILESYSTEMS=/mnt/synology,/mnt/other"
```

## API Access

Beszel uses PocketBase. Python SDK:

```python
from pocketbase import PocketBase

pb = PocketBase('http://10.5.0.10:8090')
pb.admins.auth_with_password(email, password)

# List systems
systems = pb.collection('systems').get_full_list()

# Add system
pb.collection('systems').create({
    'name': 'hostname',
    'host': '10.5.0.x',
    'port': 45876,
    'users': [user_id]
})
```

## References

- [Beszel GitHub](https://github.com/henrygd/beszel)
- [Beszel Docs](https://beszel.dev/)
- [PocketBase API](https://pocketbase.io/docs/api-records/)
