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

# <<<netapp_api_status:sep(9)>>>
# status ok


def inventory_netapp_api_status(info):
    return [(None, None)]


def check_netapp_api_status(item, _no_params, info):
    data = dict([line for line in info if len(line) == 2])

    if data.get("status"):
        state = 0 if data["status"].lower() in ["ok", "ok-with-suppressed", "ok_with_suppressed"
                                               ] else 2
        yield state, "Status: %s" % data["status"]
        del data["status"]

    for key, value in data.items():
        yield 0, "%s: %s" % (key.title(), value)


check_info["netapp_api_status"] = {
    'check_function': check_netapp_api_status,
    'inventory_function': inventory_netapp_api_status,
    'service_description': 'Diagnosis Status',
}
