Skip to content

Commit 3db0f40

Browse files
munin: add metadata usage warning and critical levels
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>
1 parent 4147ac9 commit 3db0f40

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

examples/munin/plugins/btrfs_usage

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import btrfs
2222
import os
2323
import sys
24+
from math import floor
2425

2526

2627
def calculate_munin_values(fs):
@@ -98,6 +99,14 @@ def munin_config(fs):
9899
print("metadata_unused.draw STACK")
99100
print("metadata_unused.info Unused Metadata")
100101
print("metadata_unused.colour 0000CC")
102+
103+
usage_info = calculate_munin_values(fs)
104+
#Assuming metadata is allocated by 256MB chunks
105+
available_unallocated_for_metadata = floor(usage_info['unallocated'] / (2**28)) * (2**28)
106+
metadata_warning = int((usage_info['metadata_allocated'] * 0.15) - available_unallocated_for_metadata)
107+
metadata_critical = int((usage_info['metadata_allocated'] * 0.10) - available_unallocated_for_metadata)
108+
print("metadata_unused.warning {}:".format(metadata_warning))
109+
print("metadata_unused.critical {}:".format(metadata_critical))
101110
else:
102111
print("data_metadata_used.label Used Data+Metadata")
103112
print("data_metadata_used.draw AREA")

0 commit comments

Comments
 (0)