#!/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_superstack3_sensors(info):
    return [(line[0], None) for line in info if line[1] != "not present"]


def check_superstack3_sensors(item, params, info):
    for name, state in info:
        if name == item:
            if state == "failure":
                return (2, "status is %s" % state)
            elif state == "operational":
                return (0, "status is %s" % state)
            return (1, "status is %s" % state)
    return (3, "UNKOWN - sensor not found")


check_info["superstack3_sensors"] = {
    "check_function": check_superstack3_sensors,
    "inventory_function": inventory_superstack3_sensors,
    "service_description": "%s",
    "snmp_info": (".1.3.6.1.4.1.43.43.1.1", ["7", "10"]),
    "snmp_scan_function": lambda oid: "3com superstack 3" in oid(".1.3.6.1.2.1.1.1.0").lower(),
}
