Sha256: 604dac1b99c768299e606f1bb143b18456a6a81762aba8802a79182120355b10

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 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
            line = `cat #{options.path} | grep #{options.grep}`
            value = line.match(Regexp.compile(options.match))[1]
            {options.name => value}
        end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
perus-0.1.2 lib/perus/pinger/metrics/value.rb
perus-0.1.1 lib/perus/pinger/metrics/value.rb
perus-0.1.0 lib/perus/pinger/metrics/value.rb