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

factory_settings["ucs_c_rack_server_led_default_levels"] = {
    "amber": 1,
    "blue": 0,
    "green": 0,
    "red": 2,
}


@get_parsed_item_data
def check_ucs_c_rack_server_led(
    _item: str,
    params: Dict,
    led_dict: Dict,
) -> Iterable[Tuple[int, str]]:
    for k, v in sorted(led_dict.items()):
        if k == 'Color':
            state = params.get(v, 3)
        else:
            state = 0
        yield state, "%s: %s" % (k, v)


check_info['ucs_c_rack_server_led'] = {
    'inventory_function': discover(),
    'check_function': check_ucs_c_rack_server_led,
    'service_description': 'LED %s',
    'group': 'ucs_c_rack_server_led',
    'default_levels_variable': 'ucs_c_rack_server_led_default_levels'
}
