Skip to content

Commit b165258

Browse files
oetikerclaude
andcommitted
Split backup_time metric, update graphing, add translations
- Split oposs_next_backup_time into oposs_next_time_remaining (scale 60s) and oposs_next_time_on_battery (scale 1s) - Update graphing with two separate metric/graph definitions - Add metric translations for ~40 legacy next_ups checks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 24c5d3a commit b165258

File tree

3 files changed

+321
-9
lines changed

3 files changed

+321
-9
lines changed

local/lib/python3/cmk_addons/plugins/oposs_next_ups/agent_based/oposs_next_ups.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@
315315
"query": SNMPTree(base=upsMIB + ".2", oids=["3.0"]),
316316
"keys": ["value"],
317317
"scale": 60.0,
318-
"metric_name": "oposs_next_backup_time",
318+
"metric_name": "oposs_next_time_remaining",
319319
"render_func": lambda v: "%.1fh" % (v / 3600.0),
320320
"default_params": {"levels_lower": ("fixed", (1200.0, 600.0))},
321321
"boundaries": (0.0, 3600.0),
@@ -327,7 +327,7 @@
327327
"query": SNMPTree(base=upsMIB + ".2", oids=["2.0"]),
328328
"keys": ["value"],
329329
"scale": 1.0,
330-
"metric_name": "oposs_next_backup_time",
330+
"metric_name": "oposs_next_time_on_battery",
331331
"render_func": lambda v: "%.1fh" % (v / 3600.0),
332332
"default_params": {"levels_upper": ("fixed", (60.0, 300.0))},
333333
"boundaries": (0.0, 3600.0),

local/lib/python3/cmk_addons/plugins/oposs_next_ups/graphing/next_ups.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,20 @@
7777
color=Color.GREEN,
7878
)
7979

80-
metric_oposs_next_backup_time = Metric(
81-
name="oposs_next_backup_time",
82-
title=Title("Backup Time"),
80+
metric_oposs_next_time_remaining = Metric(
81+
name="oposs_next_time_remaining",
82+
title=Title("Battery Time Remaining"),
8383
unit=unit_seconds,
8484
color=Color.BLUE,
8585
)
8686

87+
metric_oposs_next_time_on_battery = Metric(
88+
name="oposs_next_time_on_battery",
89+
title=Title("Time On Battery"),
90+
unit=unit_seconds,
91+
color=Color.DARK_BLUE,
92+
)
93+
8794
# Graphs
8895
graph_oposs_next_temperature = Graph(
8996
name="oposs_next_temperature",
@@ -137,10 +144,16 @@
137144
minimal_range=MinimalRange(lower=0, upper=100),
138145
)
139146

140-
graph_oposs_next_backup_time = Graph(
141-
name="oposs_next_backup_time",
142-
title=Title("NextUPS Backup Time"),
143-
simple_lines=["oposs_next_backup_time"],
147+
graph_oposs_next_time_remaining = Graph(
148+
name="oposs_next_time_remaining",
149+
title=Title("NextUPS Battery Time Remaining"),
150+
simple_lines=["oposs_next_time_remaining"],
151+
)
152+
153+
graph_oposs_next_time_on_battery = Graph(
154+
name="oposs_next_time_on_battery",
155+
title=Title("NextUPS Time On Battery"),
156+
simple_lines=["oposs_next_time_on_battery"],
144157
)
145158

146159
# Perfometers
Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
#!/usr/bin/env python3
2+
# Copyright (C) 2025 OETIKER+PARTNER AG - License: GNU General Public License v2
3+
4+
"""Metric translations for the Next UPS plugin rename.
5+
6+
The v1 check names follow the pattern ``next_ups_<service_name>``,
7+
using generic metric names. The v2 plugin uses ``oposs_next_ups_<service_name>``
8+
with prefixed metric names.
9+
"""
10+
11+
from cmk.graphing.v1 import translations
12+
13+
# --- Temperature ---
14+
15+
translation_next_ups_battery_temperature = translations.Translation(
16+
name="next_ups_battery_temperature",
17+
check_commands=[translations.PassiveCheck("next_ups_battery_temperature")],
18+
translations={"temperature": translations.RenameTo("oposs_next_temperature")},
19+
)
20+
21+
# --- Input Voltage (per-phase RS/ST/TR) ---
22+
23+
translation_next_ups_phase_rs_input_voltage = translations.Translation(
24+
name="next_ups_phase_rs_input_voltage",
25+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_input_voltage")],
26+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
27+
)
28+
29+
translation_next_ups_phase_st_input_voltage = translations.Translation(
30+
name="next_ups_phase_st_input_voltage",
31+
check_commands=[translations.PassiveCheck("next_ups_phase_st_input_voltage")],
32+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
33+
)
34+
35+
translation_next_ups_phase_tr_input_voltage = translations.Translation(
36+
name="next_ups_phase_tr_input_voltage",
37+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_input_voltage")],
38+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
39+
)
40+
41+
# --- Output Voltage (per-phase) ---
42+
43+
translation_next_ups_phase_rs_output_voltage = translations.Translation(
44+
name="next_ups_phase_rs_output_voltage",
45+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_output_voltage")],
46+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
47+
)
48+
49+
translation_next_ups_phase_st_output_voltage = translations.Translation(
50+
name="next_ups_phase_st_output_voltage",
51+
check_commands=[translations.PassiveCheck("next_ups_phase_st_output_voltage")],
52+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
53+
)
54+
55+
translation_next_ups_phase_tr_output_voltage = translations.Translation(
56+
name="next_ups_phase_tr_output_voltage",
57+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_output_voltage")],
58+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
59+
)
60+
61+
# --- Bypass Voltage (per-phase) ---
62+
63+
translation_next_ups_phase_rs_bypass_voltage = translations.Translation(
64+
name="next_ups_phase_rs_bypass_voltage",
65+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_bypass_voltage")],
66+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
67+
)
68+
69+
translation_next_ups_phase_st_bypass_voltage = translations.Translation(
70+
name="next_ups_phase_st_bypass_voltage",
71+
check_commands=[translations.PassiveCheck("next_ups_phase_st_bypass_voltage")],
72+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
73+
)
74+
75+
translation_next_ups_phase_tr_bypass_voltage = translations.Translation(
76+
name="next_ups_phase_tr_bypass_voltage",
77+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_bypass_voltage")],
78+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
79+
)
80+
81+
# --- Battery Voltage ---
82+
83+
translation_next_ups_battery_voltage = translations.Translation(
84+
name="next_ups_battery_voltage",
85+
check_commands=[translations.PassiveCheck("next_ups_battery_voltage")],
86+
translations={"voltage": translations.RenameTo("oposs_next_voltage")},
87+
)
88+
89+
# --- Input Frequency (per-phase) ---
90+
91+
translation_next_ups_phase_rs_input_frequency = translations.Translation(
92+
name="next_ups_phase_rs_input_frequency",
93+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_input_frequency")],
94+
translations={"frequency": translations.RenameTo("oposs_next_frequency")},
95+
)
96+
97+
translation_next_ups_phase_st_input_frequency = translations.Translation(
98+
name="next_ups_phase_st_input_frequency",
99+
check_commands=[translations.PassiveCheck("next_ups_phase_st_input_frequency")],
100+
translations={"frequency": translations.RenameTo("oposs_next_frequency")},
101+
)
102+
103+
translation_next_ups_phase_tr_input_frequency = translations.Translation(
104+
name="next_ups_phase_tr_input_frequency",
105+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_input_frequency")],
106+
translations={"frequency": translations.RenameTo("oposs_next_frequency")},
107+
)
108+
109+
# --- Output Frequency (per-phase) ---
110+
111+
translation_next_ups_phase_rs_output_frequency = translations.Translation(
112+
name="next_ups_phase_rs_output_frequency",
113+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_output_frequency")],
114+
translations={"frequency": translations.RenameTo("oposs_next_frequency")},
115+
)
116+
117+
translation_next_ups_phase_st_output_frequency = translations.Translation(
118+
name="next_ups_phase_st_output_frequency",
119+
check_commands=[translations.PassiveCheck("next_ups_phase_st_output_frequency")],
120+
translations={"frequency": translations.RenameTo("oposs_next_frequency")},
121+
)
122+
123+
translation_next_ups_phase_tr_output_frequency = translations.Translation(
124+
name="next_ups_phase_tr_output_frequency",
125+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_output_frequency")],
126+
translations={"frequency": translations.RenameTo("oposs_next_frequency")},
127+
)
128+
129+
# --- Input Current (per-phase) ---
130+
131+
translation_next_ups_phase_rs_input_current = translations.Translation(
132+
name="next_ups_phase_rs_input_current",
133+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_input_current")],
134+
translations={"current": translations.RenameTo("oposs_next_current")},
135+
)
136+
137+
translation_next_ups_phase_st_input_current = translations.Translation(
138+
name="next_ups_phase_st_input_current",
139+
check_commands=[translations.PassiveCheck("next_ups_phase_st_input_current")],
140+
translations={"current": translations.RenameTo("oposs_next_current")},
141+
)
142+
143+
translation_next_ups_phase_tr_input_current = translations.Translation(
144+
name="next_ups_phase_tr_input_current",
145+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_input_current")],
146+
translations={"current": translations.RenameTo("oposs_next_current")},
147+
)
148+
149+
# --- Output Current (per-phase) ---
150+
151+
translation_next_ups_phase_rs_output_current = translations.Translation(
152+
name="next_ups_phase_rs_output_current",
153+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_output_current")],
154+
translations={"current": translations.RenameTo("oposs_next_current")},
155+
)
156+
157+
translation_next_ups_phase_st_output_current = translations.Translation(
158+
name="next_ups_phase_st_output_current",
159+
check_commands=[translations.PassiveCheck("next_ups_phase_st_output_current")],
160+
translations={"current": translations.RenameTo("oposs_next_current")},
161+
)
162+
163+
translation_next_ups_phase_tr_output_current = translations.Translation(
164+
name="next_ups_phase_tr_output_current",
165+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_output_current")],
166+
translations={"current": translations.RenameTo("oposs_next_current")},
167+
)
168+
169+
# --- Bypass Current (per-phase) ---
170+
171+
translation_next_ups_phase_rs_bypass_current = translations.Translation(
172+
name="next_ups_phase_rs_bypass_current",
173+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_bypass_current")],
174+
translations={"current": translations.RenameTo("oposs_next_current")},
175+
)
176+
177+
translation_next_ups_phase_st_bypass_current = translations.Translation(
178+
name="next_ups_phase_st_bypass_current",
179+
check_commands=[translations.PassiveCheck("next_ups_phase_st_bypass_current")],
180+
translations={"current": translations.RenameTo("oposs_next_current")},
181+
)
182+
183+
translation_next_ups_phase_tr_bypass_current = translations.Translation(
184+
name="next_ups_phase_tr_bypass_current",
185+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_bypass_current")],
186+
translations={"current": translations.RenameTo("oposs_next_current")},
187+
)
188+
189+
# --- Battery Current ---
190+
191+
translation_next_ups_battery_current = translations.Translation(
192+
name="next_ups_battery_current",
193+
check_commands=[translations.PassiveCheck("next_ups_battery_current")],
194+
translations={"current": translations.RenameTo("oposs_next_current")},
195+
)
196+
197+
# --- Output Apparent Power (per-phase) ---
198+
199+
translation_next_ups_phase_rs_output_apparent_power = translations.Translation(
200+
name="next_ups_phase_rs_output_apparent_power",
201+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_output_apparent_power")],
202+
translations={"power": translations.RenameTo("oposs_next_apparent_power")},
203+
)
204+
205+
translation_next_ups_phase_st_output_apparent_power = translations.Translation(
206+
name="next_ups_phase_st_output_apparent_power",
207+
check_commands=[translations.PassiveCheck("next_ups_phase_st_output_apparent_power")],
208+
translations={"power": translations.RenameTo("oposs_next_apparent_power")},
209+
)
210+
211+
translation_next_ups_phase_tr_output_apparent_power = translations.Translation(
212+
name="next_ups_phase_tr_output_apparent_power",
213+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_output_apparent_power")],
214+
translations={"power": translations.RenameTo("oposs_next_apparent_power")},
215+
)
216+
217+
# --- Output True Power (per-phase) ---
218+
219+
translation_next_ups_phase_rs_output_true_power = translations.Translation(
220+
name="next_ups_phase_rs_output_true_power",
221+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_output_true_power")],
222+
translations={"power": translations.RenameTo("oposs_next_true_power")},
223+
)
224+
225+
translation_next_ups_phase_st_output_true_power = translations.Translation(
226+
name="next_ups_phase_st_output_true_power",
227+
check_commands=[translations.PassiveCheck("next_ups_phase_st_output_true_power")],
228+
translations={"power": translations.RenameTo("oposs_next_true_power")},
229+
)
230+
231+
translation_next_ups_phase_tr_output_true_power = translations.Translation(
232+
name="next_ups_phase_tr_output_true_power",
233+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_output_true_power")],
234+
translations={"power": translations.RenameTo("oposs_next_true_power")},
235+
)
236+
237+
# --- Bypass True Power (per-phase) ---
238+
239+
translation_next_ups_phase_rs_bypass_true_power = translations.Translation(
240+
name="next_ups_phase_rs_bypass_true_power",
241+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_bypass_true_power")],
242+
translations={"power": translations.RenameTo("oposs_next_true_power")},
243+
)
244+
245+
translation_next_ups_phase_st_bypass_true_power = translations.Translation(
246+
name="next_ups_phase_st_bypass_true_power",
247+
check_commands=[translations.PassiveCheck("next_ups_phase_st_bypass_true_power")],
248+
translations={"power": translations.RenameTo("oposs_next_true_power")},
249+
)
250+
251+
translation_next_ups_phase_tr_bypass_true_power = translations.Translation(
252+
name="next_ups_phase_tr_bypass_true_power",
253+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_bypass_true_power")],
254+
translations={"power": translations.RenameTo("oposs_next_true_power")},
255+
)
256+
257+
# --- Output Load (per-phase) ---
258+
259+
translation_next_ups_phase_rs_output_load = translations.Translation(
260+
name="next_ups_phase_rs_output_load",
261+
check_commands=[translations.PassiveCheck("next_ups_phase_rs_output_load")],
262+
translations={"percentage": translations.RenameTo("oposs_next_load_pct")},
263+
)
264+
265+
translation_next_ups_phase_st_output_load = translations.Translation(
266+
name="next_ups_phase_st_output_load",
267+
check_commands=[translations.PassiveCheck("next_ups_phase_st_output_load")],
268+
translations={"percentage": translations.RenameTo("oposs_next_load_pct")},
269+
)
270+
271+
translation_next_ups_phase_tr_output_load = translations.Translation(
272+
name="next_ups_phase_tr_output_load",
273+
check_commands=[translations.PassiveCheck("next_ups_phase_tr_output_load")],
274+
translations={"percentage": translations.RenameTo("oposs_next_load_pct")},
275+
)
276+
277+
# --- Battery Charge ---
278+
279+
translation_next_ups_battery_charge_remaining = translations.Translation(
280+
name="next_ups_battery_charge_remaining",
281+
check_commands=[translations.PassiveCheck("next_ups_battery_charge_remaining")],
282+
translations={"percentage": translations.RenameTo("oposs_next_battery_pct")},
283+
)
284+
285+
# --- Battery Time Remaining ---
286+
287+
translation_next_ups_battery_time_remaining = translations.Translation(
288+
name="next_ups_battery_time_remaining",
289+
check_commands=[translations.PassiveCheck("next_ups_battery_time_remaining")],
290+
translations={"duration": translations.RenameTo("oposs_next_time_remaining")},
291+
)
292+
293+
# --- Time On Battery ---
294+
295+
translation_next_ups_time_on_battery = translations.Translation(
296+
name="next_ups_time_on_battery",
297+
check_commands=[translations.PassiveCheck("next_ups_time_on_battery")],
298+
translations={"duration": translations.RenameTo("oposs_next_time_on_battery")},
299+
)

0 commit comments

Comments
 (0)