Sha256: 7b14c513f6dd4476b06b7de8abf32771c8befb72920e829de7d7493014f63423

Contents?: true

Size: 674 Bytes

Versions: 2

Compression:

Stored size: 674 Bytes

Contents

module Oxidized
  require "oxidized/input/cli"

  class Exec < Input
    include Input::CLI

    def connect(node)
      @node = node
      @log = File.open(Oxidized::Config::Log + "/#{@node.ip}-exec", "w") if Oxidized.config.input.debug?
      @node.model.cfg["exec"].each { |cb| instance_exec(&cb) }
    end

    def cmd(cmd_str)
      Oxidized.logger.debug "EXEC: #{cmd_str} @ #{@node.name}"
      # I'd really like to do popen3 with separate arguments, but that would
      # require refactoring cmd to take parameters
      %x(#{cmd_str})
    end

    private

    def disconnect
      true
    ensure
      @log.close if Oxidized.config.input.debug?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
oxidized-0.29.1 lib/oxidized/input/exec.rb
oxidized-0.29.0 lib/oxidized/input/exec.rb