You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: check-plugins/file-count/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
Checks the number of matching files or directories found. It can be also used to check the existence / absence of a single file.
6
6
7
-
Depending on the file and user (e.g. running as *icinga*), sudo (sudoers) is needed. It supports globs in accordance with [Python 3](https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob) or [Python 2](https://docs.python.org/2.7/library/glob.html). Beware that using recursive globs might cause high memory usage. Also note that there are small differences in recursive file matching between Python 2 and Python 3. Optionally, the check can be restricted to only consider files that were modified in a given timerange.
7
+
Depending on the file and user (e.g. running as *icinga*), sudo (sudoers) is needed. It supports globs in accordance with [Python 3](https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob). Beware that using recursive globs might cause high memory usage. Optionally, the check can be restricted to only consider files that were modified in a given timerange.
8
8
9
9
10
10
## Fact Sheet
@@ -38,8 +38,8 @@ options:
38
38
accordance with https://docs.python.org/3/library/path
39
39
lib.html#pathlib.Path.glob. Beware of using recursive
40
40
globs. This is mutually exclusive with -u / --url.
41
-
--only-dirs Only consider directories.
42
-
--only-files Only consider files.
41
+
--only-dirs Only count directories.
42
+
--only-files Only count files.
43
43
--password PASSWORD SMB Password.
44
44
--pattern PATTERN The search string to match against the names of SMB
45
45
directories or files. This pattern can use '*' as a
DESCRIPTION='Checks the number of matching files.'
35
35
@@ -45,7 +45,7 @@ def parse_args():
45
45
parser.add_argument(
46
46
'-V', '--version',
47
47
action='version',
48
-
version='%(prog)s: v{} by {}'.format(__version__, __author__)
48
+
version=f'%(prog)s: v{__version__} by {__author__}'
49
49
)
50
50
51
51
parser.add_argument(
@@ -64,21 +64,24 @@ def parse_args():
64
64
65
65
parser.add_argument(
66
66
'--filename',
67
-
help='File (or directory) name to check. Supports glob in accordance with https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob. Beware of using recursive globs. This is mutually exclusive with -u / --url.',
67
+
help='File (or directory) name to check. Supports glob in accordance with '
help="The search string to match against the names of SMB directories or files. This pattern can use '*' as a wildcard for multiple chars and '?' as a wildcard for a single char. Does not support regex patterns. Default: %(default)s.",
98
+
help="The search string to match against the names of SMB directories or files. "
99
+
"This pattern can use '*' as a wildcard for multiple chars and '?' as a wildcard for "
100
+
"a single char. "
101
+
"Does not support regex patterns. "
102
+
"Default: %(default)s.",
96
103
dest='PATTERN',
97
104
default=DEFAULT_PATTERN,
98
105
)
99
106
100
107
parser.add_argument(
101
108
'--timeout',
102
-
help='Network timeout in seconds. Default: %(default)s (seconds)',
109
+
help='Network timeout in seconds. '
110
+
'Default: %(default)s (seconds)',
103
111
dest='TIMEOUT',
104
112
type=int,
105
113
default=DEFAULT_TIMEOUT,
106
114
)
107
115
108
116
parser.add_argument(
109
117
'--timerange',
110
-
help='Set the timerange (seconds) in which the files should be considered. Supports ranges.',
118
+
help='Set the timerange (seconds) in which the files should be considered. '
119
+
'Supports ranges.',
111
120
dest='TIMERANGE',
112
121
)
113
122
114
123
parser.add_argument(
115
124
'-u', '--url',
116
-
help='Set the url of the file (or directory) to check, starting with "smb://". This is mutually exclusive with --filename.',
125
+
help='Set the url of the file (or directory) to check, starting with "smb://". '
126
+
'This is mutually exclusive with --filename.',
117
127
dest='URL',
118
128
type=str,
119
129
)
@@ -126,14 +136,47 @@ def parse_args():
126
136
127
137
parser.add_argument(
128
138
'-w', '--warning',
129
-
help='Set the warning number of files. Supports ranges.',
139
+
help='Set the warning number of files. '
140
+
'Supports ranges.',
130
141
dest='WARN',
131
142
)
132
143
133
144
args, _=parser.parse_known_args()
134
145
returnargs
135
146
136
147
148
+
defget_early_break_threshold(warn, crit):
149
+
"""Extract a numeric threshold for early loop termination.
150
+
Returns None if thresholds are too complex to parse.
151
+
"""
152
+
thresholds= []
153
+
forthresholdin [warn, crit]:
154
+
ifnotthreshold:
155
+
continue
156
+
# Try to extract numeric value from simple threshold formats
0 commit comments