#!/usr/bin/python
# -*- coding: utf-8; py-indent-offset: 4 -*-
#  _______ __   _ ____     __
# |       |  \ | |___ \   / /
# |       |   \| | __) | / /-,_
# |       | |\   |/ __/ /__   _|
# |_______|_| \__|_____|   |_|
#
# @author Markus Birth <markus.birth@weltn24.de>
# MIBs: ftp://ftp.snellgroup.com/RollCall/SNMP_MIBs/

def inventory_snell_iqh_faults(info):
    inventory = [("Faults", None)]
    return inventory

def check_snell_iqh_faults(item, _no_params, info):
    faults = False
    if len(info)>0 and len(info[0])>0:
        faults = info[0][1]

    if faults:
        message = "%s" % (faults)
        if faults[:2] == "OK":
            status = 0
        else:
            status = 2
#        perfdata = [ ("Sessions", int(sesscount), None, None, 0, 100) ]

        return status, message
    return 3, "Faults info not found in SNMP data."

check_info["snell_iqh_faults"] = {
    "check_function"        : check_snell_iqh_faults,
    "inventory_function"    : inventory_snell_iqh_faults,
    "service_description"   : "%s",
    "snmp_info"             : (".1.3.6.1.4.1.7995.1.3.1", [ "429.1.1", "475.1.1" ], [
                                 OID_END,
                                    2028,    # Faults ("OK:None")
                              ]),
    "snmp_scan_function"    : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.7995.1.3"),
    "has_perfdata"          : False
}
