-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcollector
executable file
·47 lines (43 loc) · 1.1 KB
/
mcollector
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# coding: us-ascii
if Object.const_defined? :RUBY_VERSION
lib_dir = File.dirname(__FILE__) + '/lib'
$LOAD_PATH.push lib_dir
require 'rubygems'
require 'socket'
else
# mruby
GC.disable #XXX
lib_dir = File.dirname(__FILE__) + '/lib'
$LOAD_PATH.push lib_dir
end
require 'gri/mlog'
require 'gri/app_collector'
require 'gri/writer'
require 'gri/config'
require 'gri/builtindefs'
require 'gri/plugin'
config_path = '/usr/local/gri/gri.conf'
gritab_path = nil
wtype = nil
while arg = ARGV.shift
case arg
when /\A--debug/
$debug = true
when /\A--config-path(?:=(\w+))?/
config_path = ($1 || ARGV.shift)
when /\A--gritab-path(?:=(\w+))?/
gritab_path = ($1 || ARGV.shift)
when /\A--writer(?:=(\w+))?/
wtype = ($1 || ARGV.shift)
end
end
config = GRI::Config.init config_path
config['gritab-path'] = gritab_path if gritab_path
GRI::Plugin.load_plugins [], config
config['root-dir'] ||= GRI::Config::ROOT_PATH
config['tra-dir'] ||= '/usr/local/gri/tra'
wtype ||= 'fluent'
writer = GRI::Writer.create wtype, config.to_h
app = GRI::AppCollector.new(config)
app.writers.push writer
app.run