rubix 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/bin/zabbix_api +31 -35
- data/bin/zabbix_pipe +25 -27
- data/lib/rubix/examples/es_monitor.rb +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.6
|
data/bin/zabbix_api
CHANGED
@@ -19,42 +19,38 @@ def Settings.usage
|
|
19
19
|
%Q{usage: #{raw_script_name} [...--param=val...] METHOD PARAMS}
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
exit(1)
|
30
|
-
end
|
22
|
+
begin
|
23
|
+
Settings.resolve!
|
24
|
+
rescue RuntimeError => e
|
25
|
+
puts e.message
|
26
|
+
Settings.dump_help
|
27
|
+
exit(1)
|
28
|
+
end
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
if Settings.rest.size < 2
|
31
|
+
Settings.dump_help
|
32
|
+
exit(1)
|
33
|
+
end
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
begin
|
41
|
-
Rubix.connect(Settings[:url], Settings[:username], Settings[:password])
|
42
|
-
|
43
|
-
params = JSON.parse(json_params)
|
44
|
-
response = Rubix.connection.request(method, params)
|
45
|
-
|
46
|
-
if Settings[:pretty]
|
47
|
-
puts JSON.pretty_generate(response.parsed)
|
48
|
-
else
|
49
|
-
puts response.parsed.to_json
|
50
|
-
end
|
51
|
-
|
52
|
-
rescue JSON::ParserError => e
|
53
|
-
puts "Invalid JSON -- #{e.message}"
|
54
|
-
exit(1)
|
55
|
-
rescue Rubix::Error => e
|
56
|
-
puts e.message
|
57
|
-
exit(1)
|
58
|
-
end
|
35
|
+
method = Settings.rest[0]
|
36
|
+
json_params = Settings.rest[1]
|
59
37
|
|
38
|
+
begin
|
39
|
+
Rubix.connect(Settings[:url], Settings[:username], Settings[:password])
|
40
|
+
|
41
|
+
params = JSON.parse(json_params)
|
42
|
+
response = Rubix.connection.request(method, params)
|
43
|
+
|
44
|
+
if Settings[:pretty]
|
45
|
+
puts JSON.pretty_generate(response.parsed)
|
46
|
+
else
|
47
|
+
puts response.parsed.to_json
|
48
|
+
end
|
49
|
+
|
50
|
+
rescue JSON::ParserError => e
|
51
|
+
puts "Invalid JSON -- #{e.message}"
|
52
|
+
exit(1)
|
53
|
+
rescue Rubix::Error => e
|
54
|
+
puts e.message
|
55
|
+
exit(1)
|
60
56
|
end
|
data/bin/zabbix_pipe
CHANGED
@@ -14,8 +14,9 @@ Settings.define 'verbose', :description => "Be verbose", :required => false, :ty
|
|
14
14
|
#
|
15
15
|
# Configuration for talking with the Zabbix server
|
16
16
|
#
|
17
|
-
Settings.define 'server', :description => "Hostname/IP of the Zabbix server", :required => true
|
17
|
+
Settings.define 'server', :description => "Hostname/IP of the Zabbix server", :required => true, :default => 'localhost'
|
18
18
|
Settings.define 'host', :description => "Name of the (possibly new) Zabbix host to write data to", :required => true
|
19
|
+
Settings.define 'configuration_file', :description => "Path to the Zabbix agent configuration file", :required => true, :default => '/etc/zabbix/zabbix_agentd.conf'
|
19
20
|
|
20
21
|
#
|
21
22
|
# Configuration for talking with the Zabbix API
|
@@ -45,33 +46,30 @@ Settings.define 'sender', :description => "Path to the zabbix_sender
|
|
45
46
|
Settings.define 'pipe', :description => "Path to the named pipe to read from", :required => false
|
46
47
|
Settings.define 'pipe_read_sleep', :description => "Seconds to sleep between reads from pipe", :required => true, :type => Float, :default => 0.1
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
49
|
+
begin
|
50
|
+
Settings.resolve!
|
51
|
+
rescue RuntimeError => e
|
52
|
+
$stderr.puts e.message
|
53
|
+
exit(1)
|
54
|
+
end
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
56
|
+
begin
|
57
|
+
Rubix.connect((Settings[:url] || File.join(Settings[:server], 'api_jsonrpc.php')), Settings[:username], Settings[:password])
|
58
|
+
|
59
|
+
rescue Rubix::Error => e
|
60
|
+
$stderr.puts e.message
|
61
|
+
exit(1)
|
62
|
+
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
64
|
+
begin
|
65
|
+
sender = Rubix::Sender.new(Settings)
|
66
|
+
rescue Rubix::Error => e
|
67
|
+
$stderr.puts e.message
|
68
|
+
exit(1)
|
69
|
+
end
|
70
70
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
71
|
+
begin
|
72
|
+
sender.run
|
73
|
+
rescue => e
|
74
|
+
$stderr.puts "#{e.class} -- #{e.message}"
|
76
75
|
end
|
77
|
-
|
@@ -49,7 +49,7 @@ class ESMonitor < Rubix::ClusterMonitor
|
|
49
49
|
end
|
50
50
|
write({
|
51
51
|
:hostname => "#{cluster_name}-elasticsearch",
|
52
|
-
:hostgroup => self.class::CLUSTER_HOSTGROUPS
|
52
|
+
:hostgroup => self.class::CLUSTER_HOSTGROUPS,
|
53
53
|
:templates => self.class::CLUSTER_TEMPLATES,
|
54
54
|
:application => self.class::CLUSTER_APPLICATIONS
|
55
55
|
}) do |d|
|
@@ -74,7 +74,7 @@ class ESMonitor < Rubix::ClusterMonitor
|
|
74
74
|
index_data['indices'].each_pair do |index_name, index_data|
|
75
75
|
write({
|
76
76
|
:hostname => "#{cluster_name}-elasticsearch",
|
77
|
-
:hostgroup => self.class::
|
77
|
+
:hostgroup => self.class::CLUSTER_HOSTGROUPS,
|
78
78
|
:templates => self.class::CLUSTER_TEMPLATES,
|
79
79
|
:appliation => index_name
|
80
80
|
}) do |d|
|
metadata
CHANGED