#!/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.

fjdarye60_sum_status = {1: "unknown", 2: "unused", 3: "ok", 4: "warning", 5: "failed"}


def inventory_fjdarye60_sum(info):
    yield from ((index, {}) for index, _status in info if index != "")


def check_fjdarye60_sum(index, _no_param, info):
    for line in info:
        if line[0] == index:
            status = int(line[1])
            text = "Status is %s" % fjdarye60_sum_status[status]
            return (0 if status == 3 else 1 if status == 4 else 2, text)


# 1: fjdaryUnitStatus

check_info["fjdarye60_sum"] = {
    "check_function": check_fjdarye60_sum,
    "inventory_function": inventory_fjdarye60_sum,
    "service_description": "Summary Status %s",
    # 1: fjdaryUnitStatus
    "snmp_info": (".1.3.6.1.4.1.211.1.21.1.60.6", [0, "0"]),
    "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.211.1.21.1.60",
}
