Skip to content

Commit fe929c3

Browse files
racicLukaGerrit Code Review
authored andcommitted
Revert "17776 systemd_units: Add option to include disabled failed units in critical failed count for systemd summary"
This reverts commit a6bb272. Reason for revert: mistakenly pushed Change-Id: Ia69f2044b1cf8e2ebff693a795184c36db3926a1
1 parent a6bb272 commit fe929c3

5 files changed

Lines changed: 15 additions & 98 deletions

File tree

.werks/17776.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

cmk/base/plugins/agent_based/systemd_units.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,7 @@ def check_systemd_units_summary(
610610
sum_failed = sum(
611611
s.active_status == "failed"
612612
for s in units
613-
if s not in services_organised["excluded"]
614-
and (params["disabled_critical"] is True or s not in services_organised["disabled"])
613+
if s not in services_organised["excluded"] and s not in services_organised["disabled"]
615614
)
616615

617616
yield Result(
@@ -643,7 +642,6 @@ def check_systemd_units_summary(
643642

644643

645644
CHECK_DEFAULT_PARAMETERS_SUMMARY = {
646-
"disabled_critical": False,
647645
"states": {
648646
"active": 0,
649647
"inactive": 0,

cmk/gui/plugins/wato/check_parameters/systemd_services_summary.py

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,7 @@
1212
RulespecGroupCheckParametersApplications,
1313
)
1414
from cmk.gui.plugins.wato.utils.simple_levels import SimpleLevels
15-
from cmk.gui.valuespec import (
16-
Age,
17-
Checkbox,
18-
Dictionary,
19-
ListOf,
20-
Migrate,
21-
MonitoringState,
22-
RegExp,
23-
)
15+
from cmk.gui.valuespec import Age, Dictionary, ListOf, Migrate, MonitoringState, RegExp
2416

2517
REQUIRED_STATE_KEYS_AND_STATES = {"active": 0, "inactive": 0, "failed": 2}
2618

@@ -39,18 +31,6 @@ def _parameter_valuespec_systemd_units_summary() -> Migrate:
3931
return Migrate(
4032
valuespec=Dictionary(
4133
elements=[
42-
(
43-
"disabled_critical",
44-
Checkbox(
45-
default_value=True,
46-
label="Failed units that are disabled will be considered critical",
47-
title=_("Treat failed units that are disabled as critical"),
48-
help=_(
49-
"Failed service that are disabled are also considered for the status of the service. "
50-
"Activating this option will cause the service to be CRIT if a failed service is disabled."
51-
),
52-
),
53-
),
5434
(
5535
"states",
5636
Dictionary(

cmk/plugins/collection/checkman/systemd_units_services_summary

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ agents: linux
33
catalog: os/ps
44
license: GPLv2
55
distribution: check_mk
6-
description: This check gives a summary of the linux services provided by
7-
the command 'systemctl --all'.
8-
The check reports the number of all services and for each service
9-
type, i.e. 'active', 'inactive', 'failed' and other ones.
10-
The state mapping is configurable, by default active and inactive
11-
states are OK, failed and all others are CRIT.
12-
Note that by default, failed systemd services that are disabled do not result in CRIT.
13-
This is configurable so that such services do trigger a CRIT.
6+
description:
7+
This check gives a summary of the linux services provided by
8+
the command 'systemctl --all'.
9+
The check reports the number of all services and for each service
10+
type, i.e. 'active', 'inactive', 'failed' and other ones.
11+
The state mapping is configurable, by default active and inactive
12+
states are OK, failed and all others are CRIT.
1413

15-
item: The fixed statement {{Summary}}
14+
item:
15+
The fixed statement {{Summary}}
1616

17-
discovery: One summary service is created.
17+
discovery:
18+
One summary service is created.

tests/unit/cmk/base/plugins/agent_based/test_systemd_units.py

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from cmk.utils.check_utils import ParametersTypeAlias
1111

12-
from cmk.base.plugins.agent_based.agent_based_api.v1 import Metric, Result, Service, State
12+
from cmk.base.plugins.agent_based.agent_based_api.v1 import Result, Service, State
1313
from cmk.base.plugins.agent_based.systemd_units import (
1414
_services_split,
1515
CHECK_DEFAULT_PARAMETERS_SUMMARY,
@@ -519,7 +519,7 @@ def test_services_split(
519519
"├─4075632 /bin/bash /usr/bin/check_mk_agent",
520520
"├─4075634 cat",
521521
"├─4075658 systemctl status --all --type service --type socket --no-pager --lines 0",
522-
"└─4075659 tr -s ",
522+
"└─4075659 tr -s " "",
523523
"● check-mk-agent.socket - Local Checkmk agent socket",
524524
"Loaded: loaded (/lib/systemd/system/check-mk-agent.socket; enabled; vendor preset: enabled)",
525525
"Active: active (listening) since Tue 2024-11-12 15:58:09 CET; 1 day 15h ago",
@@ -903,7 +903,6 @@ def test_discover_systemd_units_services_summary(
903903
"else": 2,
904904
"states": {"active": 0, "failed": 2, "inactive": 0},
905905
"states_default": 2,
906-
"disabled_critical": False,
907906
},
908907
SECTION,
909908
[
@@ -917,7 +916,6 @@ def test_discover_systemd_units_services_summary(
917916
"else": 2,
918917
"states": {"active": 0, "failed": 2, "inactive": 0},
919918
"states_default": 2,
920-
"disabled_critical": False,
921919
},
922920
SECTION,
923921
[
@@ -934,7 +932,6 @@ def test_discover_systemd_units_services_summary(
934932
"else": 2,
935933
"states": {"active": 0, "failed": 2, "inactive": 0},
936934
"states_default": 2,
937-
"disabled_critical": False,
938935
},
939936
SECTION,
940937
[
@@ -951,7 +948,6 @@ def test_discover_systemd_units_services_summary(
951948
"else": 2,
952949
"states": {"active": 0, "failed": 2, "inactive": 0},
953950
"states_default": 2,
954-
"disabled_critical": False,
955951
},
956952
Section(services={}, sockets={}),
957953
[
@@ -982,7 +978,6 @@ def test_check_systemd_units_services(
982978
"else": 2,
983979
"states": {"active": 2, "failed": 1, "inactive": 0},
984980
"states_default": 2,
985-
"disabled_critical": False,
986981
},
987982
Section(
988983
sockets={
@@ -1022,7 +1017,6 @@ def test_check_systemd_units_sockets(
10221017
"else": 2,
10231018
"states": {"active": 0, "failed": 2, "inactive": 0},
10241019
"states_default": 2,
1025-
"disabled_critical": False,
10261020
"ignored": [],
10271021
"activating_levels": (30, 60),
10281022
"deactivating_levels": (30, 60),
@@ -1042,7 +1036,6 @@ def test_check_systemd_units_sockets(
10421036
"else": 2,
10431037
"states": {"active": 0, "failed": 1, "inactive": 0},
10441038
"states_default": 2,
1045-
"disabled_critical": False,
10461039
"ignored": [],
10471040
"activating_levels": (30, 60),
10481041
"deactivating_levels": (30, 60),
@@ -1091,7 +1084,6 @@ def test_check_systemd_units_sockets(
10911084
"activating_levels": (30, 60),
10921085
"deactivating_levels": (30, 60),
10931086
"reloading_levels": (30, 60),
1094-
"disabled_critical": False,
10951087
},
10961088
Section(
10971089
sockets={},
@@ -1137,7 +1129,6 @@ def test_check_systemd_units_sockets(
11371129
"activating_levels": (30, 60),
11381130
"deactivating_levels": (30, 60),
11391131
"reloading_levels": (30, 60),
1140-
"disabled_critical": False,
11411132
},
11421133
Section(
11431134
sockets={},
@@ -1170,7 +1161,6 @@ def test_check_systemd_units_sockets(
11701161
"activating_levels": (30, 60),
11711162
"deactivating_levels": (30, 60),
11721163
"reloading_levels": (30, 60),
1173-
"disabled_critical": False,
11741164
},
11751165
Section(
11761166
sockets={},
@@ -1203,7 +1193,6 @@ def test_check_systemd_units_sockets(
12031193
"activating_levels": (30, 60),
12041194
"deactivating_levels": (30, 60),
12051195
"reloading_levels": (30, 60),
1206-
"disabled_critical": False,
12071196
},
12081197
Section(
12091198
sockets={},
@@ -1230,7 +1219,6 @@ def test_check_systemd_units_sockets(
12301219
"else": 2,
12311220
"states": {"active": 0, "failed": 2, "inactive": 0},
12321221
"states_default": 2,
1233-
"disabled_critical": False,
12341222
"ignored": [],
12351223
"activating_levels": (30, 60),
12361224
"deactivating_levels": (30, 60),
@@ -1262,7 +1250,6 @@ def test_check_systemd_units_sockets(
12621250
"else": 2,
12631251
"states": {"active": 0, "failed": 2, "inactive": 0},
12641252
"states_default": 2,
1265-
"disabled_critical": False,
12661253
"ignored": [
12671254
"systemd-timesyncd.service",
12681255
"systemd-ask-password-console",
@@ -1298,7 +1285,6 @@ def test_check_systemd_units_sockets(
12981285
"else": 2,
12991286
"states": {"active": 0, "failed": 2, "inactive": 0},
13001287
"states_default": 2,
1301-
"disabled_critical": False,
13021288
"ignored": [
13031289
"systemd.",
13041290
],
@@ -1344,7 +1330,6 @@ def test_check_systemd_units_sockets(
13441330
"else": 2,
13451331
"states": {"active": 0, "failed": 2, "inactive": 0},
13461332
"states_default": 2,
1347-
"disabled_critical": False,
13481333
"ignored": [],
13491334
"activating_levels": (30, 60),
13501335
"deactivating_levels": (30, 60),
@@ -1370,43 +1355,11 @@ def test_check_systemd_units_sockets(
13701355
],
13711356
id="One failed, but disabled",
13721357
),
1373-
pytest.param(
1374-
{
1375-
"disabled_critical": True,
1376-
"else": 2,
1377-
"states": {"active": 0, "failed": 2, "inactive": 0},
1378-
"states_default": 2,
1379-
"ignored": [],
1380-
"activating_levels": (30, 60),
1381-
"deactivating_levels": (30, 60),
1382-
"reloading_levels": (30, 60),
1383-
},
1384-
Section(
1385-
sockets={},
1386-
services={
1387-
"systemd-timesyncd.service": UnitEntry(
1388-
name="systemd-timesyncd.service",
1389-
loaded_status="loaded",
1390-
active_status="failed",
1391-
current_state="failed",
1392-
description="Import ZFS pool fgprs\\x2dpbs02\\x2dpool1\\x2d100",
1393-
enabled_status="disabled",
1394-
),
1395-
},
1396-
),
1397-
[
1398-
Result(state=State.OK, summary="Total: 1"),
1399-
Result(state=State.OK, summary="Disabled: 1"),
1400-
Result(state=State.CRIT, summary="Failed: 1"),
1401-
],
1402-
id="One disabled, but critical state configured in params -> CRIT",
1403-
),
14041358
pytest.param(
14051359
{
14061360
"else": 2,
14071361
"states": {"active": 0, "failed": 0, "inactive": 0},
14081362
"states_default": 2,
1409-
"disabled_critical": False,
14101363
"ignored": [],
14111364
"activating_levels": (30, 60),
14121365
"deactivating_levels": (30, 60),

0 commit comments

Comments
 (0)