HAL9002-CheckMK/hal9002/graphing/graph_hal9002.py

98 lines
3.1 KiB
Python

#!/usr/bin/env python3
"""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, SINotation
from cmk.graphing.v1.perfometers import (
Open,
Closed,
FocusRange,
Perfometer,
Bidirectional,
)
## Metrics
# metrics must begin with "metric_" and be an instance of "Metric"
metric_hal9002_user_quota_used = Metric(
# "name" must be exactly the "metric_name" within the check function
name="hal_user_quota_used_percent",
title=Title("Percentage of storage quota used"),
unit=Unit(DecimalNotation("%")),
color=Color.DARK_ORANGE,
)
metric_hal9002_user_bytes_used = Metric(
# "name" must be exactly the "metric_name" within the check function
name="hal_user_used_bytes",
title=Title("Used storage"),
unit=Unit(SINotation("bytes")),
color=Color.DARK_CYAN,
)
metric_hal9002_storage_upload_rate = Metric(
# "name" must be exactly the "metric_name" within the check function
name="hal_storage_upload_rate",
title=Title("Storage upload rate"),
unit=Unit(SINotation("bytes/s")),
color=Color.DARK_GREEN,
)
metric_hal9002_storage_download_rate = Metric(
# "name" must be exactly the "metric_name" within the check function
name="hal_storage_download_rate",
title=Title("Storage download rate"),
unit=Unit(SINotation("bytes/s")),
color=Color.LIGHT_GREEN,
)
metric_hal9002_storage_upload_last = Metric(
# "name" must be exactly the "metric_name" within the check function
name="hal_storage_last_upload",
title=Title("Upload since last check"),
unit=Unit(SINotation("bytes")),
color=Color.DARK_BLUE,
)
metric_hal9002_storage_download_last = Metric(
# "name" must be exactly the "metric_name" within the check function
name="hal_storage_last_download",
title=Title("Download since last check"),
unit=Unit(SINotation("bytes")),
color=Color.LIGHT_BLUE,
)
## Perfometers
# perfometers must begin with "perfometer_" and be an instance of "Perfometer"
perfometer_hal9002_users_quota_used = Perfometer(
name="hal9002_users_quota_used",
focus_range=FocusRange(Closed(0), Closed(100)),
# "segments" must be exactly the name of the metric
segments=["hal_user_quota_used_percent"],
)
perfometer_hal9002_storage_rates = Bidirectional(
name="hal9002_storage_rates",
left=Perfometer(
name="hal9002_storage_download_rate",
focus_range=FocusRange(Open(0.0), Open(500.0)),
segments=["hal_storage_download_rate"],
),
right=Perfometer(
name="hal9002_storage_upload_rate",
focus_range=FocusRange(Open(0.0), Open(500.0)),
segments=["hal_storage_upload_rate"],
),
)
## Combined Graphs
# combined graphs must begin with "graph_" and be an instance of "Graph"
graph_hal9002_storages_upload_download = Graph(
name="hal9002_storage_upload_download",
title=Title("Storage upload/download rate"),
# names here refer to the metric names above
simple_lines=["hal_storage_download_rate", "hal_storage_upload_rate"],
minimal_range=MinimalRange(0, 100),
)