Created
July 26, 2022 01:26
-
-
Save smortex/0e301186055aa32bfcd906a28d013743 to your computer and use it in GitHub Desktop.
Run multiple riemann-tools in a singe ruby process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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