# Agent install (/docs/agent)

> Install and configure the ServerMetry monitoring agent on Linux, macOS, and Windows.



The ServerMetry agent is a lightweight Python 3.8+ process with **no third-party dependencies**. It collects CPU, memory, disk, network, and process metrics and posts them to the API (default: once per minute).

> Tip: After you add a server in the dashboard, ServerMetry shows the exact install command with your API key pre-filled.

## Linux / macOS [#linux--macos]

Always download and review install scripts before running them with elevated privileges.

```bash
# 1. Download
curl -fsSL https://raw.githubusercontent.com/FloBaMedia/servermetry-client/main/agent/install.sh -o /tmp/install.sh

# 2. Review
cat /tmp/install.sh

# 3. Install (production API)
chmod +x /tmp/install.sh
SERVERMETRY_URL=https://api.servermetry.com SERVERMETRY_KEY=sp_live_... sudo /tmp/install.sh
```

Interactive install (prompts for URL and key):

```bash
curl -fsSL https://raw.githubusercontent.com/FloBaMedia/servermetry-client/main/agent/install.sh -o /tmp/install.sh
chmod +x /tmp/install.sh
sudo /tmp/install.sh
```

## Windows (PowerShell as Administrator) [#windows-powershell-as-administrator]

```powershell
Invoke-WebRequest -Uri 'https://raw.githubusercontent.com/FloBaMedia/servermetry-client/main/agent/install-windows.ps1' -OutFile $env:TEMP\install-servermetry.ps1
Get-Content $env:TEMP\install-servermetry.ps1
& $env:TEMP\install-servermetry.ps1 -ApiUrl "https://api.servermetry.com" -ApiKey "sp_live_..."
```

Install Python **for all users** so the Scheduled Task running as `SYSTEM` can execute it.

## Install paths [#install-paths]

|             | Linux / macOS                    | Windows                                 |
| ----------- | -------------------------------- | --------------------------------------- |
| Install dir | `/etc/servermetry/`              | `C:\ProgramData\ServerMetry\`           |
| Config      | `/etc/servermetry/agent.conf`    | `C:\ProgramData\ServerMetry\agent.conf` |
| Log         | `/var/log/servermetry-agent.log` | `C:\ProgramData\ServerMetry\agent.log`  |
| Scheduler   | crontab (`* * * * *`)            | Scheduled Task (every 1 min)            |
| Runs as     | root                             | SYSTEM                                  |

## Configuration [#configuration]

Config file:

```ini
[servermetry]
api_url = https://api.servermetry.com
api_key  = sp_live_...
debug    = false
```

Environment variables (override the config file):

| Variable              | Description                  |
| --------------------- | ---------------------------- |
| `SERVERMETRY_API_URL` | API base URL                 |
| `SERVERMETRY_API_KEY` | Server API key               |
| `SERVERMETRY_DEBUG`   | Set to `1` for debug logging |

Legacy `SERVERPULSE_*` names are still accepted.

## Remote configuration [#remote-configuration]

On each run the agent fetches `GET /api/v1/agent/config` and can apply timezone, locale, NTP, DNS, report interval, and auto-update settings from the dashboard **Config** tab.

## Useful CLI flags [#useful-cli-flags]

```bash
python agent.py --dry-run          # print metrics as JSON, no HTTP
python agent.py --debug            # verbose stderr logging
python agent.py --no-apply-config  # skip remote config
```

Source and uninstall scripts: [servermetry-client on GitHub](https://github.com/FloBaMedia/servermetry-client).
