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

climaveneta_alarms = {
    #20  : "Global (general)",
    21  : "Maintenance Status",
    22  : "Password",
    23  : "High water 1erature",
    24  : "High water 2erature",
    25  : "Low room humidity",
    26  : "High room humidity",
    27  : "Low Roomerature",
    28  : "High roomerature",
    29  : "High air inleterature",
    30  : "High air outleterature",
    31  : "Room humid probe",
    32  : "Room probe",
    33  : "Inlet 1 probe",
    34  : "Inlet 2 probe",
    35  : "Inlet 3 probe",
    36  : "Inlet 4 probe",
    37  : "Outlet 1 probe",
    38  : "Outlet 2 probe",
    39  : "Outlet 3 probe",
    40  : "Outlet 4 probe",
    41  : "Water 1erature probe",
    42  : "Water 2erature probe",
    43  : "Door open",
    44  : "EEPROM",
    45  : "Fan 1 disconnected",
    46  : "Fan 2 disconnected",
    47  : "Fan 3 disconnected",
    48  : "Fan 4 disconnected",
    49  : "Dew point",
    50  : "Flooding",
    51  : "LAN",
    52  : "Dirty filter",
    53  : "Electronic thermostatic valve",
    54  : "Low pressure",
    55  : "High pressure",
    56  : "Air flow",
    57  : "Fire smoke",
    58  : "I/O expansion",
    59  : "Inverter",
    60  : "Envelop",
    61  : "Polygon inconsistent",
    62  : "Delta pressure for inverter compressor",
    63  : "Primary power supply",
    64  : "Energy managment",
    65  : "Low current humidif",
    66  : "No water humidif",
    67  : "High current humidif",
    68  : "Humidifier Board Offline",
    69  : "Life timer expired Reset/Clean cylinder",
    70  : "Humidifier Drain",
    71  : "Generic Humidifier",
    72  : "Electric heater",
}


def inventory_climaveneta_alarm(info):
    return [(None,None)]


def check_climaveneta_alarm(item, params, info):
    hit = False
    for oid_id, status in info:
        alarm_id = int(oid_id.split('.')[0])
        if alarm_id in climaveneta_alarms.keys():
            if status != '0':
                hit = True
                yield 2, "Alarm: %s" % climaveneta_alarms[alarm_id]
    if not hit:
        yield 0, "No alarm state"


check_info["climaveneta_alarm"] = {
    "check_function"        : check_climaveneta_alarm,
    "inventory_function"    : inventory_climaveneta_alarm,
    "service_description"   : "Alarm Status",
    "snmp_scan_function"    : lambda oid: oid(".1.3.6.1.2.1.1.1.0") == "pCO Gateway",
    "snmp_info"             : (".1.3.6.1.4.1.9839.2.1", [ OID_END, 1 ] ),
}

