#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2019 tribe29 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.


def inventory_stulz_alerts(info):
    return [(x[0], None) for x in info]


def check_stulz_alerts(item, _no_params, info):
    for line in info:
        if line[0] == item:
            if line[1] != "0":
                return 2, "Device is in alert state"
            return 0, "No alerts on device"
    return 3, "No information found about the device"


check_info["stulz_alerts"] = {
    "check_function": check_stulz_alerts,
    "inventory_function": inventory_stulz_alerts,
    "service_description": "Alerts %s ",
    "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.29462.10",
    "snmp_info": (".1.3.6.1.4.1.29462.10.2.1.4.4.1.1.1.1010", [OID_END, 1]),
}
