-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from xt99/patch-1
Added include and ignore options for devices
- Loading branch information
Showing
1 changed file
with
17 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
# USAGE: | ||
# | ||
# NOTES: | ||
# Devices can be specifically included or ignored using -i or -I options: | ||
# e.g. metrics-disk.rb -I [svx]d[a-z][0-9]* | ||
# | ||
# LICENSE: | ||
# Copyright 2012 Sonian, Inc <[email protected]> | ||
|
@@ -49,6 +51,18 @@ class DiskGraphite < Sensu::Plugin::Metric::CLI::Graphite | |
long: '--convert', | ||
default: false | ||
|
||
option :ignore_device, | ||
description: 'Ignore devices matching pattern(s)', | ||
short: '-i DEV[,DEV]', | ||
long: '--ignore-device', | ||
proc: proc { |a| a.split(',') } | ||
|
||
option :include_device, | ||
description: 'Include only devices matching pattern(s)', | ||
short: '-I DEV[,DEV]', | ||
long: '--include-device', | ||
proc: proc { |a| a.split(',') } | ||
|
||
# Main function | ||
def run | ||
# http://www.kernel.org/doc/Documentation/iostats.txt | ||
|
@@ -62,6 +76,9 @@ def run | |
end | ||
next if stats == ['0'].cycle.take(stats.size) | ||
|
||
next if config[:ignore_device] && config[:ignore_device].find { |x| dev.match(x) } | ||
next if config[:include_device] && !config[:include_device].find { |x| dev.match(x) } | ||
|
||
metrics.size.times { |i| output "#{config[:scheme]}.#{dev}.#{metrics[i]}", stats[i] } | ||
end | ||
|
||
|