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


# .1.3.6.1.4.1.46501.6.2.1.5.201007 alpha-bravo_doppelboden_frischluft --> DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogName.201007
# .1.3.6.1.4.1.46501.6.2.1.6.201007 normal --> DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogState.201007
# .1.3.6.1.4.1.46501.6.2.1.7.201007 14.9 --> DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogValue.201007



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


def inventory_didactum_can_sensors_analog_temp(parsed):
    return inventory_didactum_sensors(parsed, "temperature")


check_info['didactum_can_sensors_analog'] = {
    'parse_function'        : parse_didactum_sensors,
    'inventory_function'    : inventory_didactum_can_sensors_analog_temp,
    'check_function'        : check_didactum_sensors_temp,
    'service_description'   : 'Temperature CAN %s',
    'snmp_info'             : ('.1.3.6.1.4.1.46501.6.2.1', [
                                    "4",    # DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogType
                                    "5",    # DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogName
                                    "6",    # DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogState
                                    "7",    # DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogValue
                                    "10",   # DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogLowAlarm
                                    "11",   # DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogLowWarning
                                    "12",   # DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogHighWarning
                                    "13",   # DIDACTUM-SYSTEM-MIB::ctlCANSensorsAnalogHighAlarm
                              ]),
    'snmp_scan_function'    : scan_didactum,
    'has_perfdata'          : True,
    'group'                 : 'temperature',
    'includes'              : [ 'temperature.include', 'didactum.include' ],
}


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


def inventory_didactum_can_sensors_analog_humid(parsed):
    return inventory_didactum_sensors(parsed, "humidity")


check_info['didactum_can_sensors_analog.humidity'] = {
    'inventory_function'      : inventory_didactum_can_sensors_analog_humid,
    'check_function'          : check_didactum_sensors_humidity,
    'service_description'     : 'Humidity CAN %s',
    'has_perfdata'            : True,
    'group'                   : 'humidity',
    'includes'                : [ 'humidity.include', 'didactum.include' ],
}


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


def inventory_didactum_can_sensors_analog_volt(parsed):
    return inventory_didactum_sensors(parsed, "voltage")


check_info['didactum_can_sensors_analog.voltage'] = {
    'inventory_function'    : inventory_didactum_can_sensors_analog_volt,
    'check_function'        : check_didactum_sensors_voltage,
    'service_description'   : 'Phase CAN %s',
    'has_perfdata'          : True,
    'group'                 : 'el_inphase',
    'includes'              : [ 'elphase.include', 'didactum.include' ],
}
