#!/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_decru_power(info):
    return [(l[0], "", None) for l in info]


def check_decru_power(item, params, info):
    for power in info:
        if power[0] == item:
            if power[1] != "1":
                return (2, "power supply in state %s" % power[1])
            return (0, "power supply ok")

    return (3, "power supply not found")


check_info["decru_power"] = {
    "check_function": check_decru_power,
    "inventory_function": inventory_decru_power,
    "service_description": "POWER %s",
    "snmp_info": (".1.3.6.1.4.1.12962.1.2.6.1", [2, 3]),
    "snmp_scan_function": lambda oid: "datafort" in oid(".1.3.6.1.2.1.1.1.0").lower(),
}
