Cleanup config.nodes_of
[check_mk.git] / checks / hyperv_checkpoints
blob5cf840bfea2943f4ea503025e37996174c540c7e
1 #!/usr/bin/python
2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
9 # | |
10 # | Copyright Mathias Kettner 2013 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 # <<<hyperv_checkpoints>>>
28 # Has_Checkpoints
29 # f5689086-243b-4dfe-9775-571ef6be8a1b 2063
30 # c85ae17b-1a6c-4a34-949a-a1b9385ef67a 2040
33 def inventory_hyperv_checkpoints(info):
34 return [(None, {})]
37 def check_hyperv_checkpoints(item, params, info):
38 snapshots = []
39 for line in info:
40 if len(line) != 2:
41 continue
42 snapshots.append((line[0], int(line[1])))
44 if snapshots:
45 yield 0, "%s checkpoints" % len(snapshots)
47 # We assume that the last snapshot is the last line
48 # of the agent output
49 for title, key, snapshot in [
50 ("Oldest", "age_oldest", max(snapshots, key=lambda x: x[1])),
51 ("Last", "age", snapshots[-1]),
53 name, age = snapshot
54 infotext = "%s: %s (%s)" % (title, get_age_human_readable(age), name)
55 warn, crit = params.get(key, (None, None))
56 if crit is not None and age >= crit:
57 state = 2
58 elif warn is not None and age >= warn:
59 state = 1
60 else:
61 state = 0
62 if state:
63 infotext += " (warn/crit at %s/%s)" % (get_age_human_readable(warn),
64 get_age_human_readable(crit))
65 yield state, infotext, [(key, age, warn, crit)]
66 else:
67 yield 0, "No Checkpoints found"
70 check_info["hyperv_checkpoints"] = {
71 "check_function": check_hyperv_checkpoints,
72 "inventory_function": inventory_hyperv_checkpoints,
73 "service_description": "HyperV Checkpoints",
74 "group": "vm_snapshots",
75 "has_perfdata": True,