Refactoring: Changed all check parameters starting with an 'o' to the new rulespec...
[check_mk.git] / checks / unitrends_replication
blobc3ee46534e8f6a01da4d3c4b236fd53dee9ed968
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.
28 def inventory_unitrends_replication(info):
29 inventory = []
30 for _application, _result, _complete, target, _instance in info:
31 if target not in [x[0] for x in inventory]:
32 inventory.append((target, None))
33 return inventory
36 def check_unitrends_replication(item, _no_params, info):
37 # this never gone be a blessed check :)
38 replications = [x for x in info if x[3] == item]
39 if len(replications) == 0:
40 return 3, "No Entries found"
41 not_successfull = [x for x in replications if x[1] != "Success"]
42 if len(not_successfull) == 0:
43 return 0, "All Replications in the last 24 hours Successfull"
44 messages = []
45 for _application, result, _complete, target, instance in not_successfull:
46 messages.append("Target: %s, Result: %s, Instance: %s " % (target, result, instance))
47 # TODO: Maybe a good place to use multiline output here
48 return 2, "Errors from the last 24 hours: " + "/ ".join(messages)
51 check_info["unitrends_replication"] = {
52 "check_function": check_unitrends_replication,
53 "inventory_function": inventory_unitrends_replication,
54 "service_description": "Replicaion %s",