receivers

package
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 Imports: 28 Imported by: 3

README

CCMetric receivers

This folder contains the ReceiveManager and receiver implementations for the cc-metric-collector.

Configuration

The configuration file for the receivers is a list of configurations. The type field in each specifies which receiver to initialize.

{
  "myreceivername" : {
    "type": "receiver-type",
    <receiver-specific configuration>
  }
}

This allows to specify

Available receivers

  • nats: Receive metrics from the NATS network
  • prometheus: Scrape data from a Prometheus client
  • http: Listen for HTTP Post requests transporting metrics in InfluxDB line protocol
  • ipmi: Read IPMI sensor readings
  • redfish Use the Redfish (specification) to query thermal and power metrics

Contributing own receivers

A receiver contains a few functions and is derived from the type Receiver (in metricReceiver.go):

For an example, check the sample receiver

Documentation

Overview

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. additional authors: Holger Obermaier (NHR@KIT)

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. additional authors: Holger Obermaier (NHR@KIT)

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. additional authors: Holger Obermaier (NHR@KIT)

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. additional authors: Holger Obermaier (NHR@KIT)

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. additional authors: Holger Obermaier (NHR@KIT)

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. additional authors: Holger Obermaier (NHR@KIT)

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. additional authors: Holger Obermaier (NHR@KIT)

Copyright (C) NHR@FAU, University Erlangen-Nuremberg. All rights reserved. This file is part of cc-lib. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file. additional authors: Holger Obermaier (NHR@KIT)

Index

Constants

View Source
const CCCPT_RECEIVER_PORT = "8080"
View Source
const HTTP_RECEIVER_PORT = "8080"

Variables

View Source
var AvailableReceivers = map[string]func(name string, config json.RawMessage) (Receiver, error){
	"http":  NewHttpReceiver,
	"nats":  NewNatsReceiver,
	"eecpt": NewEECPTReceiver,
}

Functions

This section is empty.

Types

type EECPTReceiver added in v1.0.0

type EECPTReceiver struct {
	// contains filtered or unexported fields
}

func (*EECPTReceiver) Close added in v1.0.0

func (r *EECPTReceiver) Close()

func (*EECPTReceiver) Init added in v1.0.0

func (r *EECPTReceiver) Init(name string, config json.RawMessage) error

func (*EECPTReceiver) Name added in v1.0.0

func (r *EECPTReceiver) Name() string

Name returns the name of the metric receiver

func (*EECPTReceiver) ServerHttp added in v1.0.0

func (r *EECPTReceiver) ServerHttp(w http.ResponseWriter, req *http.Request)

func (*EECPTReceiver) SetSink added in v1.0.0

func (r *EECPTReceiver) SetSink(sink chan lp.CCMessage)

SetSink set the sink channel

func (*EECPTReceiver) Start added in v1.0.0

func (r *EECPTReceiver) Start()

type EECPTReceiverConfig added in v1.0.0

type EECPTReceiverConfig struct {
	Addr string `json:"address"`
	Port string `json:"port"`
	Path string `json:"path"`

	// Maximum amount of time to wait for the next request when keep-alives are enabled
	// should be larger than the measurement interval to keep the connection open
	IdleTimeout string `json:"idle_timeout"`

	// Controls whether HTTP keep-alives are enabled. By default, keep-alives are enabled
	KeepAlivesEnabled bool `json:"keep_alives_enabled"`

	// Basic authentication
	Username string `json:"username"`
	Password string `json:"password"`

	AnalysisBufferLength int    `json:"analysis_buffer_size"`
	AnalysisInterval     string `json:"analysis_interval"`
	AnalysisMetric       string `json:"analysis_metric"`
	// contains filtered or unexported fields
}

type EECPTReceiverJob added in v1.0.0

type EECPTReceiverJob struct {
	// contains filtered or unexported fields
}

func NewJob added in v1.0.0

func NewJob(ident string) *EECPTReceiverJob

func (*EECPTReceiverJob) Analyse added in v1.0.0

func (job *EECPTReceiverJob) Analyse() float64

func (*EECPTReceiverJob) ChiSquareLimit added in v1.0.0

func (job *EECPTReceiverJob) ChiSquareLimit() float64

func (*EECPTReceiverJob) Reset added in v1.0.0

func (job *EECPTReceiverJob) Reset()

type EECPTReceiverTask added in v1.0.0

type EECPTReceiverTask struct {
	// contains filtered or unexported fields
}

func (*EECPTReceiverTask) Add added in v1.0.0

func (task *EECPTReceiverTask) Add(value float64)

func (*EECPTReceiverTask) Analyse added in v1.0.0

func (task *EECPTReceiverTask) Analyse() (float64, float64, error)

func (*EECPTReceiverTask) PrintBuffer added in v1.0.0

func (task *EECPTReceiverTask) PrintBuffer()

func (*EECPTReceiverTask) Reset added in v1.0.0

func (task *EECPTReceiverTask) Reset()

type HttpReceiver

type HttpReceiver struct {
	// contains filtered or unexported fields
}

func (*HttpReceiver) Close

func (r *HttpReceiver) Close()

func (*HttpReceiver) Init

func (r *HttpReceiver) Init(name string, config json.RawMessage) error

func (*HttpReceiver) Name

func (r *HttpReceiver) Name() string

Name returns the name of the metric receiver

func (*HttpReceiver) ServerHttp

func (r *HttpReceiver) ServerHttp(w http.ResponseWriter, req *http.Request)

func (*HttpReceiver) SetSink

func (r *HttpReceiver) SetSink(sink chan lp.CCMessage)

SetSink set the sink channel

func (*HttpReceiver) Start

func (r *HttpReceiver) Start()

type HttpReceiverConfig

type HttpReceiverConfig struct {
	Addr string `json:"address"`
	Port string `json:"port"`
	Path string `json:"path"`

	// Maximum amount of time to wait for the next request when keep-alives are enabled
	// should be larger than the measurement interval to keep the connection open
	IdleTimeout string `json:"idle_timeout"`

	// Controls whether HTTP keep-alives are enabled. By default, keep-alives are enabled
	KeepAlivesEnabled bool `json:"keep_alives_enabled"`

	// Basic authentication
	Username string `json:"username"`
	Password string `json:"password"`
	// contains filtered or unexported fields
}

type IPMIReceiver added in v0.2.0

type IPMIReceiver struct {
	// contains filtered or unexported fields
}

func (*IPMIReceiver) Close added in v0.2.0

func (r *IPMIReceiver) Close()

Close receiver: close network connection, close files, close libraries, ...

func (*IPMIReceiver) Name added in v0.2.0

func (r *IPMIReceiver) Name() string

Name returns the name of the metric receiver

func (*IPMIReceiver) SetSink added in v0.2.0

func (r *IPMIReceiver) SetSink(sink chan lp.CCMessage)

SetSink set the sink channel

func (*IPMIReceiver) Start added in v0.2.0

func (r *IPMIReceiver) Start()

type IPMIReceiverClientConfig added in v0.2.0

type IPMIReceiverClientConfig struct {
	// Hostname the IPMI service belongs to
	Protocol         string            // Protocol / tool to use for IPMI sensor reading
	DriverType       string            // Out of band IPMI driver
	Fanout           int               // Maximum number of simultaneous IPMI connections
	NumHosts         int               // Number of remote IPMI devices with the same configuration
	IPMIHosts        string            // List of remote IPMI devices to communicate with
	IPMI2HostMapping map[string]string // Mapping between IPMI device name and host name
	Username         string            // User name to authenticate with
	Password         string            // Password to use for authentication
	CLIOptions       []string          // Additional command line options for ipmi-sensors
	// contains filtered or unexported fields
}

type NatsReceiver

type NatsReceiver struct {
	// contains filtered or unexported fields
}

func (*NatsReceiver) Close

func (r *NatsReceiver) Close()

Close closes the connection to the NATS server

func (*NatsReceiver) Name

func (r *NatsReceiver) Name() string

Name returns the name of the metric receiver

func (*NatsReceiver) SetSink

func (r *NatsReceiver) SetSink(sink chan lp.CCMessage)

SetSink set the sink channel

func (*NatsReceiver) Start

func (r *NatsReceiver) Start()

Start subscribes to the configured NATS subject Messages wil be handled by r._NatsReceive

type NatsReceiverConfig

type NatsReceiverConfig struct {
	Addr     string `json:"address"`
	Port     string `json:"port"`
	Subject  string `json:"subject"`
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`
	NkeyFile string `json:"nkey_file,omitempty"`
	// contains filtered or unexported fields
}

type PrometheusReceiver

type PrometheusReceiver struct {
	// contains filtered or unexported fields
}

func (*PrometheusReceiver) Close

func (r *PrometheusReceiver) Close()

func (*PrometheusReceiver) Name

func (r *PrometheusReceiver) Name() string

Name returns the name of the metric receiver

func (*PrometheusReceiver) SetSink

func (r *PrometheusReceiver) SetSink(sink chan lp.CCMessage)

SetSink set the sink channel

func (*PrometheusReceiver) Start

func (r *PrometheusReceiver) Start()

type PrometheusReceiverConfig

type PrometheusReceiverConfig struct {
	Addr     string `json:"address"`
	Port     string `json:"port"`
	Path     string `json:"path"`
	Interval string `json:"interval"`
	SSL      bool   `json:"ssl"`
	// contains filtered or unexported fields
}

type ReceiveManager

type ReceiveManager interface {
	Init(wg *sync.WaitGroup, receiverConfig json.RawMessage) error
	AddInput(name string, rawConfig json.RawMessage) error
	AddOutput(output chan lp.CCMessage)
	Start()
	Close()
}

func New

func New(wg *sync.WaitGroup, receiverConfig json.RawMessage) (ReceiveManager, error)

type Receiver

type Receiver interface {
	Start()
	Close()                         // Close / finish metric receiver
	Name() string                   // Name of the metric receiver
	SetSink(sink chan lp.CCMessage) // Set sink channel
}

func NewEECPTReceiver added in v1.0.0

func NewEECPTReceiver(name string, config json.RawMessage) (Receiver, error)

func NewHttpReceiver

func NewHttpReceiver(name string, config json.RawMessage) (Receiver, error)

func NewIPMIReceiver added in v0.2.0

func NewIPMIReceiver(name string, config json.RawMessage) (Receiver, error)

NewIPMIReceiver creates a new instance of the redfish receiver Initialize the receiver by giving it a name and reading in the config JSON

func NewNatsReceiver

func NewNatsReceiver(name string, config json.RawMessage) (Receiver, error)

NewNatsReceiver creates a new Receiver which subscribes to messages from a NATS server

func NewPrometheusReceiver

func NewPrometheusReceiver(name string, config json.RawMessage) (Receiver, error)

func NewRedfishReceiver added in v0.2.0

func NewRedfishReceiver(name string, config json.RawMessage) (Receiver, error)

NewRedfishReceiver creates a new instance of the redfish receiver Initialize the receiver by giving it a name and reading in the config JSON

func NewSampleReceiver

func NewSampleReceiver(name string, config json.RawMessage) (Receiver, error)

New function to create a new instance of the receiver Initialize the receiver by giving it a name and reading in the config JSON

type ReceiverConfig

type ReceiverConfig struct {
	Addr         string `json:"address"`
	Port         string `json:"port"`
	Database     string `json:"database"`
	Organization string `json:"organization,omitempty"`
	Type         string `json:"type"`
}

Receiver configuration: Listen address, port

type RedfishReceiver added in v0.2.0

type RedfishReceiver struct {
	// contains filtered or unexported fields
}

RedfishReceiver configuration:

func (*RedfishReceiver) Close added in v0.2.0

func (r *RedfishReceiver) Close()

Close closes the redfish receiver

func (*RedfishReceiver) Name added in v0.2.0

func (r *RedfishReceiver) Name() string

Name returns the name of the metric receiver

func (*RedfishReceiver) SetSink added in v0.2.0

func (r *RedfishReceiver) SetSink(sink chan lp.CCMessage)

SetSink set the sink channel

func (*RedfishReceiver) Start added in v0.2.0

func (r *RedfishReceiver) Start()

Start starts the redfish receiver

type RedfishReceiverClientConfig added in v0.2.0

type RedfishReceiverClientConfig struct {
	// Hostname the redfish service belongs to
	Hostname string
	// contains filtered or unexported fields
}

type SampleReceiver

type SampleReceiver struct {
	// contains filtered or unexported fields
}

func (*SampleReceiver) Close

func (r *SampleReceiver) Close()

Close receiver: close network connection, close files, close libraries, ...

func (*SampleReceiver) Name

func (r *SampleReceiver) Name() string

Name returns the name of the metric receiver

func (*SampleReceiver) SetSink

func (r *SampleReceiver) SetSink(sink chan lp.CCMessage)

SetSink set the sink channel

func (*SampleReceiver) Start

func (r *SampleReceiver) Start()

type SampleReceiverConfig

type SampleReceiverConfig struct {
	Addr string `json:"address"`
	Port string `json:"port"`
	// contains filtered or unexported fields
}

SampleReceiver configuration: receiver type, listen address, port The defaultReceiverConfig contains the keys 'type' and 'process_messages'

Jump to

Keyboard shortcuts

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