#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# |             ____ _               _        __  __ _  __           |
# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
# |                                                                  |
# | Copyright Mathias Kettner 2014             mk@mathias-kettner.de |
# +------------------------------------------------------------------+
#
# This file is part of Check_MK.
# The official homepage is at http://mathias-kettner.de/check_mk.
#
# check_mk is free software;  you can redistribute it and/or modify it
# under the  terms of the  GNU General Public License  as published by
# the Free Software Foundation in version 2.  check_mk is  distributed
# in the hope that it will be useful, but WITHOUT ANY WARRANTY;  with-
# out even the implied warranty of  MERCHANTABILITY  or  FITNESS FOR A
# PARTICULAR PURPOSE. See the  GNU General Public License for more de-
# tails. You should have  received  a copy of the  GNU  General Public
# License along with GNU Make; see the file  COPYING.  If  not,  write
# to the Free Software Foundation, Inc., 51 Franklin St,  Fifth Floor,
# Boston, MA 02110-1301 USA.
#
# Example Output:
# .1.3.6.1.4.1.5951.4.1.1.41.8.1.1.4.47.118.97.114  "/var"
# .1.3.6.1.4.1.5951.4.1.1.41.8.1.1.6.47.102.108.97.115.104  "/flash"
# .1.3.6.1.4.1.5951.4.1.1.41.8.1.2.4.47.118.97.114  96133
# .1.3.6.1.4.1.5951.4.1.1.41.8.1.2.6.47.102.108.97.115.104  7976
# .1.3.6.1.4.1.5951.4.1.1.41.8.1.3.4.47.118.97.114  87418
# .1.3.6.1.4.1.5951.4.1.1.41.8.1.3.6.47.102.108.97.115.104  7256


def inventory_df_netscaler(info):
    mplist = []
    for mp, size_mb, _avail_mb in info:
        if int(size_mb) > 0 and mp not in inventory_df_exclude_mountpoints:
            mplist.append(mp)
    return df_inventory(mplist)


def check_df_netscaler(item, params, info):
    fslist = []
    for mp, size_mb, avail_mb in info:
        if "patterns" in params or item == mp:
            fslist.append((mp, int(size_mb), int(avail_mb), 0))
    return df_check_filesystem_list(item, params, fslist)


check_info["df_netscaler"] = {
    "check_function": check_df_netscaler,
    "inventory_function": inventory_df_netscaler,
    "default_levels_variable": "filesystem_default_levels",
    "service_description": "Filesystem %s",
    "has_perfdata": True,
    "group": "filesystem",
    "includes": ["size_trend.include", "df.include"],
    "snmp_info": (
        ".1.3.6.1.4.1.5951.4.1.1.41.8.1",
        [
            1,  # sysHealthDiskName
            2,  # sysHealthDiskSize
            3,  # sysHealthDiskAvail
        ]),
    "snmp_scan_function": lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.5951.1"),
}
