Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)

## [Unreleased]
### Added
- `check-disk-usage.rb` - Option to define minimal free space threshold.

## [5.1.4] - 2020-11-05
### Fixed
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Usage: check-disk-usage.rb (options)
-m MAGIC Magic factor to adjust warn/crit thresholds. Example: .9
-l MINIMUM Minimum size to adjust (in GB)
-n NORMAL Levels are not adapted for filesystems of exactly this size, where levels are reduced for smaller filesystems and raised for larger filesystems.
-f FREESPACEBELOW Trigger warn/critical alarm only if free space on mount goes below this threshold (in GB). Useful on huge filesystems which are 99.X percent full and still have lots of space left.
```

**metrics-disk-usage.rb**
Expand Down
9 changes: 9 additions & 0 deletions bin/check-disk-usage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,13 @@ class CheckDisk < Sensu::Plugin::Check::CLI
proc: proc(&:to_f),
default: 100

option :freespacebelow,
short: '-f FREESPACEBELOW',
description: 'Trigger alarm only if free space on device is below '\
'this threshold (in GB)',
proc: proc(&:to_f),
default: 10_000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to better understand where the rationale for this default number came from. I'd imagine this default should be much lower value. 10,000 GB is maybe an appropriate value for a SAN/NAS but I would wager that a double digit number would be more appropriate. Most of my VMs at work have < 100 GB of local storage.


# Setup variables
#
def initialize
Expand Down Expand Up @@ -195,6 +202,8 @@ def check_mount(line)
used = to_human(fs_info.bytes_used)
total = to_human(fs_info.bytes_total)

return unless (fs_info.bytes_total - fs_info.bytes_used) <= (config[:freespacebelow] * 1_000_000_000)

if percent_b >= bcrit
@crit_fs << "#{line.mount_point} #{percent_b}% bytes usage (#{used}/#{total})"
elsif percent_b >= bwarn
Expand Down