Skip to content

Commit

Permalink
v0.5.0 - collector-library-path
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Wilhelm committed Dec 31, 2013
2 parents 4477743 + 0d6c344 commit 2064db3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 0.5.0

* collector.rb - make panoptimon available in $RUBYLIB

This allows ruby collectors to access the same library path as the
collector.rb which loaded them (only intended to provide access for
'panoptimon/util'.) This should allow more flexibility with e.g.
bundler. This approach is rather limited, but maybe simpler than
treating each collector as a standalone executable.

# 0.4.17

* collectors/memory - portability: parsing solaris kstat
Expand Down
21 changes: 20 additions & 1 deletion lib/panoptimon/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ def run
@last_run_time = Time.now # TODO .to_i ?

logger.info {"run command: #{cmdc}"}
@child = EM.popen3b(cmdc, CollectorSink, self)
@child =
begin
was_env = ENV
ENV.replace(_env_fixup(was_env))
EM.popen3b(cmdc, CollectorSink, self)
ensure
ENV.replace(was_env)
end
@child.on_unbind { |status, errmess|
logger.error {"collector #{name} failed: #{status}" +
(errmess.nil? ? '' :
Expand All @@ -53,6 +60,18 @@ def running?
@child.nil? ? false : true
end

# Include the lib path that contains this panoptimon
# TODO later maybe have configurable env.
def _env_fixup (was)
env = Hash[was]
libs = (env['RUBYLIB'] || '').split(File::PATH_SEPARATOR)
libdir = File.expand_path('../../', __FILE__)
libs.unshift(libdir) if
libs.find_index {|p| libdir == File.absolute_path(p) }.nil?
env['RUBYLIB'] = libs.join(File::PATH_SEPARATOR)
return env
end

end

class Metric < Hash
Expand Down
2 changes: 1 addition & 1 deletion lib/panoptimon/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Copyright (C) 2012-2013 Sourcefire, Inc.

module Panoptimon
VERSION = "0.4.17"
VERSION = "0.5.0"
end

0 comments on commit 2064db3

Please sign in to comment.