Skip to content

Commit ad34b00

Browse files
20254 innovaphone(licenses): fix division by zero
Instead of crashing at runtime, the check should return an unknown result when the total (denominator) is zero and still show the used/total values in the result summary. CMK-37821 Change-Id: Idcddd57aeb0477f7a9b3f88bf5a9d4ee8caf7ed3
1 parent 0b13d34 commit ad34b00

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

.werks/20254.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[//]: # (werk v3)
2+
# innovaphone_licenses: fix division by zero error
3+
4+
key | value
5+
---------- | ---
6+
date | 2026-08-07T04:53:19.239404+00:00
7+
version | 2.5.0p12
8+
class | fix
9+
edition | community
10+
component | checks
11+
level | 1
12+
compatible | yes
13+
14+
The _Licenses_ service on Innovaphone devices went UNKNOWN with a crash report
15+
when a device reported a total of 0 licenses (for example a misconfigured or
16+
not-yet-licensed system), since the utilization percentage was computed as a
17+
division by zero.
18+
19+
A total of 0 no longer crashes the check; the service instead reports state
20+
UNKNOWN with "Utilization: n/a", while still showing the used and total
21+
counts.

cmk/base/legacy_checks/innovaphone_licenses.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ def check_innovaphone_licenses(_no_item, params, info):
3434
if not info:
3535
return None
3636
total, used = map(savefloat, info[0])
37-
perc_used = (100.0 * used) / total
37+
perc_used = (100.0 * used) / total if total else None
3838
warn, crit = params["levels"]
39-
message = f"Used {used:.0f}/{total:.0f} Licences ({perc_used:.0f}%)"
39+
utilization_message = f" ({perc_used:.0f}%)" if perc_used is not None else ""
40+
message = f"Used {used:.0f}/{total:.0f} Licences{utilization_message}"
4041
levels = f"Warning/ Critical at ({warn}/{crit})"
4142
perf = [("licenses", used, None, None, 0, total)]
43+
if perc_used is None:
44+
return 3, message, perf
4245
if perc_used > crit:
4346
return 2, message + levels, perf
4447
if perc_used > warn:

0 commit comments

Comments
 (0)