2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2018 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 # <<<site_object_counts:sep(124)>>>
30 # Check commands|kernel;mem.linux|4;1
33 # Check commands|kernel;mem.linux|4;1
34 # {u'heute': {u'Check commands': {u'kernel': 4, u'mem.linux': 1},
35 # u'Tags': {u'prod': 1, u'snmp': 1}},
39 def parse_site_object_counts(info
):
44 if line0
.startswith("[[[") and line0
.endswith("]]]"):
46 site_objects
= parsed
.setdefault("%s/%s" % (site
, line
[0]), {})
49 _
, type_
, header
, data
= line
50 if site_objects
is not None and data
:
51 site_objects
.setdefault(type_
, dict(zip(header
.split(), map(int, data
.split(";")))))
55 def inventory_site_object_counts(parsed
):
60 def check_site_object_counts(item
, params
, parsed
):
66 for site
, data
in parsed
.iteritems():
68 for type_
, type_data
in data
.iteritems():
69 summary_of_type
= summary
.setdefault(type_
, {})
71 for k
, v
in type_data
.iteritems():
72 summary_of_type
.setdefault(k
, 0)
73 summary_of_type
[k
] += v
74 data_info
.append("%s %s" % (v
, k
))
75 site_infos
.append("%s: %s" % (type_
.title(), ", ".join(data_info
)))
76 details
.append("[%s] %s" % (site
, ", ".join(site_infos
)))
80 for type_
, data
in summary
.iteritems():
82 for k
, v
in data
.iteritems():
83 perfdata
.append((("%s %s" % (type_
, k
)).lower()\
85 .replace(".", "_"), v
))
86 type_infos
.append("%s %s" % (v
, k
))
87 infotexts
.append("%s: %s" % (type_
.title(), ", ".join(type_infos
)))
89 return 0, "[Summary] %s\n%s" % (", ".join(infotexts
), "\n".join(details
)), perfdata
92 check_info
['site_object_counts'] = {
93 'parse_function': parse_site_object_counts
,
94 'inventory_function': inventory_site_object_counts
,
95 'check_function': check_site_object_counts
,
96 'service_description': 'OMD objects', # Leave 'OMD' to be consistent (OMD %s apache,...)