Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions check-plugins/file-count/file-count
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ def parse_args():
default=False,
)

parser.add_argument(
'--no-early-break',
help='Disable early break optimization and count all matching files.',
dest='NO_EARLY_BREAK',
action='store_true',
default=False,
)

parser.add_argument(
'--password',
help='Password for SMB authentication.',
Expand Down Expand Up @@ -202,7 +210,10 @@ def main():
exceeded_threshold = False

# Determine if we can break early for performance
early_break_at = get_early_break_threshold(args.WARN, args.CRIT)
if args.NO_EARLY_BREAK:
early_break_at = None
else:
early_break_at = get_early_break_threshold(args.WARN, args.CRIT)

if args.FILENAME:
path = Path(args.FILENAME)
Expand Down Expand Up @@ -293,7 +304,8 @@ def main():
display_count = file_count - 1
msg = (
f'Found more than {display_count} matching '
f'{lib.txt.pluralize("file", display_count)} (thresholds {args.WARN}/{args.CRIT})'
f'{lib.txt.pluralize("file", display_count)} '
f'(thresholds {args.WARN}/{args.CRIT}, early-break active)'
)
else:
msg = (
Expand All @@ -309,6 +321,15 @@ def main():
_min=0,
)

state_text = {
STATE_OK: 'OK',
STATE_WARN: 'WARNING',
STATE_CRIT: 'CRITICAL',
STATE_UNKNOWN: 'UNKNOWN'
}.get(state, 'UNKNOWN')

msg = f'[{state_text}] {msg}'

# over and out
lib.base.oao(msg, state, perfdata, always_ok=args.ALWAYS_OK)

Expand Down