Refactored snapin server_time to new snapin API
[check_mk.git] / checks / emc_datadomain_nvbat
blob42f24eaaecd7341707593f38524fee6326c51af6
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
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.
27 def inventory_emc_datadomain_nvbat(info):
28 inventory = []
29 for line in info:
30 item = line[0]+"-"+line[1]
31 inventory.append((item, None))
32 return inventory
34 def check_emc_datadomain_nvbat(item, _no_params, info):
35 state_table = { "0": ("OK", 0),
36 "1": ("Disabled", 1),
37 "2": ("Discharged", 2),
38 "3": ("Softdisabled", 1),
40 for line in info:
41 if item == line[0]+"-"+line[1]:
42 dev_charge = line[3]
43 dev_state = line[2]
44 dev_state_str = state_table.get(dev_state, ("Unknown",3))[0]
45 dev_state_rc = state_table.get(dev_state, ("Unknown",3))[1]
46 infotext = "Status %s Charge Level %s%%" % ( dev_state_str, dev_charge )
47 perfdata = [('charge', dev_charge+"%" )]
48 return dev_state_rc, infotext, perfdata
51 check_info["emc_datadomain_nvbat"] = {
52 "check_function" : check_emc_datadomain_nvbat,
53 "inventory_function" : inventory_emc_datadomain_nvbat,
54 "service_description" : "NVRAM Battery %s",
55 "has_perfdata" : True,
56 "snmp_info" : (".1.3.6.1.4.1.19746.1.2.3.1.1",
58 1, # BatteriesIndex
59 2, # BatteryIndex
60 3, # BatteryStatus
61 4, # BatteryCharge
64 "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.1.0").startswith("Data Domain OS")