munin: metadata usage warning and critical levels#43
Open
Self-Perfection wants to merge 4 commits intoknorrie:masterfrom
Open
munin: metadata usage warning and critical levels#43Self-Perfection wants to merge 4 commits intoknorrie:masterfrom
Self-Perfection wants to merge 4 commits intoknorrie:masterfrom
Conversation
Owner
|
Hi! Sorry for the late reply... :-) Adding some alerting options to the munin plugin is indeed an interesting idea. The commit with changes that is included here does a bit of that, but it also rewrites almost the whole program. Is it possible to at least (if you still want to work on this, of course!) split up the changes that you made into several logical commits that all do 1 thing at a time? Thanks |
Refactor the munin_values() function to store all calculated values in a usage_info dictionary before printing them. This change separates the calculation logic from the output logic, making the code easier to understand and preparing it for extraction into a separate function in a future commit. No functional changes are made to the output.
Extract the usage calculation logic from munin_values() into a new calculate_munin_values() function. This function encapsulates all the logic for calculating usage statistics and returns a dictionary with the computed values. The munin_values() function now simply calls calculate_munin_values() and uses the returned dictionary to print the values. This makes the code more modular and prepares it for use in other contexts, such as calculating alert thresholds.
Replace multiple individual print() calls in munin_values() with a single template string that is formatted with all values at once. This makes the code more concise and easier to maintain. No functional changes are made to the output.
Add warning and critical alert thresholds for metadata usage to help prevent out-of-space situations caused by metadata exhaustion. The thresholds are calculated based on: - Currently allocated metadata space - Available unallocated space that can be used for metadata (rounded down to 256MB chunks, the typical metadata allocation size) Warning is triggered when free metadata drops below 15% of allocated metadata minus available unallocated space. Critical is triggered at 10%. This addresses the issue where btrfs can run out of metadata space even when data space is available, which can cause filesystem problems. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
dc2716b to
3db0f40
Compare
Author
|
@knorrie how about the split that I just pushed? I tried to make it easier for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I have several times encountered lack of free space due to depleted metadata. Thus I have added warning and critical levels to monitoring plugin.
No attempt to alert on free space for data is made as it is can be handled perfectly by df munin plugin.