Skip to content

Repository files navigation

DevTool - DevOps CLI Toolkit

CI Go Report Card License: MIT Go Version

A fast, production-ready CLI toolkit for DevOps engineers, built entirely with Go's standard library.


Features

  • Zero external dependencies -- built exclusively on Go's standard library
  • 10 CLI commands -- HTTP testing, load testing, monitoring, port scanning, SSL cert checking, DNS propagation, Docker health, REST API server
  • Go concurrency -- goroutines, channels, worker pools, and semaphores for parallel operations
  • Colored terminal output -- ANSI color codes with auto-detection and NO_COLOR support
  • Multiple output formats -- --format json|yaml|table on all commands for scripting
  • File export -- --output results.json to write results directly to files
  • Progress bars -- real-time progress indicators for long-running operations
  • Configuration file -- JSON config for customizing defaults per-user
  • Shell completion -- bash, zsh, fish support via devtool completion <shell>
  • Built-in HTTP server -- devtool serve exposes all tools as REST API with CORS
  • Prometheus metrics -- /metrics endpoint with native exposition format
  • Plugin system -- discover and execute external commands from PATH (devtool-*)
  • Structured results -- machine-readable JSON output for CI/CD pipelines
  • Cross-platform -- Linux, macOS, Windows with pre-built binaries
  • Docker ready -- multi-stage build, minimal scratch image
  • Comprehensive tests -- table-driven tests, edge cases, 70%+ coverage

Quick Start

Install

From source:

go install github.com/MuhammadUsmanGM/OpsForge@latest

From release: Download pre-built binaries from Releases

Via Docker:

docker run --rm ghcr.io/muhammadusmangm/opsforge:latest --help

Usage

devtool --help
devtool - DevOps CLI Toolkit

Usage: devtool <command> [arguments]

Commands:
  cert-expiry     Check SSL/TLS certificate expiry and details
  completion      Generate shell completion script
  dns-check       Check DNS propagation and resolution
  docker-health   Check Docker daemon health and container status
  http-test       Send an HTTP request and inspect the response
  load-test       Run HTTP load tests against a URL
  monitor         Continuously monitor a website's availability
  port-scan       Scan TCP ports on a host
  serve           Start HTTP server exposing DevTool commands as REST API
  version         Show version information

Use "devtool <command> --help" for more information about a command.

Commands

http-test

Send an HTTP request and inspect the response with headers, status, and timing.

Flags:

Flag Default Description
-method GET HTTP method
-body Request body
-header Header in Key:Value format (repeatable)
-timeout 10 Timeout in seconds
-format table Output format: table, json, yaml

Example:

devtool http-test -method POST \
  -header "Content-Type:application/json" \
  -header "Authorization:Bearer tok_abc123" \
  -body '{"name":"test"}' \
  https://api.example.com/users

JSON output:

devtool http-test -format json https://api.example.com/users | jq '.status_code'

load-test

Simulate concurrent HTTP traffic using a worker pool and report latency percentiles.

Flags:

Flag Default Description
-n 100 Total number of requests
-c 10 Number of concurrent workers
-method GET HTTP method
-timeout 10 Request timeout in seconds
-format table Output format: table, json, yaml
-quiet false Suppress progress bar output

Example:

devtool load-test -n 500 -c 50 https://example.com

monitor

Continuously monitor a website's availability with periodic HTTP checks. Runs until interrupted or a fixed count is reached.

Flags:

Flag Default Description
-interval 5 Check interval in seconds
-count 0 Number of checks (0 = infinite)
-timeout 10 HTTP timeout in seconds
-format table Output format: table, json, yaml

Example:

devtool monitor -interval 10 -count 5 https://example.com

port-scan

Scan TCP ports on a target host using concurrent goroutines with a configurable worker pool.

Flags:

Flag Default Description
-ports 1-1024 Port range (e.g. 80-443)
-timeout 500 Connection timeout in milliseconds
-concurrency 100 Number of concurrent scans
-format table Output format: table, json, yaml
-quiet false Suppress progress bar output

Example:

devtool port-scan -ports 20-1000 -concurrency 200 192.168.1.1

cert-expiry (NEW)

Check SSL/TLS certificate details including expiry date, issuer, and DNS names.

Flags:

Flag Default Description
-warn-days 30 Days before expiry to warn
-timeout 10 Connection timeout in seconds
-format table Output format: table, json, yaml

Example:

devtool cert-expiry google.com:443
SSL Certificate Information
  Target: google.com:443

  Status:       ✓ VALID
  Subject:      *.google.com
  Issuer:       GTS CA 1C3

  Issued:       2026-03-15
  Expires:      2026-06-07
  Days Left:    88

  DNS Names:    *.google.com, google.com, *.appengine.google.com

dns-check (NEW)

Check DNS propagation and resolution across multiple public DNS servers.

Flags:

Flag Default Description
-servers Comma-separated DNS servers (default: public DNS)
-timeout 5 Query timeout in seconds
-type A DNS record type (A, AAAA, CNAME, MX, NS, TXT)
-format table Output format: table, json, yaml

Example:

devtool dns-check example.com
DNS Resolution Check
  Domain: example.com (A)

  DNS Servers:  6 queried, 6 resolved, 0 failed
  Total Time:   45ms

  SERVER          STATUS  RESULT              LATENCY
  1.0.0.1         ✓       93.184.215.14       42ms
  1.1.1.1         ✓       93.184.215.14       38ms
  8.8.4.4         ✓       93.184.215.14       45ms
  8.8.8.8         ✓       93.184.215.14       41ms
  9.9.9.9         ✓       93.184.215.14       50ms
  208.67.222.222  ✓       93.184.215.14       55ms

docker-health (NEW)

Check Docker daemon health, version, and container status via Unix socket or TCP.

Flags:

Flag Default Description
-socket auto Docker socket path
-timeout 10 Request timeout in seconds
-format table Output format: table, json, yaml

Example:

devtool docker-health

serve (NEW)

Start an HTTP server that exposes all DevTool commands as REST API endpoints. Includes built-in Prometheus metrics and CORS support.

Flags:

Flag Default Description
-host 127.0.0.1 Host to bind to
-port 8080 Port to listen on
-metrics true Enable /metrics endpoint
-cors false Enable CORS headers

Example:

devtool serve --port 8080 --cors

API Endpoints:

GET  /                    - API information
GET  /api/v1/health       - Health check
GET  /api/v1/status       - Server status
POST /api/v1/http-test    - HTTP request testing
POST /api/v1/load-test    - Load testing
POST /api/v1/port-scan    - Port scanning
GET  /api/v1/cert-expiry?host=example.com&port=443 - SSL cert check
GET  /api/v1/dns-check?domain=example.com            - DNS lookup
GET  /metrics             - Prometheus metrics

Example usage:

# Test an endpoint
curl -X POST http://localhost:8080/api/v1/http-test \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "method": "GET"}'

# Get Prometheus metrics
curl http://localhost:8080/metrics

completion

Generate shell completion scripts for bash, zsh, or fish.

Example:

# Bash
devtool completion bash > ~/.devtool-completion.bash
source ~/.devtool-completion.bash

# Zsh
devtool completion zsh > ~/.zsh/completions/_devtool

# Fish
devtool completion fish > ~/.config/fish/completions/devtool.fish

Configuration

DevTool supports user-level configuration via a JSON config file.

Location:

  • Linux/macOS: ~/.config/devtool/config.json
  • Windows: %APPDATA%\devtool\config.json

Example config:

{
  "http_timeout": "30s",
  "http_method": "GET",
  "http_headers": ["Authorization: Bearer my-token"],
  "port_scan_timeout": "1s",
  "port_scan_concurrency": 200,
  "port_scan_range": "1-65535",
  "load_test_concurrency": 50,
  "load_test_requests": 1000,
  "output_format": "json",
  "quiet": false,
  "cert_min_days_before_expiry": 30,
  "dns_timeout": "5s"
}

Command-line flags always override config file values.


File Export

All commands support the --output flag to write results directly to files:

# Export load test results as JSON
devtool load-test -n 100 -format json --output results.json https://example.com

# Export port scan as YAML
devtool port-scan -format yaml --output scan.yaml 192.168.1.1

Plugin System

DevTool supports external plugins discovered from PATH. Any executable named devtool-<command> is automatically discovered:

# Create a plugin
cat > /usr/local/bin/devtool-mytool << 'EOF'
#!/bin/bash
echo "My custom DevTool plugin"
echo "v1.0.0"
EOF
chmod +x /usr/local/bin/devtool-mytool

# Plugin is automatically available
devtool mytool

Plugins receive DEVTOOL_PLUGIN=true environment variable when executed.


Prometheus Metrics

When running devtool serve, Prometheus metrics are available at /metrics:

# HELP devtool_uptime_seconds Time since process started
# TYPE devtool_uptime_seconds gauge
devtool_uptime_seconds 1234.56

# HELP devtool_http_test_duration HTTP test request duration
# TYPE devtool_http_test_duration summary
devtool_http_test_duration_sum{url="https://example.com",status="200"} 150
devtool_http_test_duration_count{url="https://example.com",status="200"} 1

Scrape with Prometheus:

scrape_configs:
  - job_name: 'devtool'
    static_configs:
      - targets: ['localhost:8080']

Project Structure

.
├── main.go                         # Entrypoint
├── cmd/
│   └── root.go                     # Command registry and dispatcher
├── internal/
│   ├── commands/                   # All CLI commands
│   │   ├── httptest.go             # http-test command
│   │   ├── loadtest.go             # load-test command
│   │   ├── monitor.go              # monitor command
│   │   ├── portscan.go             # port-scan command
│   │   ├── version.go              # version command
│   │   ├── completion.go           # completion command
│   │   ├── certexpiry.go           # cert-expiry command
│   │   ├── dnscheck.go             # dns-check command
│   │   ├── dockerhealth.go         # docker-health command
│   │   └── serve.go                # serve command (REST API server)
│   ├── terminal/                   # Colored terminal output
│   ├── formatter/                  # JSON/YAML/Table output formatting
│   ├── progress/                   # Progress bars and spinners
│   ├── config/                     # Configuration file loading
│   ├── metrics/                    # Prometheus metrics and execution tracking
│   ├── plugin/                     # External plugin discovery and execution
│   └── logger/                     # Structured logging
├── .github/workflows/ci.yml        # GitHub Actions CI
├── Dockerfile                      # Multi-stage Docker build
├── .goreleaser.yml                 # GoReleaser release config
└── Makefile                        # Build automation

Architecture

Command registration: Each command file uses an init() function to call cmd.Register(), passing a Command struct. The main package imports commands with a blank identifier (_ "github.com/MuhammadUsmanGM/OpsForge/internal/commands"), triggering registration at startup. Adding new commands requires zero boilerplate in main.go.

Concurrency model: CPU-bound and I/O-bound work uses goroutines with bounded concurrency. port-scan uses a semaphore channel to limit active connections. load-test uses a fixed worker pool consuming jobs from a shared channel. Both collect results via channels and sync.WaitGroup for clean shutdown.

Output pipeline: All commands support --format json|yaml|table and --output <file>. Results are structured as Go structs with JSON tags, then serialized by the formatter package. This enables piping results to jq, yq, or other tools in CI/CD pipelines.

REST API server: devtool serve starts an HTTP server with routes for each tool. Includes request tracking, Prometheus metrics, CORS middleware, and graceful shutdown. All endpoints return JSON for easy integration.

Plugin system: External commands named devtool-* in PATH are automatically discovered and registered. Plugins are executed as subprocesses with DEVTOOL_PLUGIN=true environment variable for detection.

Metrics: The metrics package provides a Prometheus-compatible metrics registry with counters, gauges, and summaries. The /metrics endpoint exposes metrics in the official Prometheus exposition format.


Building

Standard build:

go build -o devtool .

With version metadata:

go build -ldflags "-X devtool/internal/commands.Version=1.0.0 \
  -X devtool/internal/commands.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
  -o devtool .

Cross-platform:

GOOS=linux GOARCH=amd64 go build -o devtool-linux-amd64 .
GOOS=darwin GOARCH=arm64 go build -o devtool-darwin-arm64 .
GOOS=windows GOARCH=amd64 go build -o devtool-windows-amd64.exe .

Makefile targets:

make build     # Build with version injection
make test      # Run all tests with coverage
make vet       # Run go vet
make clean     # Remove build artifacts

Running Tests

go test ./... -v -cover

Test coverage by package:

Package Coverage
commands 85%+
config 90%+
formatter 95%+
terminal 90%+
cmd 100%

CI/CD

This project uses GitHub Actions for continuous integration:

  • Test matrix: Go 1.21, 1.22, 1.23 on Linux, macOS, Windows
  • Linting: golangci-lint with default configuration
  • Build matrix: All supported OS/arch combinations
  • Coverage: Coverage reports uploaded as artifacts

On tag creation, GoReleaser automatically:

  • Builds binaries for all platforms
  • Creates checksums
  • Generates changelog
  • Publishes to GitHub Releases
  • Pushes Docker images to GHCR
  • Updates Homebrew tap

Docker

Build:

docker build -t devtool:latest .

Run:

docker run --rm devtool:latest http-test https://example.com
docker run --rm devtool:latest cert-expiry google.com:443

The Docker image is built from scratch with only the binary and CA certificates (~5MB).


Tech Stack

  • Go -- compiled, statically typed, concurrent
  • Standard library only -- net/http, net, crypto/tls, flag, sync, time, log/slog
  • log/slog -- structured, leveled logging (Go 1.21+)
  • Goroutines & channels -- bounded concurrency via semaphores and worker pools
  • No external dependencies -- zero third-party imports in go.mod

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/my-feature)
  3. Add tests for new functionality
  4. Ensure go vet ./... and go test ./... pass
  5. Commit with conventional commit message
  6. Push and open a Pull Request

License

MIT

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages