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.
27 from cmk
.gui
.i18n
import _
28 from cmk
.gui
.valuespec
import (
41 from cmk
.gui
.plugins
.wato
import (
42 RulespecGroupCheckParametersStorage
,
43 register_check_parameters
,
48 RulespecGroupCheckParametersStorage
,
49 varname
="fileinfo_groups",
50 title
=_('File Grouping Patterns'),
51 help=_('The check <tt>fileinfo</tt> monitors the age and size of '
52 'a single file. Each file information that is sent '
53 'by the agent will create one service. By defining grouping '
54 'patterns you can switch to the check <tt>fileinfo.groups</tt>. '
55 'That check monitors a list of files at once. You can set levels '
56 'not only for the total size and the age of the oldest/youngest '
57 'file but also on the count. You can define one or several '
58 'patterns for a group containing <tt>*</tt> and <tt>?</tt>, for example '
59 '<tt>/var/log/apache/*.log</tt>. Please see Python\'s fnmatch for more '
60 'information regarding globbing patterns and special characters. '
61 'If the pattern begins with a tilde then this pattern is interpreted as '
62 'a regular expression instead of as a filename globbing pattern and '
63 '<tt>*</tt> and <tt>?</tt> are treated differently. '
64 'For files contained in a group '
65 'the discovery will automatically create a group service instead '
66 'of single services for each file. This rule also applies when '
67 'you use manually configured checks instead of inventorized ones. '
68 'Furthermore, the current time/date in a configurable format '
69 'may be included in the include pattern. The syntax is as follows: '
70 '$DATE:format-spec$ or $YESTERDAY:format-spec$, where format-spec '
71 'is a list of time format directives of the unix date command. '
72 'Example: $DATE:%Y%m%d$ is todays date, e.g. 20140127. A pattern '
73 'of /var/tmp/backups/$DATE:%Y%m%d$.txt would search for .txt files '
74 'with todays date as name in the directory /var/tmp/backups. '
75 'The YESTERDAY syntax simply subtracts one day from the reference time.'),
78 help=_("This defines one file grouping pattern."),
80 orientation
="horizontal",
83 title
=_("Name of group"),
89 orientation
="vertical",
91 TextAscii(title
=_("Include Pattern"), size
=40),
92 TextAscii(title
=_("Exclude Pattern"), size
=40),
95 forth
=lambda params
: isinstance(params
, str) and (params
, '') or params
),
98 add_label
=_("Add pattern group"),
103 register_check_parameters(
104 RulespecGroupCheckParametersStorage
,
106 _("Size, age and count of file groups"),
111 title
=_("Minimal age of oldest file"),
113 Age(title
=_("Warning if younger than")),
114 Age(title
=_("Critical if younger than")),
118 title
=_("Maximal age of oldest file"),
120 Age(title
=_("Warning if older than")),
121 Age(title
=_("Critical if older than")),
125 title
=_("Minimal age of newest file"),
127 Age(title
=_("Warning if younger than")),
128 Age(title
=_("Critical if younger than")),
132 title
=_("Maximal age of newest file"),
134 Age(title
=_("Warning if older than")),
135 Age(title
=_("Critical if older than")),
139 title
=_("Minimal size of smallest file"),
141 Filesize(title
=_("Warning if below")),
142 Filesize(title
=_("Critical if below")),
146 title
=_("Maximal size of smallest file"),
148 Filesize(title
=_("Warning if above")),
149 Filesize(title
=_("Critical if above")),
153 title
=_("Minimal size of largest file"),
155 Filesize(title
=_("Warning if below")),
156 Filesize(title
=_("Critical if below")),
160 title
=_("Maximal size of largest file"),
162 Filesize(title
=_("Warning if above")),
163 Filesize(title
=_("Critical if above")),
167 title
=_("Minimal size"),
169 Filesize(title
=_("Warning if below")),
170 Filesize(title
=_("Critical if below")),
174 title
=_("Maximal size"),
176 Filesize(title
=_("Warning if above")),
177 Filesize(title
=_("Critical if above")),
181 title
=_("Minimal file count"),
183 Integer(title
=_("Warning if below")),
184 Integer(title
=_("Critical if below")),
188 title
=_("Maximal file count"),
190 Integer(title
=_("Warning if above")),
191 Integer(title
=_("Critical if above")),
195 title
=_("Only check during the following times of the day"),
196 help=_("Outside these ranges the check will always be OK"),
201 MonitoringState(title
=_("Monitoring state"), default_value
=2),
204 orientation
="hroizontal",
206 ("count", _("File count at"), Integer()),
207 ("count_lower", _("File count below"), Integer()),
208 ("size", _("File size at"), Filesize()),
209 ("size_lower", _("File size below"), Filesize()),
210 ("largest_size", _("Largest file size at"), Filesize()),
211 ("largest_size_lower", _("Largest file size below"), Filesize()),
212 ("smallest_size", _("Smallest file size at"), Filesize()),
213 ("smallest_size_lower", _("Smallest file size below"), Filesize()),
214 ("oldest_age", _("Oldest file age at"), Age()),
215 ("oldest_age_lower", _("Oldest file age below"), Age()),
216 ("newest_age", _("Newest file age at"), Age()),
217 ("newest_age_lower", _("Newest file age below"), Age()),
222 title
=_("Level conjunctions"),
224 _("In order to check dependent file group statistics you can configure "
225 "conjunctions of single levels now. A conjunction consists of a monitoring state "
226 "and any number of upper or lower levels. If all of the configured levels within "
227 "a conjunction are reached then the related state is reported."),
230 ignored_keys
=["precompiled_patterns"]),
232 title
=_("File Group Name"),
234 "This name must match the name of the group defined "
235 "in the <a href=\"wato.py?mode=edit_ruleset&varname=fileinfo_groups\">%s</a> ruleset.")
236 % (_('File Grouping Patterns')),