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