Sha256: d263ff859bf71873a4be40ead86aaa6687d1897135c0dfe9cb464a172cffe73a

Contents?: true

Size: 723 Bytes

Versions: 2

Compression:

Stored size: 723 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.match))[1]
            {options.name => value}
        end
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
perus-0.1.5 lib/perus/pinger/metrics/value.rb
perus-0.1.4 lib/perus/pinger/metrics/value.rb