#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# |             ____ _               _        __  __ _  __           |
# |            / ___| |__   ___  ___| | __   |  \/  | |/ /           |
# |           | |   | '_ \ / _ \/ __| |/ /   | |\/| | ' /            |
# |           | |___| | | |  __/ (__|   <    | |  | | . \            |
# |            \____|_| |_|\___|\___|_|\_\___|_|  |_|_|\_\           |
# |                                                                  |
# | Copyright Mathias Kettner 2015             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.

#   .--temperature---------------------------------------------------------.
#   |      _                                      _                        |
#   |     | |_ ___ _ __ ___  _ __   ___ _ __ __ _| |_ _   _ _ __ ___       |
#   |     | __/ _ \ '_ ` _ \| '_ \ / _ \ '__/ _` | __| | | | '__/ _ \      |
#   |     | ||  __/ | | | | | |_) |  __/ | | (_| | |_| |_| | | |  __/      |
#   |      \__\___|_| |_| |_| .__/ \___|_|  \__,_|\__|\__,_|_|  \___|      |
#   |                       |_|                                            |
#   +----------------------------------------------------------------------+
#   |                             main check                               |
#   '----------------------------------------------------------------------'

check_info['raritan_px2_sensors'] = {
    'parse_function'            : parse_raritan_sensors,
    'inventory_function'        : lambda parsed: inventory_raritan_sensors_temp(parsed, 'temp'),
    'check_function'            : check_raritan_sensors_temp,
    'service_description'       : 'Temperature %s',
    'has_perfdata'              : True,
    'snmp_info'                 :
        (".1.3.6.1.4.1.13742.6", [
            "5.5.3.1.2.1",  # measurementsExternalSensorIsAvailable -> True/False (1/0)
            OID_END,        # sensor nr.
            "3.6.3.1.5.1",  # externalSensorDescription
            "3.6.3.1.2.1",  # externalSensorType
            "5.5.3.1.3.1",  # measurementsExternalSensorState
            "3.6.3.1.16.1", # externalSensorUnits
            "3.6.3.1.17.1", # externalSensorDecimalDigits -> for scaling the values
            "5.5.3.1.4.1",  # measurementsExternalSensorValue
            "3.6.3.1.31.1", # externalSensorLowerCriticalThreshold
            "3.6.3.1.32.1", # externalSensorLowerWarningThreshold
            "3.6.3.1.33.1", # externalSensorUpperCriticalThreshold
            "3.6.3.1.34.1", # externalSensorUpperWarningThreshold
        ]),
    'snmp_scan_function'        : lambda oid: oid(".1.3.6.1.2.1.1.2.0") == ".1.3.6.1.4.1.13742.6",
    'group'                     : "temperature",
    'includes'                  : [ "raritan.include", "temperature.include" ],
}

#.
#   .--airflow-------------------------------------------------------------.
#   |                        _       __ _                                  |
#   |                   __ _(_)_ __ / _| | _____      __                   |
#   |                  / _` | | '__| |_| |/ _ \ \ /\ / /                   |
#   |                 | (_| | | |  |  _| | (_) \ V  V /                    |
#   |                  \__,_|_|_|  |_| |_|\___/ \_/\_/                     |
#   |                                                                      |
#   +----------------------------------------------------------------------+

check_info['raritan_px2_sensors.airflow'] = {
    'inventory_function'        : lambda parsed: inventory_raritan_sensors(parsed, 'airflow'),
    'check_function'            : check_raritan_sensors,
    'service_description'       : 'Air flow %s',
    'has_perfdata'              : True,
}

#.
#   .--humidity------------------------------------------------------------.
#   |              _                     _     _ _ _                       |
#   |             | |__  _   _ _ __ ___ (_) __| (_) |_ _   _               |
#   |             | '_ \| | | | '_ ` _ \| |/ _` | | __| | | |              |
#   |             | | | | |_| | | | | | | | (_| | | |_| |_| |              |
#   |             |_| |_|\__,_|_| |_| |_|_|\__,_|_|\__|\__, |              |
#   |                                                  |___/               |
#   +----------------------------------------------------------------------+

check_info['raritan_px2_sensors.humidity'] = {
    'inventory_function'        : lambda parsed: inventory_raritan_sensors(parsed, 'humidity'),
    'check_function'            : check_raritan_sensors,
    'service_description'       : 'Humidity %s',
    'has_perfdata'              : True,
}

#.
#   .--pressure------------------------------------------------------------.
#   |                                                                      |
#   |               _ __  _ __ ___  ___ ___ _   _ _ __ ___                 |
#   |              | '_ \| '__/ _ \/ __/ __| | | | '__/ _ \                |
#   |              | |_) | | |  __/\__ \__ \ |_| | | |  __/                |
#   |              | .__/|_|  \___||___/___/\__,_|_|  \___|                |
#   |              |_|                                                     |
#   +----------------------------------------------------------------------+

check_info['raritan_px2_sensors.pressure'] = {
    'inventory_function'        : lambda parsed: inventory_raritan_sensors(parsed, 'pressure'),
    'check_function'            : check_raritan_sensors,
    'service_description'       : 'Pressure %s',
    'has_perfdata'              : True,
}
