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

# <<<splunk_alerts>>>
# 5


def inventory_splunk_alerts(info):
    yield None, {}


def check_splunk_alerts(no_item, params, info):
    try:
        value = int(info[0][0])
    except (IndexError, ValueError):
        return

    infotext = "Number of fired alerts"

    yield check_levels(
        value, "fired_alerts", params.get("alerts"), human_readable_func=int, infoname=infotext
    )


check_info["splunk_alerts"] = {
    "check_function": check_splunk_alerts,
    "inventory_function": inventory_splunk_alerts,
    "service_description": "Splunk Alerts",
    "group": "splunk_alerts",
    "has_perfdata": True,
}
