#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# |          _           _           _       _   __   _______        |
# |       __| |_  ___ __| |__  _ __ | |__   / | /  \ |__ / _ \       |
# |      / _| ' \/ -_) _| / / | '  \| / /   | || () | |_ \_, /       |
# |      \__|_||_\___\__|_\_\_|_|_|_|_\_\   |_(_)__(_)___//_/        |
# |                                            check_mk 1.0.39       |
# |                                                                  |
# | Copyright Mathias Kettner 2009                mk@mathias-kettner |
# +------------------------------------------------------------------+
# 
# This file is part of check_mk 1.0.39.
# 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.


def inventory_fsc_subsystems(checkname, info):
   return [ (line[0], line[1], (int(line[1]) * 0.9, int(line[1]) * 0.8)) for line in info if int(line[1]) > 0 ]

def check_fsc_subsystems(item, params, info):
   warn, crit = params
   for line in info: # , value1, value2 in info:
      name = line[0]
      if name != item: continue
      status = int(line[1])
      statusname = { 1:'ok', 2:'degraded', 3:'error', 4:'failed', 5:'unknown-init'}.get(status, 'invalid')
      if status == 1 or status == 5:
          return (0, "OK - %s - no problems" % statusname)
      elif status >= 2 and status <= 4:
          return (2, "CRITICAL - %s" % statusname)
      else:
          return (3, "UNKNOWN - unknown status %d" % status)
         
   return (3, "UNKNOWN - FAN %s not found in SNMP data" % item)

check_info['fsc_subsystems'] = (check_fsc_subsystems, "FSC %s", 0,  inventory_fsc_subsystems)
snmp_info['fsc_subsystems'] = ( "enterprises.231.2.10.2.11.3.1.1", [ 2, 3 ])
