#!/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_octopus_cpu(info):
    if len(info[0][0]) == 1:
        return [(None, None)]


def check_octopus_cpu(_no_item, _no_params_info, info):
    cpu_perc = int(info[0][0][0])
    perfdata = [("util", "%.3f" % cpu_perc)]
    return 0, "CPU utilization is %d%%" % cpu_perc, perfdata


check_info["sni_octopuse_cpu"] = {
    "check_function": check_octopus_cpu,
    "inventory_function": inventory_octopus_cpu,
    "service_description": "CPU utilization",
    "has_perfdata": True,
    "snmp_scan_function": lambda oid: "agent for hipath" in oid(".1.3.6.1.2.1.1.1.0").lower(),
    "snmp_info": [
        (".1.3.6.1.4.1.231.7.2.9.1", [7]),
    ],
}
