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

import cmk.base.plugins.agent_based.utils.pulse_secure as pulse_secure

METRIC_PULSE_SECURE_LOG = "log_file_utilization"


def check_pulse_secure_log_util(item, params, parsed):

    if not parsed:
        return None

    yield check_levels(
        parsed[METRIC_PULSE_SECURE_LOG],
        METRIC_PULSE_SECURE_LOG,
        params,
        infoname="Percentage of log file used",
        human_readable_func=get_percent_human_readable,
    )


check_info["pulse_secure_log_util"] = {
    "parse_function": lambda info: pulse_secure.parse_pulse_secure(info, METRIC_PULSE_SECURE_LOG),
    "inventory_function": discover_single,
    "check_function": check_pulse_secure_log_util,
    "service_description": "Pulse Secure log file utilization",
    "has_perfdata": True,
    "snmp_info": (
        ".1.3.6.1.4.1.12532",
        [
            "1",  # logFullPercent
        ],
    ),
    "snmp_scan_function": pulse_secure.scan_pulse_secure,
}
