kurchatov 0.0.6 → 0.0.7.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +1 -0
- data/lib/kurchatov/application.rb +6 -20
- data/lib/kurchatov/monitor.rb +3 -3
- data/lib/kurchatov/plugin/dsl.rb +7 -0
- data/lib/kurchatov/plugin/riemann.rb +14 -3
- data/lib/kurchatov/plugin.rb +1 -1
- data/lib/kurchatov/responders/http.rb +29 -38
- data/lib/kurchatov/responders/riemann.rb +19 -42
- data/lib/kurchatov/responders/udp.rb +20 -29
- data/lib/kurchatov/version.rb +1 -1
- data/lib/ohai/plugins/freebsd/cpu.rb +52 -0
- data/lib/ohai/plugins/freebsd/hostname.rb +22 -0
- data/lib/ohai/plugins/freebsd/platform.rb +23 -0
- data/lib/ohai/plugins/freebsd/virtualization.rb +93 -0
- metadata +8 -5
- data/lib/kurchatov/responders/init.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7e6c68a87238baaef79f95a9f6d6da2c1df1eb7
|
4
|
+
data.tar.gz: a196e3e7973c49d16657ab6cb88306091d87933b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ac544720faa2e0588b20aba059e7e8a55557e58c5c56c2056b8710ff09d1705abc95be805ac73cfdfdbe1d02d05c5bae47955cb4a34df1c351faf5093fd545c
|
7
|
+
data.tar.gz: 0159379599e421a6949a4aff2db8f0ab0cfa29ed027e2cf70748a3c45c35d54a4eb8afd0b69f45cbf4762eec1f553de9288d8b7b973fc95d6393f7c1dee331c8
|
data/CHANGELOG
CHANGED
@@ -7,7 +7,6 @@ require 'kurchatov/config'
|
|
7
7
|
require 'kurchatov/log'
|
8
8
|
require 'kurchatov/mixin/init'
|
9
9
|
require 'kurchatov/plugin/config'
|
10
|
-
require 'kurchatov/responders/init'
|
11
10
|
require 'kurchatov/monitor'
|
12
11
|
|
13
12
|
module Kurchatov
|
@@ -116,23 +115,11 @@ module Kurchatov
|
|
116
115
|
Config[:host] ||= ohai[:fqdn] || ohai[:hostname]
|
117
116
|
end
|
118
117
|
|
119
|
-
def
|
118
|
+
def load_plugins(path)
|
120
119
|
return if Config[:test_plugin]
|
121
|
-
|
122
|
-
if Config[:udp_responder]
|
123
|
-
monitor << Responders::Udp.new(Config[:udp_responder])
|
124
|
-
end
|
125
|
-
if Config[:http_responder]
|
126
|
-
monitor << Responders::Http.new(Config[:http_responder])
|
127
|
-
end
|
128
|
-
monitor << Responders::Riemann.new(Config[:riemann_responder])
|
129
|
-
end
|
130
|
-
|
131
|
-
def configure_plugins
|
132
|
-
return if Config[:test_plugin]
|
133
|
-
plugins = Kurchatov::Plugins::Config.load_plugins(Config[:plugin_paths],
|
120
|
+
plugins = Kurchatov::Plugins::Config.load_plugins(path,
|
134
121
|
Config[:config_file])
|
135
|
-
plugins.each {
|
122
|
+
plugins.each {|p| monitor << p}
|
136
123
|
end
|
137
124
|
|
138
125
|
def configure_test_plugin
|
@@ -144,11 +131,10 @@ module Kurchatov
|
|
144
131
|
configure_opts
|
145
132
|
configure_logging
|
146
133
|
configure_defaults
|
147
|
-
|
148
|
-
|
149
|
-
configure_plugins
|
134
|
+
load_plugins(Config[:plugin_paths])
|
135
|
+
load_plugins(File.join(File.dirname(__FILE__),'responders'))
|
150
136
|
configure_test_plugin
|
151
|
-
monitor.
|
137
|
+
monitor.start
|
152
138
|
end
|
153
139
|
|
154
140
|
end
|
data/lib/kurchatov/monitor.rb
CHANGED
@@ -8,7 +8,7 @@ module Kurchatov
|
|
8
8
|
|
9
9
|
def initialize(plugin)
|
10
10
|
@plugin = plugin
|
11
|
-
@thread = Thread.new { @plugin.
|
11
|
+
@thread = Thread.new { @plugin.start }
|
12
12
|
@count_errors = 0
|
13
13
|
@last_error = nil
|
14
14
|
@last_error_at = nil
|
@@ -42,7 +42,7 @@ module Kurchatov
|
|
42
42
|
event(:service => 'riemann client errors', :desc => desc, :state => 'critical')
|
43
43
|
end
|
44
44
|
end
|
45
|
-
@thread = Thread.new { @plugin.
|
45
|
+
@thread = Thread.new { @plugin.start }
|
46
46
|
true
|
47
47
|
end
|
48
48
|
|
@@ -61,7 +61,7 @@ module Kurchatov
|
|
61
61
|
@tasks << Task.new(plugin)
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
64
|
+
def start
|
65
65
|
loop do
|
66
66
|
@tasks.each { |t| exit Config[:ERROR_PLUGIN_REQ] if t.died? && @stop_on_error }
|
67
67
|
Log.debug("Check alive plugins [#{@tasks.count}]")
|
data/lib/kurchatov/plugin/dsl.rb
CHANGED
@@ -45,6 +45,11 @@ module Kurchatov
|
|
45
45
|
last.collect = block
|
46
46
|
end
|
47
47
|
|
48
|
+
def run(opts = {}, *args, &block)
|
49
|
+
return unless last.respond_to_ohai?(opts)
|
50
|
+
last.run = block
|
51
|
+
end
|
52
|
+
|
48
53
|
def run_if(opts = {}, &block)
|
49
54
|
return unless last.respond_to_ohai?(opts)
|
50
55
|
last.run_if = block
|
@@ -54,6 +59,7 @@ module Kurchatov
|
|
54
59
|
return unless last.respond_to_ohai?(opts)
|
55
60
|
last.required = block
|
56
61
|
end
|
62
|
+
alias :helpers :required
|
57
63
|
|
58
64
|
def last_plugin
|
59
65
|
last.plugin
|
@@ -66,6 +72,7 @@ module Kurchatov
|
|
66
72
|
|
67
73
|
def self.load_riemann_plugins(paths)
|
68
74
|
dsl = Kurchatov::Plugins::DSL.new
|
75
|
+
paths = [paths] unless paths.kind_of? Array
|
69
76
|
paths.map do |path|
|
70
77
|
Log.error("Directory #{path} not exists") and exit Kurchatov::Config[:ERROR_CONFIG] unless
|
71
78
|
File.directory?(path)
|
@@ -11,13 +11,16 @@ module Kurchatov
|
|
11
11
|
include Kurchatov::Mixin::Event
|
12
12
|
include Kurchatov::Mixin::Command
|
13
13
|
include Kurchatov::Mixin::Http
|
14
|
+
include Kurchatov::Mixin::Queue
|
15
|
+
include Kurchatov::Mixin::Monitor
|
14
16
|
|
15
|
-
attr_accessor :run_if, :collect, :always_start, :required, :ignore_errors, :interval, :plugin
|
17
|
+
attr_accessor :run_if, :collect, :run, :always_start, :required, :ignore_errors, :interval, :plugin
|
16
18
|
|
17
19
|
def initialize(name = '')
|
18
20
|
super(name)
|
19
21
|
@run_if = Proc.new { true }
|
20
22
|
@required = Proc.new { true }
|
23
|
+
@run = nil
|
21
24
|
@plugin = Mashie.new
|
22
25
|
@always_start = false
|
23
26
|
@ignore_errors = false
|
@@ -29,8 +32,12 @@ module Kurchatov
|
|
29
32
|
plugin
|
30
33
|
end
|
31
34
|
|
32
|
-
def
|
35
|
+
def start
|
33
36
|
super
|
37
|
+
run.nil? ? start_collect : start_run
|
38
|
+
end
|
39
|
+
|
40
|
+
def start_collect
|
34
41
|
loop do
|
35
42
|
t_start = Time.now
|
36
43
|
Timeout::timeout(interval * 2.to_f/3) do
|
@@ -40,6 +47,10 @@ module Kurchatov
|
|
40
47
|
end
|
41
48
|
end
|
42
49
|
|
50
|
+
def start_run
|
51
|
+
self.instance_eval(&run)
|
52
|
+
end
|
53
|
+
|
43
54
|
def respond_to_ohai?(opts = {})
|
44
55
|
opts.each { |k, v| return false unless ohai[k] == v }
|
45
56
|
true
|
@@ -55,7 +66,7 @@ module Kurchatov
|
|
55
66
|
end
|
56
67
|
|
57
68
|
def runnable_by_config?
|
58
|
-
Log.info("Plugin '#{self.name}' disabled by
|
69
|
+
Log.info("Plugin '#{self.name}' disabled by run and collect nil") and return if (collect.nil? && run.nil?)
|
59
70
|
Log.info("Plugin '#{self.name}' disabled in config") and return if (plugin[:disable] == true)
|
60
71
|
Log.info("Plugin '#{self.name}' not started by run_if condition ") and
|
61
72
|
return unless self.instance_eval(&run_if)
|
data/lib/kurchatov/plugin.rb
CHANGED
@@ -1,44 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Http < Kurchatov::Plugin
|
1
|
+
name 'http'
|
2
|
+
always_start true
|
4
3
|
|
5
|
-
|
4
|
+
default[:host], default[:port] = Kurchatov::Config[:http_responder].split(":")
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
@s_time = Time.now
|
11
|
-
end
|
12
|
-
|
13
|
-
def plugin_config
|
14
|
-
{:host => @host, :port => @port}
|
15
|
-
end
|
16
|
-
|
17
|
-
def run
|
18
|
-
super
|
19
|
-
@server ||= TCPServer.new(@host, @port)
|
20
|
-
loop do
|
21
|
-
client = @server.accept
|
22
|
-
response = info
|
23
|
-
client.gets
|
24
|
-
headers = "HTTP/1.1 200 OK\r\n" +
|
25
|
-
"Server: Kurchatov Ruby\r\n" +
|
26
|
-
"Content-Length: #{response.bytesize}\r\n" +
|
27
|
-
"Content-Type: application/json\r\n\r\n"
|
28
|
-
client.print headers
|
29
|
-
client.print response
|
30
|
-
client.close
|
31
|
-
end
|
32
|
-
end
|
6
|
+
run_if do
|
7
|
+
!!Kurchatov::Config[:http_responder]
|
8
|
+
end
|
33
9
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
10
|
+
helpers do
|
11
|
+
@s_time = Time.now
|
12
|
+
def json_info
|
13
|
+
{
|
14
|
+
:version => Kurchatov::VERSION,
|
15
|
+
:uptime => (Time.now - @s_time).to_i,
|
16
|
+
:monitor => monitor.inspect,
|
17
|
+
}.to_json + "\n"
|
18
|
+
end
|
19
|
+
end
|
41
20
|
|
42
|
-
|
21
|
+
run do
|
22
|
+
@server ||= TCPServer.new(plugin.host, plugin.port)
|
23
|
+
loop do
|
24
|
+
client = @server.accept
|
25
|
+
response = json_info
|
26
|
+
client.gets
|
27
|
+
headers = "HTTP/1.1 200 OK\r\n" +
|
28
|
+
"Server: Kurchatov Ruby\r\n" +
|
29
|
+
"Content-Length: #{response.bytesize}\r\n" +
|
30
|
+
"Content-Type: application/json\r\n\r\n"
|
31
|
+
client.print headers
|
32
|
+
client.print response
|
33
|
+
client.close
|
43
34
|
end
|
44
35
|
end
|
@@ -1,49 +1,26 @@
|
|
1
1
|
require 'kurchatov/riemann/client'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
class Riemann < Kurchatov::Plugin
|
3
|
+
name 'riemann'
|
4
|
+
always_start true
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
FLUSH_INTERVAL = 0.5
|
10
|
-
|
11
|
-
def initialize(conn)
|
12
|
-
@ignore_errors = true
|
13
|
-
@hosts = conn
|
14
|
-
@riemanns = Array.new
|
15
|
-
end
|
16
|
-
|
17
|
-
def plugin_config
|
18
|
-
{:hosts => @hosts}
|
19
|
-
end
|
20
|
-
|
21
|
-
def run
|
22
|
-
super
|
23
|
-
make_clients
|
24
|
-
loop { flush; sleep FLUSH_INTERVAL }
|
25
|
-
end
|
26
|
-
|
27
|
-
private
|
28
|
-
|
29
|
-
def make_clients
|
30
|
-
@riemanns.clear
|
31
|
-
@hosts.each do |host|
|
32
|
-
riemann, port = host.split(':')
|
33
|
-
@riemanns << Kurchatov::Riemann::Client.new(:host => riemann, :port => port)
|
34
|
-
@name = @riemanns.map { |c| "riemann client [#{c.host}:#{c.port}]" }.join(' , ')
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def flush
|
39
|
-
@events_to_send ||= events.to_flush
|
40
|
-
unless @events_to_send.empty?
|
41
|
-
@riemanns.each { |riemann| riemann << @events_to_send }
|
42
|
-
Log.debug("Sended events via #{@name.inspect}: #{@events_to_send}")
|
43
|
-
end
|
44
|
-
@events_to_send = nil
|
45
|
-
end
|
6
|
+
default[:hosts] = Kurchatov::Config[:riemann_responder]
|
46
7
|
|
8
|
+
helpers do
|
9
|
+
def flush
|
10
|
+
@events_to_send ||= events.to_flush
|
11
|
+
unless @events_to_send.empty?
|
12
|
+
@riemanns.each { |riemann| riemann << @events_to_send }
|
13
|
+
Log.debug("Sended events: #{@events_to_send}")
|
47
14
|
end
|
15
|
+
@events_to_send = nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
run do
|
20
|
+
@riemanns = []
|
21
|
+
plugin.hosts.each do |host|
|
22
|
+
riemann, port = host.split(':')
|
23
|
+
@riemanns << Kurchatov::Riemann::Client.new(:host => riemann, :port => port)
|
48
24
|
end
|
25
|
+
loop { flush; sleep 0.5 }
|
49
26
|
end
|
@@ -1,35 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Udp < Kurchatov::Plugin
|
1
|
+
name 'udp'
|
2
|
+
always_start true
|
4
3
|
|
5
|
-
|
4
|
+
default[:host], default[:port] = Kurchatov::Config[:udp_responder].to_s.split(":")
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
def plugin_config
|
13
|
-
{:host => @host, :port => @port}
|
14
|
-
end
|
15
|
-
|
16
|
-
def run
|
17
|
-
super
|
18
|
-
Socket.udp_server_loop(@host, @port) do |data, src|
|
19
|
-
process(data, src)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def process(data, src)
|
24
|
-
begin
|
25
|
-
event(JSON.parse(data))
|
26
|
-
src.reply "sended\n\n"
|
27
|
-
rescue => e
|
28
|
-
src.reply "failed to send: #{data.inspect}\n"
|
29
|
-
Log.error("Failed parse #{data.inspect}, #{e.class}: #{e}\n #{e.backtrace.join("\n")}")
|
30
|
-
end
|
31
|
-
end
|
6
|
+
run_if do
|
7
|
+
!!Kurchatov::Config[:udp_responder]
|
8
|
+
end
|
32
9
|
|
10
|
+
helpers do
|
11
|
+
def process(data, src)
|
12
|
+
begin
|
13
|
+
event(JSON.parse(data))
|
14
|
+
src.reply "sended\n\n"
|
15
|
+
rescue => e
|
16
|
+
src.reply "failed to send: #{data.inspect}\n"
|
17
|
+
Log.error("Failed parse #{data.inspect}, #{e.class}: #{e}\n #{e.backtrace.join("\n")}")
|
33
18
|
end
|
34
19
|
end
|
35
20
|
end
|
21
|
+
|
22
|
+
run do
|
23
|
+
Socket.udp_server_loop(plugin.host, plugin.port) do |data, src|
|
24
|
+
process(data, src)
|
25
|
+
end
|
26
|
+
end
|
data/lib/kurchatov/version.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2008 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "cpu"
|
20
|
+
|
21
|
+
# all dmesg output for smp I can find only provides info about a single processor
|
22
|
+
# identical processors is probably a hardware requirement so we'll duplicate data for each cpu
|
23
|
+
# old examples: http://www.bnv-bamberg.de/home/ba3294/smp/rbuild/index.htm
|
24
|
+
cpuinfo = Mash.new
|
25
|
+
|
26
|
+
# /var/run/dmesg.boot
|
27
|
+
#CPU: QEMU Virtual CPU version 0.9.1 (1862.02-MHz 686-class CPU)
|
28
|
+
# Origin = "GenuineIntel" Id = 0x623 Stepping = 3
|
29
|
+
# Features=0x78bfbfd<FPU,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,MMX,FXSR,SSE,SSE2>
|
30
|
+
# Features2=0x80000001<SSE3,<b31>>
|
31
|
+
|
32
|
+
File.open("/var/run/dmesg.boot").each do |line|
|
33
|
+
case line
|
34
|
+
when /CPU:\s+(.+) \(([\d.]+).+\)/
|
35
|
+
cpuinfo["model_name"] = $1
|
36
|
+
cpuinfo["mhz"] = $2
|
37
|
+
when /Origin = "(.+)"\s+Id = (.+)\s+Stepping = (.+)/
|
38
|
+
cpuinfo["vendor_id"] = $1
|
39
|
+
cpuinfo["stepping"] = $3
|
40
|
+
# These _should_ match /AMD Features2?/ lines as well
|
41
|
+
when /Features=.+<(.+)>/
|
42
|
+
cpuinfo["flags"] = $1.downcase.split(',')
|
43
|
+
# Features2=0x80000001<SSE3,<b31>>
|
44
|
+
when /Features2=[a-f\dx]+<(.+)>/
|
45
|
+
cpuinfo["flags"].concat($1.downcase.split(','))
|
46
|
+
when /Logical CPUs per core: (\d+)/
|
47
|
+
cpuinfo["cores"] = $1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
cpu cpuinfo
|
52
|
+
cpu[:total] = from("sysctl -n hw.ncpu")
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "hostname", "fqdn"
|
20
|
+
|
21
|
+
hostname from("hostname -s")
|
22
|
+
fqdn from("hostname -f")
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "platform", "platform_version"
|
20
|
+
|
21
|
+
platform from("uname -s").downcase
|
22
|
+
platform_version from("uname -r")
|
23
|
+
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Bryan McLellan (btm@loftninjas.org)
|
3
|
+
# Copyright:: Copyright (c) 2009 Bryan McLellan
|
4
|
+
# License:: Apache License, Version 2.0
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
|
19
|
+
provides "virtualization"
|
20
|
+
|
21
|
+
virtualization Mash.new
|
22
|
+
|
23
|
+
if from("sysctl -n security.jail.jailed").to_i == 1
|
24
|
+
virtualization[:system] = "jail"
|
25
|
+
virtualization[:role] = "guest"
|
26
|
+
end
|
27
|
+
|
28
|
+
# detect from modules
|
29
|
+
popen4("/sbin/kldstat") do |pid, stdin, stdout, stderr|
|
30
|
+
stdin.close
|
31
|
+
stdout.each do |line|
|
32
|
+
case line
|
33
|
+
when /vboxdrv/
|
34
|
+
virtualization[:system] = "vbox"
|
35
|
+
virtualization[:role] = "host"
|
36
|
+
when /vboxguest/
|
37
|
+
virtualization[:system] = "vbox"
|
38
|
+
virtualization[:role] = "guest"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# XXX doesn't work when jail is there but not running (ezjail-admin stop)
|
45
|
+
if from("jls -n \| wc -l").to_i >= 1
|
46
|
+
virtualization[:system] = "jail"
|
47
|
+
virtualization[:role] = "host"
|
48
|
+
end
|
49
|
+
|
50
|
+
# KVM Host support for FreeBSD is in development
|
51
|
+
# http://feanor.sssup.it/~fabio/freebsd/lkvm/
|
52
|
+
|
53
|
+
# Detect KVM/QEMU from cpu, report as KVM
|
54
|
+
# hw.model: QEMU Virtual CPU version 0.9.1
|
55
|
+
if from("sysctl -n hw.model") =~ /QEMU Virtual CPU/
|
56
|
+
virtualization[:system] = "kvm"
|
57
|
+
virtualization[:role] = "guest"
|
58
|
+
end
|
59
|
+
|
60
|
+
# http://www.dmo.ca/blog/detecting-virtualization-on-linux
|
61
|
+
if File.exists?("/usr/local/sbin/dmidecode")
|
62
|
+
popen4("dmidecode") do |pid, stdin, stdout, stderr|
|
63
|
+
stdin.close
|
64
|
+
found_virt_manufacturer = nil
|
65
|
+
found_virt_product = nil
|
66
|
+
stdout.each do |line|
|
67
|
+
case line
|
68
|
+
when /Manufacturer: Microsoft/
|
69
|
+
found_virt_manufacturer = "microsoft"
|
70
|
+
when /Product Name: Virtual Machine/
|
71
|
+
found_virt_product = "microsoft"
|
72
|
+
when /Version: 5.0/
|
73
|
+
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
74
|
+
virtualization[:system] = "virtualpc"
|
75
|
+
virtualization[:role] = "guest"
|
76
|
+
end
|
77
|
+
when /Version: VS2005R2/
|
78
|
+
if found_virt_manufacturer == "microsoft" && found_virt_product == "microsoft"
|
79
|
+
virtualization[:system] = "virtualserver"
|
80
|
+
virtualization[:role] = "guest"
|
81
|
+
end
|
82
|
+
when /Manufacturer: VMware/
|
83
|
+
found_virt_manufacturer = "vmware"
|
84
|
+
when /Product Name: VMware Virtual Platform/
|
85
|
+
if found_virt_manufacturer == "vmware"
|
86
|
+
virtualization[:system] = "vmware"
|
87
|
+
virtualization[:role] = "guest"
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kurchatov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7.pre.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vasiliev Dmitry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: beefcake
|
@@ -166,7 +166,6 @@ files:
|
|
166
166
|
- lib/kurchatov/plugin/riemann.rb
|
167
167
|
- lib/kurchatov/queue.rb
|
168
168
|
- lib/kurchatov/responders/http.rb
|
169
|
-
- lib/kurchatov/responders/init.rb
|
170
169
|
- lib/kurchatov/responders/riemann.rb
|
171
170
|
- lib/kurchatov/responders/udp.rb
|
172
171
|
- lib/kurchatov/riemann/client.rb
|
@@ -176,6 +175,10 @@ files:
|
|
176
175
|
- lib/ohai/plugins/darwin/cpu.rb
|
177
176
|
- lib/ohai/plugins/darwin/hostname.rb
|
178
177
|
- lib/ohai/plugins/darwin/platform.rb
|
178
|
+
- lib/ohai/plugins/freebsd/cpu.rb
|
179
|
+
- lib/ohai/plugins/freebsd/hostname.rb
|
180
|
+
- lib/ohai/plugins/freebsd/platform.rb
|
181
|
+
- lib/ohai/plugins/freebsd/virtualization.rb
|
179
182
|
- lib/ohai/plugins/hostname.rb
|
180
183
|
- lib/ohai/plugins/linux/cpu.rb
|
181
184
|
- lib/ohai/plugins/linux/hostname.rb
|
@@ -208,9 +211,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
211
|
version: '0'
|
209
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
213
|
requirements:
|
211
|
-
- - '
|
214
|
+
- - '>'
|
212
215
|
- !ruby/object:Gem::Version
|
213
|
-
version:
|
216
|
+
version: 1.3.1
|
214
217
|
requirements: []
|
215
218
|
rubyforge_project:
|
216
219
|
rubygems_version: 2.0.3
|