This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
DankGop is a system monitoring tool with CLI and REST API, designed to provide comprehensive system metrics. It's written in Go and compiles to a single binary that provides both CLI commands and a REST API server.
# Standard build
make
# Development build (with debug info)
make dev
# Build and install system-wide
make && sudo make install# Run all tests
make test
# Run tests for specific package
go test -v ./api/middleware/...# Format code
make fmt
# Run go vet
make vet
# Update dependencies
make deps# Run locally without building
go run ./cmd/cli [command]
# After building
./bin/dgop [command]
# Start API server
./bin/dgop server-
CLI Entry Point (
cmd/cli/)main.go: Sets up Cobra commands and initializes GopsUtilcommands.go: Implements individual CLI commands (cpu, memory, network, etc.)server.go: Starts the REST API server
-
Data Collection (
gops/)gops.go: Main utility class that orchestrates all metric collection- Individual collectors:
cpu.go,memory.go,disk.go,net.go,processes.go,system.go,hardware.go - Each collector uses
github.com/shirou/gopsutil/v4for system information
-
API Layer (
api/)api/gops/: HTTP handlers that wrap the gops collectorsapi/server/: Server implementationapi/middleware/: Request logging, recovery, and request ID middleware- Uses Huma v2 framework for OpenAPI-compliant REST API
-
Data Models (
models/)- Defines structures for all system metrics (CPU, Memory, Disk, Network, Process, etc.)
- Shared between CLI output and API responses
- Single Responsibility: Each file in
gops/handles one type of metric - Dependency Injection: GopsUtil is passed to commands and API handlers
- Process Sampling: CPU and process metrics support sampling for performance optimization
- Modular Commands: Meta command allows combining multiple metrics dynamically
- Default port: 63484
- OpenAPI docs available at
/docs - All endpoints under
/gops/prefix - Supports JSON output and query parameters for filtering/sorting
- Process CPU Calculation: Can be disabled with
--no-cpuflag for faster results - GPU Temperature: Requires
nvidia-smifor NVIDIA GPUs, uses PCI IDs for identification - CGO Disabled: Built with
CGO_ENABLED=0for maximum portability - Error Handling: Non-critical errors are logged but don't stop execution (graceful degradation)
- Sampling Support: CPU and process commands support
--sampleflag for testing with mock data