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_elphase(parsed
):
29 for item
in parsed
.keys():
33 # Parsed has the following form:
36 # "device_state" : (1, "warning"), # overall device state: state, state readable
37 # "voltage" : (220.17, (1, "Voltage is too low")), # with device state
38 # "current" : 12.0, # without device state
41 def check_elphase(item
, params
, parsed
):
42 if item
not in parsed
:
43 return # Item not found in SNMP data
46 if isinstance(value
, int):
51 Lower
, Upper
, Both
= range(3)
56 if "device_state" in parsed
[item
]:
57 device_state
, device_state_readable
= parsed
[item
]["device_state"]
58 if params
.get("map_device_states", []):
59 device_state_params
= dict(params
["map_device_states"])
60 if device_state
in device_state_params
:
61 state
= device_state_params
[device_state
]
62 elif device_state_readable
in device_state_params
:
63 state
= device_state_params
[device_state_readable
]
68 yield state
, "Device status: %s(%s)" % (device_state_readable
, device_state
)
70 for what
, title
, unit
, bound
, factor
in [
71 ("voltage", "Voltage", " V", Bounds
.Lower
, 1),
72 ("current", "Current", " A", Bounds
.Upper
, 1),
73 ("output_load", "Load", "%", Bounds
.Upper
, 1),
74 ("power", "Power", " W", Bounds
.Upper
, 1),
75 ("appower", "Apparent Power", " VA", Bounds
.Upper
, 1),
76 ("energy", "Energy", " Wh", Bounds
.Upper
, 1),
77 ("frequency", "Frequency", " hz", Bounds
.Both
, 1),
78 ("differential_current_ac", "Differential current AC", " mA", Bounds
.Upper
, 0.001),
79 ("differential_current_dc", "Differential current DC", " mA", Bounds
.Upper
, 0.001),
82 if what
in parsed
[item
]:
83 entry
= parsed
[item
][what
]
84 if isinstance(entry
, tuple):
85 value
, state_info
= entry
# (220.17, (1, "Voltage is too low"))
90 infotext
= "%s: %s%s" % (title
, tostring(value
), unit
)
92 perfdata
= [(what
, value
* factor
)]
95 warn_lower
= crit_lower
= warn
= crit
= None
96 if bound
== Bounds
.Both
:
97 warn_lower
, crit_lower
, warn
, crit
= params
[what
]
98 elif bound
== Bounds
.Upper
:
99 warn
, crit
= params
[what
]
101 warn_lower
, crit_lower
= params
[what
]
104 levelstext
= " (warn/crit below %s/%s%s)" %\
105 (tostring(warn_lower
), tostring(crit_lower
), unit
)
106 if value
< crit_lower
:
108 infotext
+= levelstext
109 elif value
< warn_lower
:
110 status
= max(status
, 1)
111 infotext
+= levelstext
114 levelstext
= " (warn/crit at %s/%s%s)" %\
115 (tostring(warn
), tostring(crit
), unit
)
118 infotext
+= levelstext
120 status
= max(status
, 1)
121 infotext
+= levelstext
123 perfdata
= [(what
, value
* factor
, warn
* factor
, crit
* factor
)]
125 yield status
, infotext
, perfdata