Windows Update Service mit Ausnahme von " Microsoft Defender Antivirus"

Mit einem Hack (durch @andreas-doehler) konnten wir alle Defender Updates aus den Listen ausblenden.

Es wurde die Datei windows_updates.py nach /omd/sites/xxx/local/lib/python3/cmk/base/plugins/agent_based kopiert und angepasst.

def check_windows_updates(params: Mapping[str, Any], section: Section) -> CheckResult:
    if section.failed:
        yield Result(state=State.CRIT, notice=f"({section.failed})")

    imp_update = section.important_updates
    updates_clean = []
    for line in imp_update:
        if not "Microsoft Defender Antivirus" in line:
            updates_clean.append(line)

    yield from check_levels(
        len(updates_clean),
        metric_name="important",
        levels_upper=params["levels_important"],
        render_func=lambda x: f"{x:d}",
        label="Important",
    )
    if updates_clean:
        yield Result(state=State.OK, notice=f"({'; '.join(updates_clean)})")

    yield from check_levels(
        len(section.optional_updates),
        metric_name="optional",
        levels_upper=params["levels_optional"],
        render_func=lambda x: f"{x:d}",
        label="Optional",
    )

    if section.reboot_required:
        yield Result(state=State.WARN, summary="Reboot required to finish updates")

    if not section.forced_reboot or (delta := section.forced_reboot - time.time()) < 0:
        return

    yield from check_levels(
        delta,
        levels_lower=params["levels_lower_forced_reboot"],
        render_func=render.timespan,
        label="Time to enforced reboot to finish updates",
    )

MfG Paul

2 Likes