receivers

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2023 License: MIT Imports: 25 Imported by: 1

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

Index

Constants

View Source
const HTTP_RECEIVER_PORT = "8080"

Variables

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

Functions

This section is empty.

Types

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.CCMetric)

SetSink set the sink channel

func (*HttpReceiver) Start

func (r *HttpReceiver) Start()

type HttpReceiverConfig

type HttpReceiverConfig struct {
	Type string `json:"type"`
	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.6.3

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

func (*IPMIReceiver) Close added in v0.6.3

func (r *IPMIReceiver) Close()

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

func (*IPMIReceiver) Name added in v0.6.3

func (r *IPMIReceiver) Name() string

Name returns the name of the metric receiver

func (*IPMIReceiver) SetSink added in v0.6.3

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

SetSink set the sink channel

func (*IPMIReceiver) Start added in v0.6.3

func (r *IPMIReceiver) Start()

type IPMIReceiverClientConfig added in v0.6.3

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.CCMetric)

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 {
	Type    string `json:"type"`
	Addr    string `json:"address"`
	Port    string `json:"port"`
	Subject string `json:"subject"`
}

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.CCMetric)

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, receiverConfigFile string) error
	AddInput(name string, rawConfig json.RawMessage) error
	AddOutput(output chan lp.CCMetric)
	Start()
	Close()
}

func New

func New(wg *sync.WaitGroup, receiverConfigFile string) (ReceiveManager, error)

type Receiver

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

func NewHttpReceiver

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

func NewIPMIReceiver added in v0.6.3

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.6.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.6.0

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

RedfishReceiver configuration:

func (*RedfishReceiver) Close added in v0.6.0

func (r *RedfishReceiver) Close()

Close closes the redfish receiver

func (*RedfishReceiver) Name added in v0.6.0

func (r *RedfishReceiver) Name() string

Name returns the name of the metric receiver

func (*RedfishReceiver) SetSink added in v0.6.0

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

SetSink set the sink channel

func (*RedfishReceiver) Start added in v0.6.0

func (r *RedfishReceiver) Start()

Start starts the redfish receiver

type RedfishReceiverClientConfig added in v0.6.2

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.CCMetric)

SetSink set the sink channel

func (*SampleReceiver) Start

func (r *SampleReceiver) Start()

type SampleReceiverConfig

type SampleReceiverConfig struct {
	Type string `json:"type"`
	Addr string `json:"address"`
	Port string `json:"port"`
}

SampleReceiver configuration: receiver type, listen address, port

Jump to

Keyboard shortcuts

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