cc-lib

module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2025 License: MIT

README

GoDoc Go Report Card

cc-lib

Common ClusterCockpit golang packages providing reusable components for building HPC monitoring and metric collection applications.

Overview

cc-lib is a collection of Go packages developed for the ClusterCockpit project. These packages provide essential functionality for:

  • Metric Collection: Receivers for various protocols (IPMI, Redfish, Prometheus, etc.)
  • Data Processing: Message processing pipelines, resampling, and transformations
  • Data Storage: Sinks for InfluxDB, NATS, Prometheus, and more
  • Configuration: Flexible configuration management with validation
  • Utilities: Caching, logging, topology detection, and helper functions

The library is designed to be modular, allowing you to use individual packages as needed in your own projects.

Packages

Core Messaging & Processing
Package Description
ccMessage Message types and protocols for metrics, logs, events, and control messages
messageProcessor Expression-based message processing and transformation pipeline
schema JSON schema definitions and validation for ClusterCockpit data structures
Metric Collection
Package Description
receivers Metric receivers for IPMI, Redfish, Prometheus, and other protocols
ccTopology System topology detection and hardware information gathering
Data Storage & Output
Package Description
sinks Metric sinks for InfluxDB, NATS, Prometheus, HTTP, and file output
resampler Data resampling and aggregation utilities
Configuration & Logging
Package Description
ccConfig Configuration file management with hot-reloading support
ccLogger Structured logging with multiple output levels
Utilities
Package Description
lrucache Thread-safe LRU cache with TTL support and HTTP middleware
hostlist Hostlist expansion for compact host specifications (e.g., node[1-10])
ccUnits Unit conversion and handling for metrics
util Common utility functions and helpers
runtimeEnv Runtime environment detection and information

Installation

go get github.com/ClusterCockpit/cc-lib

Requirements:

  • Go 1.24.0 or higher

Quick Start

Using the LRU Cache
import "github.com/ClusterCockpit/cc-lib/lrucache"

cache := lrucache.New(1000) // maxmemory in arbitrary units

value := cache.Get("key", func() (interface{}, time.Duration, int) {
    // Compute expensive value
    result := fetchFromDatabase()
    return result, 10 * time.Minute, len(result)
})
Expanding Hostlists
import "github.com/ClusterCockpit/cc-lib/hostlist"

hosts, err := hostlist.Expand("node[1-10],gpu[1-4]")
// Returns: [gpu1, gpu2, gpu3, gpu4, node1, node2, ..., node10]
Creating Messages
import "github.com/ClusterCockpit/cc-lib/ccMessage"

msg, err := ccMessage.NewMessage(
    "temperature",
    map[string]string{"hostname": "node01", "type": "node"},
    map[string]string{"unit": "degC"},
    map[string]interface{}{"value": 45.2},
    time.Now(),
)
Using Configuration Management
import "github.com/ClusterCockpit/cc-lib/ccConfig"

config := ccConfig.New()
config.AddFile("config.json")

// Access configuration
value := config.Get("key")

// Watch for changes
config.Watch(func() {
    log.Println("Configuration changed")
})

Documentation

Package Documentation

Testing

Run all tests:

go test ./...

Run tests with coverage:

go test -cover ./...

Run tests for a specific package:

go test -v ./lrucache

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.

Development
  1. Clone the repository
  2. Make your changes
  3. Run tests: go test ./...
  4. Submit a pull request

Projects Using cc-lib

License

This project is licensed under the MIT License - see the LICENSE file for details.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg.

Acknowledgments

Developed by the National High Performance Computing (NHR) center at FAU.

Additional contributors:

  • Holger Obermaier (NHR@KIT)

Directories

Path Synopsis
Package ccconfig provides a simple configuration management system for the ClusterCockpit ecosystem.
Package ccconfig provides a simple configuration management system for the ClusterCockpit ecosystem.
Package cclogger implements a simple log wrapper for the standard log package.
Package cclogger implements a simple log wrapper for the standard log package.
Package ccmessage provides a message format and interface for ClusterCockpit.
Package ccmessage provides a message format and interface for ClusterCockpit.
Package hostlist provides functionality to expand compact hostlist specifications into individual host names.
Package hostlist provides functionality to expand compact hostlist specifications into individual host names.
Package lrucache provides a thread-safe, in-memory LRU (Least Recently Used) cache with TTL (Time To Live) support and size-based eviction.
Package lrucache provides a thread-safe, in-memory LRU (Least Recently Used) cache with TTL (Time To Live) support and size-based eviction.
Package resampler provides time-series data downsampling algorithms.
Package resampler provides time-series data downsampling algorithms.
Package schema provides core data structures and types for the ClusterCockpit system.
Package schema provides core data structures and types for the ClusterCockpit system.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL