2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2014 mk@mathias-kettner.de |
11 # +------------------------------------------------------------------+
13 # This file is part of Check_MK.
14 # The official homepage is at http://mathias-kettner.de/check_mk.
16 # check_mk is free software; you can redistribute it and/or modify it
17 # under the terms of the GNU General Public License as published by
18 # the Free Software Foundation in version 2. check_mk is distributed
19 # in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
20 # out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
21 # PARTICULAR PURPOSE. See the GNU General Public License for more de-
22 # tails. You should have received a copy of the GNU General Public
23 # License along with GNU Make; see the file COPYING. If not, write
24 # to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25 # Boston, MA 02110-1301 USA.
28 def inventory_cmciii_lcp_fans(info
):
30 # FAN infos have 4 elements. Split the single info line we get
31 # into even sized chunks of 4 elements. In some cases there might
32 # be non-fan information in the resulting data like infos about
33 # water cooling. Filter them out.
34 parts
= [info
[0][x
+ 1:x
+ 4] for x
in range(0, len(info
[0]), 4)]
35 for i
, (name
, _value
, status
) in enumerate(parts
):
36 if status
!= "off" and 'FAN' in name
:
37 # FIXME: Why not use the unique name? Maybe recode
38 inventory
.append((i
+ 1, None))
42 def check_cmciii_lcp_fans(item
, params
, info
):
44 lowlevel
= int(re
.sub(" .*$", "", info
[0][0])) # global low warning
46 parts
= [info
[0][x
+ 1:x
+ 4] for x
in range(0, len(info
[0]), 4)]
47 for i
, (name
, value
, status
) in enumerate(parts
):
49 rpm
, unit
= value
.split(" ", 1)
53 if status
== "OK" and rpm
>= lowlevel
:
55 elif status
== "OK" and rpm
< lowlevel
:
62 info_text
= "%s RPM: %d%s (limit %d%s)%s, Status %s" \
63 % (name
, rpm
, unit
, lowlevel
, unit
, sym
, status
)
65 perfdata
= [("rpm", str(rpm
) + unit
, str(lowlevel
) + ":", 0, 0)]
67 return (state
, info_text
, perfdata
)
69 return (3, "no SNMP data found")
71 check_info
['cmciii_lcp_fans'] = {
72 "check_function" : check_cmciii_lcp_fans
,
73 "inventory_function" : inventory_cmciii_lcp_fans
,
74 "has_perfdata" : True,
75 "service_description" : "LCP Fanunit FAN %s",
76 "snmp_scan_function" : lambda oid
: oid(".1.3.6.1.2.1.1.1.0").startswith("Rittal LCP") and \
77 oid(".1.3.6.1.4.1.2606.7.4.2.2.1.3.2.6").startswith("Air.Temperature.DescName"),
78 "snmp_info" : ( '.1.3.6.1.4.1.2606.7.4.2.2.1.10.2', range(34, 58)),