Skip to content

Instantly share code, notes, and snippets.

@smortex
Created July 26, 2022 01:26
Show Gist options
  • Select an option

  • Save smortex/0e301186055aa32bfcd906a28d013743 to your computer and use it in GitHub Desktop.

Select an option

Save smortex/0e301186055aa32bfcd906a28d013743 to your computer and use it in GitHub Desktop.
Run multiple riemann-tools in a singe ruby process
#!/usr/bin/env ruby
# frozen_string_literal: true
Process.setproctitle($PROGRAM_NAME)
require 'riemann/tools/health'
require 'riemann/tools/net'
require 'riemann/tools/nut'
argv = ARGV.dup
threads = []
[
[Riemann::Tools::Health, %w[]],
# [Riemann::Tools::Net, %w[]],
[Riemann::Tools::Nut, %w[--interval 20]],
].each do |klass, extra_argv|
ARGV.replace(argv + extra_argv)
instance = klass.new
# Force evaluation of options. This rely on ARGV and needs to be done before
# we launch multiple threads which compete to read information from there.
instance.options
threads << Thread.new { instance.run }
end
threads.each(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment