#!/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_sessions(info):
    inventory = [("Sessions", None)]
#    for sesscount in info:
#        inventory.append( ("Sessions", None) )
    return inventory

def check_snell_iqh_sessions(item, _no_params, info):
    if len(info)>0 and len(info[0])>1:
        sesscount = info[0][1]
        message = "%s Gateway Ctrl Session%s" % (sesscount, "s" if sesscount!="1" else "")
        status = 0
        perfdata = [ ("Sessions", int("0"+sesscount), None, None, 0, 100) ]

        return status, message, perfdata

    return 3, "Sessions info not found in SNMP data."

check_info["snell_iqh_sessions"] = {
    "check_function"        : check_snell_iqh_sessions,
    "inventory_function"    : inventory_snell_iqh_sessions,
    "service_description"   : "%s",
    "snmp_info"             : (".1.3.6.1.4.1.7995.1.3.1", [ "429.1.1", "475.1.1" ], [
                                     OID_END,
                                        2007,    # No. of Gateway Ctrl Sessions
                              ]),
    "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"          : True
}
