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

# Example output from agent:
# <<<emcvnx_info>>>
#
#
# Server IP Address:       10.1.36.13
# Agent Rev:           7.32.25 (1.56)
#
#
# Agent/Host Information
# -----------------------
#
#
#
# Agent Rev:           7.32.25 (1.56)
# Name:                K10
# Desc:
# Node:                A-CKM00114701225
# Physical Node:       K10
# Signature:           3195192
# Peer Signature:      3187006
# Revision:            05.32.000.5.201
# SCSI Id:             0
# Model:               VNX5300
# Model Type:          Rackmount
# Prom Rev:            7.00.00
# SP Memory:           8192
# Serial No:           CKM00114701225
# SP Identifier:       A
# Cabinet:             DPE7
#
# Name of the software package:        -Compression
# Revision of the software package:    -
# Commit Required:                     NO
# Revert Possible:                     NO
# Active State:                        YES
# Is installation completed:           YES
# Is this System Software:             NO
#
# [... more software packages follow ...]


def inventory_emcvnx_info(info):
    if info:
        return [ (None, None) ]


def check_emcvnx_info(item, _no_params, info):
    for line in info:
        if len(line) > 1:
            state = 0
            if line[0] == "Error":
                state = 2
            yield state, " ".join(line)


check_info['emcvnx_info'] = {
    "inventory_function"      : inventory_emcvnx_info,
    "check_function"          : check_emcvnx_info,
    "service_description"     : "EMC VNX Info"
}
