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

# Example output from agent:
# <<<logins>>>
# 3

logins_default_levels = (20, 30)


def inventory_logins(info):
    if info:
        return [(None, "logins_default_levels")]


def check_logins(_no_item, params, info):
    try:
        logins = int(info[0][0])
    except (IndexError, ValueError):
        return
    return check_levels(logins,
                        "logins",
                        params,
                        infoname="On system",
                        human_readable_func=lambda x: '%d' % x)


check_info["logins"] = {
    'check_function': check_logins,
    'inventory_function': inventory_logins,
    'service_description': 'Logins',
    'has_perfdata': True,
    'group': 'logins',
}
