Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make max file count configurable in the directory check #6847

Merged
merged 3 commits into from
Jun 9, 2020
Merged
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
5 changes: 4 additions & 1 deletion directory/datadog_checks/directory/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def check(self, instance):
ignore_missing = is_affirmative(instance.get('ignore_missing', False))
follow_symlinks = is_affirmative(instance.get('follow_symlinks', True))
custom_tags = instance.get('tags', [])
max_filegauge_count = instance.get('max_filegauge_count', self.MAX_FILEGAUGE_COUNT)

if not exists(abs_directory):
msg = (
Expand All @@ -79,6 +80,7 @@ def check(self, instance):
follow_symlinks,
countonly,
custom_tags,
max_filegauge_count,
)

def _get_stats(
Expand All @@ -95,12 +97,13 @@ def _get_stats(
follow_symlinks,
countonly,
tags,
max_filegauge_count,
):
dirtags = ['{}:{}'.format(dirtagname, name)]
dirtags.extend(tags)
directory_bytes = 0
directory_files = 0
max_filegauge_balance = self.MAX_FILEGAUGE_COUNT
max_filegauge_balance = max_filegauge_count

# If we do not want to recursively search sub-directories only get the root.
walker = walk(directory, follow_symlinks) if recursive else (next(walk(directory, follow_symlinks)),)
Expand Down