#!/usr/bin/env python3
# Copyright (C) 2019 Checkmk GmbH - License: GNU General Public License v2
# This file is part of Checkmk (https://checkmk.com). It is subject to the terms and
# conditions defined in the file COPYING, which is part of this source code package.

from cmk.base.check_legacy_includes.fireeye import scan_fireeye

# .1.3.6.1.4.1.25597.11.5.1.9.0 0

factory_settings["active_vm_levels"] = {"vms": (100, 120)}


def discover_fireeye_active_vms(string_table):
    if string_table:
        yield None, {}


def check_fireeye_active_vms(no_item, params, info):
    value = int(info[0][0])
    return check_levels(
        value,
        "active_vms",
        params["vms"],
        human_readable_func=str,
        infoname="Active VMs",
    )


check_info["fireeye_active_vms"] = {
    "inventory_function": discover_fireeye_active_vms,
    "check_function": check_fireeye_active_vms,
    "service_description": "Active VMs",
    "default_levels_variable": "active_vm_levels",
    "group": "fireeye_active_vms",
    "snmp_info": (
        ".1.3.6.1.4.1.25597.11.5.1.9",
        [
            "0",  # FE-FIREEYE-MIB::feActiveVMs
        ],
    ),
    "snmp_scan_function": scan_fireeye,
    "has_perfdata": True,
}
