diff --git a/bin/metrics-disk.rb b/bin/metrics-disk.rb index a14e28a..59285c8 100755 --- a/bin/metrics-disk.rb +++ b/bin/metrics-disk.rb @@ -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 @@ -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