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

def inventory_netgear_readynas_power(info):
    inventory = []
    for psuNumber, psuDesc, psuStatus in info:
        inventory.append( (psuNumber, None) )
    return inventory

def check_netgear_readynas_power(item, params, info):
    status = 0
    for psuNumber, psuDesc, psuStatus in info:
        if psuNumber != item: continue

        if psuStatus != "ok":
            status = 1

        message = "%s (%s)" % (psuDesc, psuStatus)

        return (status, message)

    return (3, "%s not found in SNMP data." % item)

check_info["netgear_readynas_power"] = {
    "check_function"        : check_netgear_readynas_power,
    "inventory_function"    : inventory_netgear_readynas_power,
    "service_description"   : "PSU %s",
    "snmp_info"             : (".1.3.6.1.4.1.4526.18.8.1", [
                                     1,    # psuNumber
                                     2,    # psuDesc
                                     3,    # psuStatus
                              ]),
    "snmp_scan_function"    : lambda oid: oid(".1.3.6.1.4.1.4526.18.1.0"),
    "has_perfdata"          : False
}
