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.
44 def inventory_omd_status(info
):
45 for site
in info
.keys():
49 def parse_omd_status(info
):
56 # items may appear several times in clusters
57 # so dont overwrite the previous node result
58 if item
not in parsed
:
61 parsed
[item
][node
] = {}
62 parsed
[item
][node
]["stopped"] = []
64 elif active
and line
[1] == 'OVERALL':
66 parsed
[item
][node
]["overall"] = "running"
68 parsed
[item
][node
]["overall"] = "stopped"
70 elif active
and line
[2] != '0':
71 parsed
[item
][node
]["stopped"].append(line
[1])
72 parsed
[item
][node
]["overall"] = "partially"
77 def check_omd_status(item
, _no_params
, parsed
):
79 if item
not in parsed
:
82 parsed_site
= parsed
[item
]
83 number_nodes
= len(parsed_site
)
86 for node
, services
in parsed_site
.iteritems():
87 if "overall" in services
and services
["overall"] == "stopped":
90 # stopped sites are only CRIT when all are stopped
91 if stopped_nodes
== number_nodes
:
96 for node
, services
in parsed_site
.iteritems():
98 node_text
= " on %s" % node
101 if "overall" not in services
:
102 infotext
= "defective installation%s" % node_text
104 elif services
["overall"] == "running":
105 infotext
= "running%s" % node_text
106 # running sites are always OK
108 elif services
["overall"] == "stopped":
109 infotext
= "stopped%s" % node_text
110 # stopped sites are only CRIT when all are stopped
111 yield state
, infotext
113 infotext
= "partially running%s, stopped services: " % node_text
114 infotext
+= ", ".join(services
["stopped"])
115 # partially running sites are always CRIT
119 check_info
["omd_status"] = {
120 'check_function': check_omd_status
,
121 'inventory_function': inventory_omd_status
,
122 'parse_function': parse_omd_status
,
123 'service_description': 'OMD %s status',