Skip to content

Conversation

@Self-Perfection
Copy link

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.

@knorrie
Copy link
Owner

knorrie commented Dec 17, 2025

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.
So, it is kind of impossible for me to review what all the things are that are actually happening at the same time.

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

Self-Perfection and others added 4 commits December 17, 2025 18:49
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 <[email protected]>
@Self-Perfection
Copy link
Author

Self-Perfection commented Dec 17, 2025

@knorrie how about the split that I just pushed? I tried to make it easier for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants