199 lines
5.2 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, SINotation, Metric, Unit
from cmk.graphing.v1.perfometers import Open, Closed, FocusRange, Perfometer, Stacked
metric_nc_num_users = Metric(
name="nc_num_users",
title=Title("Number of Users"),
unit=Unit(DecimalNotation("")),
color=Color.PURPLE,
)
metric_nc_num_shares = Metric(
name="nc_num_shares",
title=Title("Number of Shares"),
unit=Unit(DecimalNotation("")),
color=Color.BROWN,
)
metric_nc_num_storages = Metric(
name="nc_num_storages",
title=Title("Number of Storages"),
unit=Unit(DecimalNotation("")),
color=Color.BLUE,
)
metric_nc_num_storages_home = Metric(
name="nc_num_storages_home",
title=Title("Number of Home Storages"),
unit=Unit(DecimalNotation("")),
color=Color.GREEN,
)
metric_nc_num_storages_local = Metric(
name="nc_num_storages_local",
title=Title("Number of Local Storages"),
unit=Unit(DecimalNotation("")),
color=Color.DARK_GREEN,
)
metric_nc_num_storages_other = Metric(
name="nc_num_storages_other",
title=Title("Number of Other Storages"),
unit=Unit(DecimalNotation("")),
color=Color.LIGHT_GREEN,
)
metric_nc_num_files = Metric(
name="nc_num_files",
title=Title("Number of Files"),
unit=Unit(SINotation("")),
color=Color.RED,
)
metric_nc_num_apps_installed = Metric(
name="nc_num_apps_installed",
title=Title("Number of installed Apps"),
unit=Unit(DecimalNotation("")),
color=Color.GREEN,
)
metric_nc_apps_with_updates_available = Metric(
name="nc_apps_with_updates_available",
title=Title("Number of installed Apps with Updates Available"),
unit=Unit(DecimalNotation("")),
color=Color.RED,
)
metric_nc_active_users_last_5min = Metric(
name="nc_active_users_last_5min",
title=Title("Number of Active Users in the last 5 minutes"),
unit=Unit(DecimalNotation("")),
color=Color.LIGHT_RED,
)
metric_nc_active_users_last_1hour = Metric(
name="nc_active_users_last_1hour",
title=Title("Number of Active Users in the last 1 hour"),
unit=Unit(DecimalNotation("")),
color=Color.LIGHT_GREEN,
)
metric_nc_active_users_last_1day = Metric(
name="nc_active_users_last_1day",
title=Title("Number of Active Users in the last 1 day"),
unit=Unit(DecimalNotation("")),
color=Color.LIGHT_BLUE,
)
metric_nc_users_free_space = Metric(
name="nc_users_free_space",
title=Title("Free Space of User"),
unit=Unit(SINotation("bytes")),
color=Color.LIGHT_BLUE,
)
metric_nc_free_space = Metric(
name="nc_free_space",
title=Title("Free Space on Disk"),
unit=Unit(SINotation("bytes")),
color=Color.DARK_BLUE,
)
metric_nc_database_size = Metric(
name="nc_database_size",
title=Title("Database Size"),
unit=Unit(SINotation("bytes")),
color=Color.GREEN,
)
metric_nc_database_opcache_hit_rate = Metric(
name="nc_database_opcache_hit_rate",
title=Title("Database PHP OPCache Hit Rate"),
unit=Unit(DecimalNotation("%")),
color=Color.LIGHT_BLUE,
)
metric_nc_users_quota_used = Metric(
name="nc_users_quota_used",
title=Title("Quota used"),
unit=Unit(DecimalNotation("%")),
color=Color.BLUE,
)
graph_nc_number_of_users_shares_storages = Graph(
name="number_of_users_shares_storages_combined",
title=Title("Number of Users, Shares and Storages"),
# names here refer to the metric names above
simple_lines=["nc_num_users", "nc_num_shares", "nc_num_storages"],
minimal_range=MinimalRange(0, 200),
)
graph_nc_number_of_storage_types = Graph(
name="number_of_storage_types_combined",
title=Title("Number of Storage Types"),
# names here refer to the metric names above
simple_lines=[
"nc_num_storages_home",
"nc_num_storages_local",
"nc_num_storages_other",
],
minimal_range=MinimalRange(0, 100),
)
graph_nc_number_of_active_users = Graph(
name="number_of_active_users_combined",
title=Title("Number of Active Users"),
# names here refer to the metric names above
simple_lines=[
"nc_active_users_last_5min",
"nc_active_users_last_1hour",
"nc_active_users_last_1day",
],
minimal_range=MinimalRange(0, 100),
)
perfometer_nc_database_op_cache_hit_rate = Perfometer(
name="nc_database_opcache_hit_rate",
focus_range=FocusRange(
Closed(0),
Closed(100),
),
segments=("nc_database_opcache_hit_rate",),
)
perfometer_nc_database_size = Perfometer(
name="nc_database_size",
focus_range=FocusRange(Open(0.0), Open(500.0)),
segments=["nc_database_size"],
)
perfometer_nc_quota_used = Perfometer(
name="nc_users_quota_used",
focus_range=FocusRange(Closed(0), Closed(100)),
segments=["nc_users_quota_used"],
)
perfometer_nc_info = Stacked(
name="nc_info",
lower=Perfometer(
name="nc_num_users",
focus_range=FocusRange(Closed(0), Open(200)),
segments=["nc_num_users"],
),
upper=Perfometer(
name="nc_num_apps_installed",
focus_range=FocusRange(Closed(0), Open(100)),
segments=["nc_num_apps_installed"],
),
)