CMDP Module#

SPDX-FileCopyrightText: 2024 DESY and the Constellation authors SPDX-License-Identifier: EUPL-1.2

Module implementing the Constellation Monitoring Distribution Protocol.

class core.cmdp.CMDPTransmitter(name: str, socket: Socket | None)#

Bases: object

Class for sending Constellation monitoring messages via ZMQ.

close() None#

Close the socket.

closed() bool#

Return whether socket is closed or not.

recv(flags: int = 0) LogRecord | Metric | None#

Receive a Constellation monitoring message and return log or metric.

send(data: LogRecord | Metric) None#

Send a LogRecord or a Metric.

send_log(record: LogRecord) None#

Send a LogRecord via an ZMQ socket.

Follows the Constellation Monitoring Distribution Protocol.

record: LogRecord to send.

send_metric(metric: Metric) None#

Send a metric via a ZMQ socket.

class core.cmdp.Metric(name: str, unit: str, handling: MetricsType, value: Any = None)#

Bases: object

Class to hold information for a Constellation metric.

pack() bytes#

Pack metric for CMDP payload.

class core.cmdp.MetricsType(*values)#

Bases: Enum

ACCUMULATE = 2#
AVERAGE = 3#
LAST_VALUE = 1#
RATE = 4#
core.cmdp.decode_log(name: str, topic: str, msg: list[bytes]) LogRecord#

Receive a Constellation log message.

core.cmdp.decode_metric(name: str, topic: str, msg: list[Any]) Metric#

Receive a Constellation STATS message and return a Metric.