Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy Documentation

on:
push:
branches:
- main
paths:
- 'docs/**'
- 'mkdocs.yml'
- '.github/workflows/docs-deploy.yml'
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v4
Comment thread
martian56 marked this conversation as resolved.
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'docs/requirements.txt'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r docs/requirements.txt

- name: Build documentation
run: mkdocs build

- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: chatops-docs
directory: site
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,7 @@ htmlcov/

# Architecture
ARCHITECTURE.md

# Documentation
site/
.cache/
8 changes: 4 additions & 4 deletions agent/INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

```bash
# Download the .deb package from GitHub Releases
wget https://github.com/martian56/chatops/releases/download/v1.0.3/chatops-agent_1.0.3_amd64.deb
wget https://github.com/martian56/chatops/releases/download/v1.0.4/chatops-agent_1.0.4_amd64.deb

# Install the package
sudo dpkg -i chatops-agent_1.0.3_amd64.deb
sudo dpkg -i chatops-agent_1.0.4_amd64.deb
sudo apt-get install -f # Install dependencies if needed

# Edit the service file with your API key
Expand All @@ -49,8 +49,8 @@ sudo systemctl status chatops-agent

```bash
# Download from GitHub Releases
wget https://github.com/martian56/chatops/releases/download/v1.0.3/chatops-agent-linux-amd64-1.0.3.tar.gz
tar -xzf chatops-agent-linux-amd64-1.0.3.tar.gz
wget https://github.com/martian56/chatops/releases/download/v1.0.4/chatops-agent-linux-amd64-1.0.4.tar.gz
tar -xzf chatops-agent-linux-amd64-1.0.4.tar.gz

# Run the agent
./chatops-agent-linux-amd64 -api-key YOUR_API_KEY_HERE
Expand Down
3 changes: 3 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Documentation
site/
.cache/
58 changes: 58 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Documentation

This directory contains the MkDocs documentation for ChatOps.

## Building Locally

### Prerequisites

- Python 3.12+
- pip

### Setup

```bash
# Install dependencies
pip install -r requirements-docs.txt
Comment thread
martian56 marked this conversation as resolved.

# Serve documentation locally
mkdocs serve
```

The documentation will be available at `http://localhost:8000`

### Build Static Site

```bash
mkdocs build
```

The static site will be generated in the `site/` directory.

## Documentation Structure

- `index.md` - Homepage
- `getting-started/` - Getting started guides
- `architecture/` - System architecture
- `api/` - API documentation
- `agent/` - Agent documentation
- `frontend/` - Frontend documentation
- `technologies/` - Technology stack
- `deployment/` - Deployment guides
- `contributing/` - Contribution guidelines

## Deployment

Documentation is automatically deployed to Cloudflare Pages on push to `main` branch.

See `.github/workflows/docs-deploy.yml` for deployment configuration.

## Contributing

When adding or updating documentation:

1. Edit the relevant `.md` file
2. Test locally with `mkdocs serve`
3. Commit and push
4. Documentation will be automatically deployed

65 changes: 65 additions & 0 deletions docs/agent/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Agent Configuration

Configuration options for the ChatOps agent.

## Configuration Methods

### Command-line Flags

```bash
./chatops-agent \
-api-key YOUR_API_KEY \
-api-url https://your-chatops-instance.com
```

### Environment Variables

```bash
export CHATOPS_API_KEY="your-api-key-here"
export CHATOPS_API_URL="https://your-chatops-instance.com"
./chatops-agent
```

### Config File

Create a JSON config file:

```json
{
"api_key": "your-api-key-here",
"api_url": "https://your-chatops-instance.com"
}
```

Use with:
```bash
./chatops-agent -config /path/to/config.json
```

## Configuration Options

### API Key

- **Required**: Yes
- **Flag**: `-api-key`
- **Env**: `CHATOPS_API_KEY`
- **Description**: API key for authentication

### API URL

- **Required**: No (default: https://chatops.onrender.com)
- **Flag**: `-api-url`
- **Env**: `CHATOPS_API_URL`
- **Description**: ChatOps API server URL

## Defaults

- **API URL**: `https://chatops.onrender.com`
- **Metrics Interval**: 5 seconds
- **Reconnection Delay**: Exponential backoff starting at 1 second

## Next Steps

- [Installation Guide](installation.md)
- [Development Guide](development.md)

54 changes: 54 additions & 0 deletions docs/agent/development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Agent Development

Development guide for the ChatOps agent.

## Prerequisites

- Go 1.24+
- Docker (optional, for testing Docker features)

## Building

```bash
cd agent
go build -o chatops-agent ./main.go
```

## Running Locally

```bash
./chatops-agent -api-key YOUR_API_KEY -api-url http://localhost:8000
```

## Project Structure

```
agent/
├── main.go # Entry point
├── internal/
│ ├── agent/ # Agent core logic
│ ├── api/ # API client
│ ├── config/ # Configuration
│ ├── metrics/ # Metrics collection
│ └── pkg/ # Shared packages
└── package/ # Packaging scripts
```

## Testing

```bash
go test ./...
```

## Contributing

1. Follow Go best practices
2. Write tests for new features
3. Update documentation
4. Submit pull request

## Next Steps

- [Installation Guide](installation.md)
- [Configuration Guide](configuration.md)

122 changes: 122 additions & 0 deletions docs/agent/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Agent Documentation

The ChatOps agent is a lightweight Go application that runs on each monitored server.

## Overview

The agent is responsible for:

- **Metrics Collection**: CPU, memory, disk, and network metrics every 5 seconds
- **Docker Management**: Container lifecycle operations
- **Command Execution**: Remote command execution via WebSocket
- **Real-time Communication**: Bidirectional WebSocket connection to API

## Features

- ✅ Lightweight and efficient (single binary)
- ✅ Low resource usage
- ✅ Automatic reconnection
- ✅ Secure API key authentication
- ✅ Docker integration
- ✅ System metrics collection
- ✅ Command execution with output capture

## Architecture

```
┌─────────────────────────────────────────┐
│ Go Agent │
├─────────────────────────────────────────┤
│ Components │
│ ├── Metrics Collector │
│ │ ├── CPU │
│ │ ├── Memory │
│ │ ├── Disk │
│ │ └── Network │
│ ├── Docker Client │
│ ├── WebSocket Client │
│ └── Command Executor │
├─────────────────────────────────────────┤
│ Communication │
│ ├── WebSocket Connection │
│ ├── Authentication (API Key) │
│ └── Message Protocol │
└─────────────────────────────────────────┘
```

## Quick Start

1. **Get an API Key**: Create one in the web interface
2. **Download Agent**: Get the binary for your platform
3. **Run Agent**: `./chatops-agent -api-key YOUR_KEY`
4. **Verify**: Check the web interface for metrics

See [Installation Guide](installation.md) for detailed instructions.

## Configuration

The agent can be configured via:

- **Command-line flags**: `-api-key`, `-api-url`
- **Environment variables**: `CHATOPS_API_KEY`, `CHATOPS_API_URL`
- **Config file**: JSON configuration file (optional)

See [Configuration Guide](configuration.md) for details.

## Communication Protocol

### Agent → API

**Message Types**:
- `auth`: Initial authentication
- `metrics`: System metrics data
- `command_response`: Command execution result
- `docker_response`: Docker operation result

### API → Agent

**Message Types**:
- `auth_success`: Authentication confirmation
- `command`: Command execution request
- `docker_command`: Docker operation request

## Metrics Collection

The agent collects the following metrics every 5 seconds:

- **CPU**: Usage percentage per core
- **Memory**: Total, used, available, percentage
- **Disk**: Usage per filesystem
- **Network**: Bytes sent/received per interface

## Docker Support

The agent can manage Docker containers if Docker is installed:

- List containers
- Start/stop/restart containers
- Get container logs
- Container status information

## Security

- **API Key Authentication**: Secure key-based authentication
- **WebSocket Encryption**: TLS/SSL encryption in production
- **No Root Required**: Agent can run as non-root user
- **Minimal Permissions**: Only requires necessary system access

## Troubleshooting

Common issues and solutions:

- **Connection Failed**: Check API URL and network connectivity
- **Authentication Failed**: Verify API key is correct and active
- **No Metrics**: Ensure agent has necessary system permissions
- **Docker Not Working**: Verify Docker is installed and accessible

## Next Steps

- [Installation Guide](installation.md)
- [Configuration Guide](configuration.md)
- [Development Guide](development.md)

Loading