2 # -*- encoding: utf-8; py-indent-offset: 4 -*-
3 # +------------------------------------------------------------------+
4 # | ____ _ _ __ __ _ __ |
5 # | / ___| |__ ___ ___| | __ | \/ | |/ / |
6 # | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
7 # | | |___| | | | __/ (__| < | | | | . \ |
8 # | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
10 # | Copyright Mathias Kettner 2017 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 factory_settings
['informix_logusage_default_levels'] = {'levels_perc': (80.0, 85.0)}
30 def parse_informix_logusage(info
):
35 if instance
is not None and line
== ["(constant)", "LOGUSAGE"]:
37 parsed
.setdefault(instance
, [])
38 parsed
[instance
].append(entry
)
40 elif line
[0].startswith("[[[") and line
[0].endswith("]]]"):
41 instance
= line
[0][3:-3]
43 elif entry
is not None:
44 if line
[0] == "(expression)":
45 k
, v
= line
[1].split(":")
47 k
, v
= line
[0], line
[1]
48 entry
.setdefault(k
, v
)
53 def inventory_informix_logusage(parsed
):
54 return [(instance
, {}) for instance
in parsed
]
57 def check_informix_logusage(item
, params
, parsed
):
62 yield 1, "Log information missing"
68 pagesize
= int(entry
['sh_pagesize'])
69 size
+= int(entry
['size']) * pagesize
70 used
+= int(entry
['used']) * pagesize
72 infotext
= "Files: %s, Size: %s, Used: %s" % \
73 (logfiles
, get_bytes_human_readable(size
),
74 get_bytes_human_readable(used
))
76 if 'levels' in params
:
77 warn
, crit
= params
['levels']
83 infotext
+= " (warn/crit at %s/%s)" % \
84 (get_bytes_human_readable(warn
),
85 get_bytes_human_readable(crit
))
87 yield state
, infotext
, [("file_count", logfiles
), ("log_files_total", size
),
88 ("log_files_used", used
)]
91 used_perc
= used
* 100.0 / size
92 infotext
= "%.2f%%" % used_perc
93 warn_perc
, crit_perc
= params
['levels_perc']
95 if used_perc
>= crit_perc
:
97 elif used_perc
>= warn_perc
:
100 infotext
+= " (warn/crit at %.2f%%/%.2f%%)" % (warn_perc
, crit_perc
)
102 yield state
, infotext
105 check_info
['informix_logusage'] = {
106 'parse_function': parse_informix_logusage
,
107 'inventory_function': inventory_informix_logusage
,
108 'check_function': check_informix_logusage
,
109 'has_perfdata': True,
110 'service_description': 'Informix Log Usage %s',
111 'default_levels_variable': 'informix_logusage_default_levels',