Skip to content

Commit e0de41b

Browse files
committed
added perf-o-meter / graph
1 parent 22c868d commit e0de41b

File tree

4 files changed

+179
-0
lines changed

4 files changed

+179
-0
lines changed

intune/agent_based/ms_intune_apple_ade_tokens.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
CheckPlugin,
4949
CheckResult,
5050
DiscoveryResult,
51+
Metric,
5152
render,
5253
Result,
5354
Service,
@@ -118,6 +119,7 @@ def check_ms_intune_apple_ade_tokens(
118119
yield from check_levels(
119120
token_expiration_timespan,
120121
levels_lower=(params_levels_token_expiration),
122+
metric_name="ms_intune_apple_ade_tokens_remaining_validity",
121123
label="Remaining",
122124
render_func=render.timespan,
123125
)
@@ -129,6 +131,13 @@ def check_ms_intune_apple_ade_tokens(
129131
render_func=lambda x: f"{render.timespan(abs(x))} ago",
130132
)
131133

134+
# To prevent a negative value for the metric.
135+
yield Metric(
136+
name="ms_intune_apple_ade_tokens_remaining_validity",
137+
value=0.0,
138+
levels=params_levels_token_expiration[1],
139+
)
140+
132141
yield Result(
133142
state=State.OK,
134143
summary=f"Expiration time: {token_expiration_timestamp_render}",

intune/agent_based/ms_intune_apple_mdm_push_cert.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
CheckResult,
4444
DiscoveryResult,
4545
render,
46+
Metric,
4647
Result,
4748
Service,
4849
State,
@@ -84,6 +85,7 @@ def check_ms_intune_apple_mdm_push_cert(params: Mapping[str, Any], section: Sect
8485
yield from check_levels(
8586
cert_expiration_timespan,
8687
levels_lower=(params_levels_cert_expiration),
88+
metric_name="ms_intune_apple_mdm_push_cert_remaining_validity",
8789
label="Remaining",
8890
render_func=render.timespan,
8991
)
@@ -95,6 +97,13 @@ def check_ms_intune_apple_mdm_push_cert(params: Mapping[str, Any], section: Sect
9597
render_func=lambda x: f"{render.timespan(abs(x))} ago",
9698
)
9799

100+
# To prevent a negative value for the metric.
101+
yield Metric(
102+
name="ms_intune_apple_mdm_push_cert_remaining_validity",
103+
value=0.0,
104+
levels=params_levels_cert_expiration[1],
105+
)
106+
98107
yield Result(
99108
state=State.OK,
100109
summary=f"Expiration time: {cert_expiration_timestamp_render}",

intune/agent_based/ms_intune_apple_vpp_tokens.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
CheckResult,
5151
DiscoveryResult,
5252
render,
53+
Metric,
5354
Result,
5455
Service,
5556
State,
@@ -123,6 +124,7 @@ def check_ms_intune_apple_vpp_tokens(
123124
yield from check_levels(
124125
token_expiration_timespan,
125126
levels_lower=(params_levels_token_expiration),
127+
metric_name="ms_intune_apple_vpp_tokens_remaining_validity",
126128
label="Remaining",
127129
render_func=render.timespan,
128130
)
@@ -134,6 +136,13 @@ def check_ms_intune_apple_vpp_tokens(
134136
render_func=lambda x: f"{render.timespan(abs(x))} ago",
135137
)
136138

139+
# To prevent a negative value for the metric.
140+
yield Metric(
141+
name="ms_intune_apple_vpp_tokens_remaining_validity",
142+
value=0.0,
143+
levels=params_levels_token_expiration[1],
144+
)
145+
137146
if token.token_state != "valid":
138147
yield Result(
139148
state=State.CRIT,

intune/graphing/ms_intune.py

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8; py-indent-offset: 4; max-line-length: 100 -*-
3+
4+
# Copyright (C) 2024, 2025 Christopher Pommer <cp.software@outlook.de>
5+
6+
# This program is free software; you can redistribute it and/or
7+
# modify it under the terms of the GNU General Public License
8+
# as published by the Free Software Foundation; either version 2
9+
# of the License, or (at your option) any later version.
10+
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program; if not, write to the Free Software
18+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
20+
21+
####################################################################################################
22+
# The graph parameters are part of the Microsoft Intune special agent (ms_intune).
23+
24+
25+
from cmk.graphing.v1 import Title
26+
from cmk.graphing.v1.graphs import Graph, MinimalRange
27+
from cmk.graphing.v1.metrics import (
28+
Color,
29+
CriticalOf,
30+
DecimalNotation,
31+
Metric,
32+
StrictPrecision,
33+
TimeNotation,
34+
Unit,
35+
WarningOf,
36+
)
37+
from cmk.graphing.v1.perfometers import Closed, FocusRange, Open, Perfometer
38+
39+
UNIT_COUNTER = Unit(DecimalNotation(""), StrictPrecision(0))
40+
UNIT_PERCENTAGE = Unit(DecimalNotation("%"))
41+
UNIT_TIME = Unit(TimeNotation())
42+
43+
44+
# Microsoft Intune App Licenses
45+
46+
metric_ms_intune_app_licenses_consumed = Metric(
47+
name="ms_intune_app_licenses_consumed",
48+
title=Title("Consumed"),
49+
unit=UNIT_COUNTER,
50+
color=Color.CYAN,
51+
)
52+
53+
metric_ms_intune_app_licenses_consumed_pct = Metric(
54+
name="ms_intune_app_licenses_consumed_pct",
55+
title=Title("Usage"),
56+
unit=UNIT_PERCENTAGE,
57+
color=Color.BLUE,
58+
)
59+
60+
metric_ms_intune_app_licenses_total = Metric(
61+
name="ms_intune_app_licenses_total",
62+
title=Title("Total"),
63+
unit=UNIT_COUNTER,
64+
color=Color.DARK_CYAN,
65+
)
66+
67+
metric_ms_intune_app_licenses_available = Metric(
68+
name="ms_intune_app_licenses_available",
69+
title=Title("Available"),
70+
unit=UNIT_COUNTER,
71+
color=Color.LIGHT_GRAY,
72+
)
73+
74+
75+
graph_ms_intune_app_licenses_count = Graph(
76+
name="ms_intune_app_licenses_count",
77+
title=Title("License count"),
78+
compound_lines=[
79+
"ms_intune_app_licenses_consumed",
80+
"ms_intune_app_licenses_available",
81+
],
82+
simple_lines=[
83+
"ms_intune_app_licenses_total",
84+
WarningOf("ms_intune_app_licenses_consumed"),
85+
CriticalOf("ms_intune_app_licenses_consumed"),
86+
],
87+
)
88+
89+
graph_ms_intune_app_licenses_usage = Graph(
90+
name="ms_intune_app_licenses_usage",
91+
title=Title("License usage"),
92+
minimal_range=MinimalRange(0, 100),
93+
simple_lines=[
94+
"ms_intune_app_licenses_consumed_pct",
95+
WarningOf("ms_intune_app_licenses_consumed_pct"),
96+
CriticalOf("ms_intune_app_licenses_consumed_pct"),
97+
],
98+
)
99+
100+
perfometer_ms_intune_app_licenses_consumed_pct = Perfometer(
101+
name="ms_intune_app_licenses_consumed_pct",
102+
focus_range=FocusRange(Closed(0), Closed(100)),
103+
segments=["ms_intune_app_licenses_consumed_pct"],
104+
)
105+
106+
107+
# Microsoft Intune Apple ADE tokens
108+
109+
metric_ms_intune_apple_ade_tokens_remaining_validity = Metric(
110+
name="ms_intune_apple_ade_tokens_remaining_validity",
111+
title=Title("Remaining token validity time"),
112+
unit=UNIT_TIME,
113+
color=Color.YELLOW,
114+
)
115+
116+
perfometer_ms_intune_apple_ade_tokens_remaining_validity = Perfometer(
117+
name="ms_intune_apple_ade_tokens_remaining_validity",
118+
focus_range=FocusRange(Closed(0), Open(15552000)),
119+
segments=["ms_intune_apple_ade_tokens_remaining_validity"],
120+
)
121+
122+
123+
# Microsoft Intune Apple MDM Push Certificate
124+
125+
metric_ms_intune_apple_mdm_push_cert_remaining_validity = Metric(
126+
name="ms_intune_apple_mdm_push_cert_remaining_validity",
127+
title=Title("Remaining certificate validity time"),
128+
unit=UNIT_TIME,
129+
color=Color.YELLOW,
130+
)
131+
132+
perfometer_ms_intune_apple_mdm_push_cert_remaining_validity = Perfometer(
133+
name="ms_intune_apple_mdm_push_cert_remaining_validity",
134+
focus_range=FocusRange(Closed(0), Open(15552000)),
135+
segments=["ms_intune_apple_mdm_push_cert_remaining_validity"],
136+
)
137+
138+
139+
# Microsoft Intune Apple VPP Tokens
140+
141+
metric_ms_intune_apple_vpp_tokens_remaining_validity = Metric(
142+
name="ms_intune_apple_vpp_tokens_remaining_validity",
143+
title=Title("Remaining token validity time"),
144+
unit=UNIT_TIME,
145+
color=Color.YELLOW,
146+
)
147+
148+
perfometer_ms_intune_apple_vpp_tokens_remaining_validityy = Perfometer(
149+
name="ms_intune_apple_vpp_tokens_remaining_validity",
150+
focus_range=FocusRange(Closed(0), Open(15552000)),
151+
segments=["ms_intune_apple_vpp_tokens_remaining_validity"],
152+
)

0 commit comments

Comments
 (0)