#!/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_mailman_lists(info):
    return [(i[0], None) for i in info]


def check_mailman_lists(item, params, info):
    for line in info:
        name, num_members = line[0], saveint(line[1])
        if name == item:
            return (0, "%d members subscribed" % (num_members), [("count", num_members)])
    return (3, "List could not be found in agent output")


check_info["mailman_lists"] = {
    "check_function": check_mailman_lists,
    "inventory_function": inventory_mailman_lists,
    "service_description": "Mailinglist %s",
    "has_perfdata": True,
}
