zabbix_receiver 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zabbix_receiver/cli.rb +31 -34
- data/lib/zabbix_receiver/output/stdout.rb +4 -3
- data/lib/zabbix_receiver/version.rb +1 -1
- data/lib/zabbix_receiver/worker.rb +1 -1
- data/zabbix_receiver.gemspec +3 -2
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6bb55e93057af6f74f3a28e11eeea044c38b78d0
|
4
|
+
data.tar.gz: 5369d40a344d0973b03fffcba444af51de44b6ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ece7c04f1eb7379f87d570d915f1f8989d327c96ddc481ed8c637ee49bf2af4d7adc6733bbca81ca0c4fb834aa6615431aa09ea2a92b83521b04f8a7fb1c920
|
7
|
+
data.tar.gz: 8638037e040dcd4bcbf6050ddac7e841d32f363918fc684fde44030dbee39061a0bf27ee703eec827aeb32c1873cc082c8b3295a121baf625708995e57fcdcd5
|
data/lib/zabbix_receiver/cli.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
require 'zabbix_receiver'
|
2
2
|
require 'serverengine'
|
3
|
-
require '
|
3
|
+
require 'slop'
|
4
4
|
|
5
5
|
module ZabbixReceiver
|
6
6
|
class CLI
|
7
|
-
REQUIRED_OPTIONS = %i(daemonize workers proxy_to_host proxy_to_port bind port)
|
8
|
-
|
9
7
|
def self.start(argv)
|
10
8
|
self.new(argv).start
|
11
9
|
end
|
@@ -26,45 +24,44 @@ module ZabbixReceiver
|
|
26
24
|
private
|
27
25
|
|
28
26
|
def load_options(argv)
|
29
|
-
|
30
|
-
|
27
|
+
output_type = argv.first
|
28
|
+
output_class = get_output_class(output_type)
|
29
|
+
if output_class
|
30
|
+
argv.shift # output type
|
31
|
+
else
|
32
|
+
output_type = 'stdout'
|
33
|
+
output_class = get_output_class(output_type)
|
34
|
+
end
|
31
35
|
|
32
|
-
|
33
|
-
daemonize: false,
|
34
|
-
workers: 1,
|
35
|
-
bind: '0.0.0.0',
|
36
|
-
port: 10051,
|
37
|
-
proxy_to_port: 10051,
|
38
|
-
to: 'stdout',
|
39
|
-
}
|
36
|
+
puts "Using #{output_type} output."
|
40
37
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
38
|
+
opts = Slop::Options.new
|
39
|
+
opts.on('--help') { puts opts; exit }
|
40
|
+
opts.bool '--daemonize', default: false
|
41
|
+
opts.string '--log'
|
42
|
+
opts.string '--pid-path'
|
43
|
+
opts.integer '--workers', default: 1
|
44
|
+
opts.string '--bind', default: '0.0.0.0'
|
45
|
+
opts.integer '--port', default: 10051
|
46
|
+
opts.string '--proxy-to-host'
|
47
|
+
opts.integer '--proxy-to-port', default: 10051
|
48
|
+
opts.string '--log-level'
|
49
|
+
output_class.add_options(opts)
|
53
50
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
51
|
+
parser = Slop::Parser.new(opts)
|
52
|
+
@options = Hash[parser.parse(argv).to_hash.map do |k, v|
|
53
|
+
[k.to_s.tr('-', '_').to_sym, v]
|
54
|
+
end]
|
59
55
|
|
60
56
|
@options[:output_class] = output_class
|
61
|
-
@options[:output_options] = @options[:output_class].parse_options(argv_for_output)
|
62
57
|
end
|
63
58
|
|
64
|
-
def
|
65
|
-
require "zabbix_receiver/output/#{
|
66
|
-
class_name =
|
59
|
+
def get_output_class(type)
|
60
|
+
require "zabbix_receiver/output/#{type}"
|
61
|
+
class_name = type.split('_').map {|v| v.capitalize }.join
|
67
62
|
ZabbixReceiver::Output.const_get(class_name)
|
63
|
+
rescue NameError, LoadError
|
64
|
+
nil
|
68
65
|
end
|
69
66
|
end
|
70
67
|
end
|
@@ -1,15 +1,16 @@
|
|
1
1
|
module ZabbixReceiver
|
2
2
|
module Output
|
3
3
|
class Stdout
|
4
|
-
def self.
|
5
|
-
|
4
|
+
def self.add_options(opts)
|
5
|
+
opts.string '--indent', default: ''
|
6
6
|
end
|
7
7
|
|
8
8
|
def initialize(logger, options)
|
9
|
+
@options = options
|
9
10
|
end
|
10
11
|
|
11
12
|
def receive_sender_data(data)
|
12
|
-
puts data
|
13
|
+
puts @options[:indent] + data.inspect
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
data/zabbix_receiver.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "zabbix_receiver"
|
8
8
|
spec.version = ZabbixReceiver::VERSION
|
9
9
|
spec.authors = ["Ryota Arai"]
|
10
|
-
spec.email = ["ryota
|
10
|
+
spec.email = ["ryota.arai@gmail.com"]
|
11
11
|
spec.summary = %q{Server to receive sender data from zabbix-agent.}
|
12
12
|
spec.homepage = ""
|
13
13
|
spec.license = "MIT"
|
@@ -17,7 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
-
spec.
|
20
|
+
spec.add_dependency "serverengine", "~> 1.5.10"
|
21
|
+
spec.add_dependency "slop"
|
21
22
|
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.7"
|
23
24
|
spec.add_development_dependency "rake", "~> 10.0"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zabbix_receiver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
@@ -12,12 +12,26 @@ date: 2015-01-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: serverengine
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.5.10
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.5.10
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slop
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
33
|
version: '0'
|
20
|
-
type: :
|
34
|
+
type: :runtime
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
@@ -68,7 +82,7 @@ dependencies:
|
|
68
82
|
version: '0'
|
69
83
|
description:
|
70
84
|
email:
|
71
|
-
- ryota
|
85
|
+
- ryota.arai@gmail.com
|
72
86
|
executables:
|
73
87
|
- zabbix_receiver
|
74
88
|
extensions: []
|