Sha256: 1236539ca55a562985dad7f8b019b3fb665cbf37a54e36a023e7f06f97e536b6

Contents?: true

Size: 722 Bytes

Versions: 38

Compression:

Stored size: 722 Bytes

Contents

module Perus::Pinger
    class Value < Command
        description 'Searches the file specified by "path" with the regular
                     expression specified by "grep". Returns the resulting
                     string to the server under the metric called "name". Valid
                     values for "path" are contained in the pinger config file.'
        option :path, restricted: true
        option :grep
        option :name
        metric!
        
        def run
            grep = options.grep.gsub('"', '\\"')
            line = shell(%Q[cat #{options.path} | egrep "#{grep}"])
            value = line.match(Regexp.compile(options.grep))[1]
            {options.name => value}
        end
    end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
perus-0.1.23 lib/perus/pinger/metrics/value.rb
perus-0.1.22 lib/perus/pinger/metrics/value.rb
perus-0.1.21 lib/perus/pinger/metrics/value.rb
perus-0.1.20 lib/perus/pinger/metrics/value.rb
perus-0.1.19 lib/perus/pinger/metrics/value.rb
perus-0.1.18 lib/perus/pinger/metrics/value.rb
perus-0.1.17 lib/perus/pinger/metrics/value.rb
perus-0.1.16 lib/perus/pinger/metrics/value.rb
perus-0.1.15 lib/perus/pinger/metrics/value.rb
perus-0.1.14 lib/perus/pinger/metrics/value.rb
perus-0.1.13 lib/perus/pinger/metrics/value.rb
perus-0.1.12 lib/perus/pinger/metrics/value.rb
perus-0.1.11 lib/perus/pinger/metrics/value.rb
perus-0.1.10 lib/perus/pinger/metrics/value.rb
perus-0.1.9 lib/perus/pinger/metrics/value.rb
perus-0.1.8 lib/perus/pinger/metrics/value.rb
perus-0.1.7 lib/perus/pinger/metrics/value.rb
perus-0.1.6 lib/perus/pinger/metrics/value.rb