# pylint: disable=unused-import
"""graphing and metrics definitions"""

from cmk.graphing.v1 import Title

# from cmk.graphing.v1.graphs import Graph, MinimalRange
from cmk.graphing.v1.metrics import Color, DecimalNotation, Metric, Unit
from cmk.graphing.v1.perfometers import Closed, FocusRange, Perfometer


# info section
metric_traefik_agent_execution_time = Metric(
    # "name" must be exactly the "metric_name" within the check function
    name="traefik_agent_execution_time",
    title=Title("Agent execution time"),
    unit=Unit(DecimalNotation("ms")),
    color=Color.DARK_ORANGE,
)

# HTTP section
metric_traefik_num_http_routers = Metric(
    name="traefik_num_http_routers",
    title=Title("Number of HTTP routers"),
    unit=Unit(DecimalNotation("")),
    color=Color.LIGHT_GREEN,
)

metric_traefik_num_http_services = Metric(
    name="traefik_num_http_services",
    title=Title("Number of HTTP services"),
    unit=Unit(DecimalNotation("")),
    color=Color.LIGHT_BLUE,
)

metric_traefik_num_http_middlewares = Metric(
    name="traefik_num_http_middlewares",
    title=Title("Number of HTTP middlewares"),
    unit=Unit(DecimalNotation("")),
    color=Color.LIGHT_RED,
)


metric_traefik_percent_http_components_not_ok = Metric(
    name="traefik_percent_http_components_not_ok",
    title=Title("Percent of HTTP components in not OK state"),
    unit=Unit(DecimalNotation("%")),
    color=Color.DARK_RED,
)

# TCP section
metric_traefik_num_tcp_routers = Metric(
    name="traefik_num_tcp_routers",
    title=Title("Number of TCP routers"),
    unit=Unit(DecimalNotation("")),
    color=Color.LIGHT_GREEN,
)

metric_traefik_num_tcp_services = Metric(
    name="traefik_num_tcp_services",
    title=Title("Number of TCP services"),
    unit=Unit(DecimalNotation("")),
    color=Color.LIGHT_BLUE,
)

metric_traefik_num_tcp_middlewares = Metric(
    name="traefik_num_tcp_middlewares",
    title=Title("Number of TCP middlewares"),
    unit=Unit(DecimalNotation("")),
    color=Color.LIGHT_RED,
)

metric_traefik_percent_tcp_components_not_ok = Metric(
    name="traefik_percent_tcp_components_not_ok",
    title=Title("Percent of TCP components in not OK state"),
    unit=Unit(DecimalNotation("%")),
    color=Color.DARK_RED,
)

# UDP section
metric_traefik_num_udp_routers = Metric(
    name="traefik_num_udp_routers",
    title=Title("Number of UDP routers"),
    unit=Unit(DecimalNotation("")),
    color=Color.LIGHT_GREEN,
)

metric_traefik_num_udp_services = Metric(
    name="traefik_num_udp_services",
    title=Title("Number of UDP services"),
    unit=Unit(DecimalNotation("")),
    color=Color.LIGHT_BLUE,
)

metric_traefik_percent_udp_components_not_ok = Metric(
    name="traefik_percent_udp_components_not_ok",
    title=Title("Percent of UDP components in not OK state"),
    unit=Unit(DecimalNotation("%")),
    color=Color.DARK_RED,
)


# Perfometers
perfometer_traefik_agent_execution_time = Perfometer(
    name="traefik_agent_execution_time",
    focus_range=FocusRange(Closed(0), Closed(5000)),
    # "segments" must be exactly the name of the metric
    segments=["traefik_agent_execution_time"],
)