|
| 1 | +# Getting Started with Gearbox |
| 2 | + |
| 3 | +Welcome to Gearbox! This guide will walk you through setting up your first monitored server or workstation (we call these "Boxes"). |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +Gearbox is a plugin-based server monitoring and management platform that consists of two components: |
| 8 | + |
| 9 | +- **Gearbox Dashboard** - Web interface for monitoring multiple servers (port 3000) |
| 10 | +- **Gearbox Agent** - Lightweight service installed on each Box you want to monitor (port 8405) |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +- A Linux server or workstation to monitor (the "Box") |
| 15 | +- Go 1.21+ installed on the Box (for building the agent) |
| 16 | +- Network connectivity between the dashboard and the Box on port 8405 |
| 17 | + |
| 18 | +## Quick Start |
| 19 | + |
| 20 | +### Step 1: Install Gearbox Dashboard |
| 21 | + |
| 22 | +The dashboard is where you'll view and manage all your monitored Boxes. |
| 23 | + |
| 24 | +```bash |
| 25 | +# Clone the repository |
| 26 | +git clone https://github.com/sarg3nt/gearbox.git |
| 27 | +cd gearbox/gearbox |
| 28 | + |
| 29 | +# Build the dashboard |
| 30 | +make build |
| 31 | + |
| 32 | +# Run the dashboard |
| 33 | +./bin/gearbox |
| 34 | +``` |
| 35 | + |
| 36 | +The dashboard will be available at `http://localhost:3000` |
| 37 | + |
| 38 | +### Step 2: Install Gearbox Agent on Your Box |
| 39 | + |
| 40 | +On the server or workstation you want to monitor: |
| 41 | + |
| 42 | +```bash |
| 43 | +# Clone the repository |
| 44 | +git clone https://github.com/sarg3nt/gearbox.git |
| 45 | +cd gearbox/gearbox-agent |
| 46 | + |
| 47 | +# Build the agent |
| 48 | +make build |
| 49 | + |
| 50 | +# The agent binary will be in ./bin/gearbox-agent |
| 51 | +``` |
| 52 | + |
| 53 | +### Step 3: Generate an API Key |
| 54 | + |
| 55 | +1. Open the Gearbox dashboard at `http://localhost:3000` |
| 56 | +2. Navigate to **Settings > Servers** and click **Add Server** |
| 57 | +3. Click the **Generate API Key** button |
| 58 | +4. Copy the generated API key to your clipboard |
| 59 | +5. **Important:** Save this key somewhere safe - you won't be able to see it again! |
| 60 | + |
| 61 | +### Step 4: Configure the Agent |
| 62 | + |
| 63 | +Create a configuration file or set environment variables on your Box: |
| 64 | + |
| 65 | +#### Option A: Environment Variables (Recommended) |
| 66 | + |
| 67 | +```bash |
| 68 | +export GEARBOX_API_KEY="your-generated-api-key-here" |
| 69 | +export GEARBOX_PORT="8405" # Optional, defaults to 8405 |
| 70 | +``` |
| 71 | + |
| 72 | +Add these to your shell profile (`~/.bashrc`, `~/.zshrc`) or create a systemd service file to make them persistent. |
| 73 | + |
| 74 | +#### Option B: Configuration File |
| 75 | + |
| 76 | +Create `/etc/gearbox-agent/config.yaml`: |
| 77 | + |
| 78 | +```yaml |
| 79 | +api_key: "your-generated-api-key-here" |
| 80 | +port: 8405 |
| 81 | +``` |
| 82 | +
|
| 83 | +### Step 5: Start the Agent |
| 84 | +
|
| 85 | +```bash |
| 86 | +# Start the agent |
| 87 | +cd gearbox-agent |
| 88 | +./bin/gearbox-agent |
| 89 | +``` |
| 90 | + |
| 91 | +The agent will start on port 8405 and begin collecting system metrics. |
| 92 | + |
| 93 | +### Step 6: Add the Box to Your Dashboard |
| 94 | + |
| 95 | +1. Return to the Gearbox dashboard |
| 96 | +2. In the **Add Server** form, fill in: |
| 97 | + - **Server Name**: A friendly name (e.g., "Production Web Server") |
| 98 | + - **Server ID**: A unique identifier (e.g., "web-prod-01") |
| 99 | + - **Agent URL**: The URL to your agent (e.g., `http://192.168.1.100:8405`) |
| 100 | + - **API Key**: Paste the API key you generated earlier |
| 101 | +3. Click **Test Connection** to verify connectivity |
| 102 | +4. Click **Add Server** to save |
| 103 | + |
| 104 | +### Step 7: Enable Plugins |
| 105 | + |
| 106 | +After adding your first Box: |
| 107 | + |
| 108 | +1. Navigate to **Settings > Plugins** |
| 109 | +2. Enable the plugins you want to use: |
| 110 | + - **HAProxy** - HAProxy monitoring and statistics |
| 111 | + - **Metrics** - System metrics visualization |
| 112 | + - **Services** - Service management and monitoring |
| 113 | + - **Certificates** - TLS certificate tracking |
| 114 | + - **Logs** - Log aggregation and viewing |
| 115 | + - **Traffic** - Traffic analysis and visualization |
| 116 | + - **Alerts** - Alert management |
| 117 | + - **OS Updates** - OS package updates |
| 118 | + |
| 119 | +When you enable a plugin, its default dashboard will be automatically created and added to the navigation. |
| 120 | + |
| 121 | +## Running as a System Service |
| 122 | + |
| 123 | +### Systemd Service (Linux) |
| 124 | + |
| 125 | +Create `/etc/systemd/system/gearbox-agent.service`: |
| 126 | + |
| 127 | +```ini |
| 128 | +[Unit] |
| 129 | +Description=Gearbox Agent - Server Monitoring |
| 130 | +After=network.target |
| 131 | + |
| 132 | +[Service] |
| 133 | +Type=simple |
| 134 | +User=gearbox |
| 135 | +WorkingDirectory=/opt/gearbox-agent |
| 136 | +Environment="GEARBOX_API_KEY=your-api-key-here" |
| 137 | +Environment="GEARBOX_PORT=8405" |
| 138 | +ExecStart=/opt/gearbox-agent/bin/gearbox-agent |
| 139 | +Restart=always |
| 140 | +RestartSec=10 |
| 141 | + |
| 142 | +[Install] |
| 143 | +WantedBy=multi-user.target |
| 144 | +``` |
| 145 | + |
| 146 | +Enable and start the service: |
| 147 | + |
| 148 | +```bash |
| 149 | +sudo systemctl daemon-reload |
| 150 | +sudo systemctl enable gearbox-agent |
| 151 | +sudo systemctl start gearbox-agent |
| 152 | +sudo systemctl status gearbox-agent |
| 153 | +``` |
| 154 | + |
| 155 | +## Auto-Discovery |
| 156 | + |
| 157 | +Gearbox Agent automatically discovers services running on your Box: |
| 158 | + |
| 159 | +- **HAProxy** - Detects running HAProxy instances and collects stats |
| 160 | +- **Docker** - Discovers Docker containers and images |
| 161 | +- **System Services** - Monitors systemd services |
| 162 | + |
| 163 | +No manual configuration required! Just enable the relevant plugins in the dashboard. |
| 164 | + |
| 165 | +## Security Considerations |
| 166 | + |
| 167 | +1. **API Key Security**: Treat your API key like a password. Never commit it to version control. |
| 168 | +2. **Network Security**: Use a firewall to restrict access to port 8405 to only your dashboard server. |
| 169 | +3. **HTTPS**: In production, run both the dashboard and agent behind a reverse proxy with HTTPS. |
| 170 | +4. **Authentication**: The dashboard supports password authentication and WebAuthn. Enable it for production use. |
| 171 | + |
| 172 | +## Troubleshooting |
| 173 | + |
| 174 | +### Agent Won't Start |
| 175 | + |
| 176 | +- Verify the `GEARBOX_API_KEY` environment variable is set |
| 177 | +- Check if port 8405 is available: `sudo netstat -tulpn | grep 8405` |
| 178 | +- Review agent logs for errors |
| 179 | + |
| 180 | +### Connection Test Fails |
| 181 | + |
| 182 | +- Verify the Agent URL is correct and accessible from the dashboard server |
| 183 | +- Check firewall rules on both the dashboard and Box |
| 184 | +- Confirm the API key matches between dashboard and agent |
| 185 | +- Use `curl` to test: `curl http://your-box:8405/health` |
| 186 | + |
| 187 | +### No Data Showing |
| 188 | + |
| 189 | +- Wait 30-60 seconds for the first data collection cycle |
| 190 | +- Verify the plugin is enabled in **Settings > Plugins** |
| 191 | +- Check that the service you're trying to monitor is actually running on the Box |
| 192 | +- Review agent logs for collection errors |
| 193 | + |
| 194 | +## Next Steps |
| 195 | + |
| 196 | +- **Customize Dashboards**: Create custom dashboards with your favorite widgets |
| 197 | +- **Configure Alerts**: Set up alert rules for critical metrics |
| 198 | +- **Enable GitOps**: Configure git sync for dashboard definitions |
| 199 | +- **Add More Boxes**: Repeat the process to monitor additional servers |
| 200 | + |
| 201 | +## Getting Help |
| 202 | + |
| 203 | +- **Documentation**: [GitHub Repository](https://github.com/sarg3nt/gearbox) |
| 204 | +- **Issues**: [Report a Bug](https://github.com/sarg3nt/gearbox/issues) |
| 205 | +- **Architecture**: See [docs/plugins.md](plugins.md) for plugin architecture details |
| 206 | + |
| 207 | +## What's Next? |
| 208 | + |
| 209 | +Now that you have Gearbox running, explore: |
| 210 | + |
| 211 | +1. **Widget System**: Learn how to create custom widgets |
| 212 | +2. **Plugin Development**: Build your own monitoring plugins |
| 213 | +3. **Dashboard Layouts**: Customize dashboard arrangements |
| 214 | +4. **Advanced Configuration**: Explore environment variables and configuration options |
| 215 | + |
| 216 | +Happy monitoring! 📊 |
0 commit comments