kurchatov 0.0.1

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.
Files changed (82) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +18 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +111 -0
  7. data/Rakefile +1 -0
  8. data/Vagrantfile +16 -0
  9. data/bin/kurchatov +6 -0
  10. data/examples/check_file_contains.rb +14 -0
  11. data/examples/count_proc.rb +14 -0
  12. data/examples/cpu.rb +29 -0
  13. data/examples/disk.rb +56 -0
  14. data/examples/disk_stat.rb +28 -0
  15. data/examples/dns_check.rb +5 -0
  16. data/examples/exim.rb +12 -0
  17. data/examples/file_age.rb +11 -0
  18. data/examples/find_files.rb +21 -0
  19. data/examples/http.rb +25 -0
  20. data/examples/iptables.rb +27 -0
  21. data/examples/la.rb +10 -0
  22. data/examples/mdadm.rb +43 -0
  23. data/examples/megacli.rb +12 -0
  24. data/examples/memory.rb +28 -0
  25. data/examples/net.rb +25 -0
  26. data/examples/net_stat.rb +25 -0
  27. data/examples/nfs.rb +9 -0
  28. data/examples/nginx.rb +22 -0
  29. data/examples/nginx_500.rb +48 -0
  30. data/examples/ntp.rb +15 -0
  31. data/examples/openfiles.rb +6 -0
  32. data/examples/pgsql.rb +67 -0
  33. data/examples/ping_icmp.rb +12 -0
  34. data/examples/ping_tcp.rb +14 -0
  35. data/examples/proc_mem.rb +24 -0
  36. data/examples/process_usage.rb +15 -0
  37. data/examples/rabbitmq.rb +16 -0
  38. data/examples/runit.rb +47 -0
  39. data/examples/sidekiq.rb +21 -0
  40. data/examples/sidekiq_queue_state.rb +9 -0
  41. data/examples/status_file.rb +14 -0
  42. data/examples/tw_cli.rb +17 -0
  43. data/examples/uptime.rb +14 -0
  44. data/kurchatov.gemspec +28 -0
  45. data/lib/kurchatov/application.rb +154 -0
  46. data/lib/kurchatov/config.rb +14 -0
  47. data/lib/kurchatov/log.rb +9 -0
  48. data/lib/kurchatov/mashie.rb +152 -0
  49. data/lib/kurchatov/mixin/command.rb +31 -0
  50. data/lib/kurchatov/mixin/event.rb +63 -0
  51. data/lib/kurchatov/mixin/http.rb +21 -0
  52. data/lib/kurchatov/mixin/init.rb +6 -0
  53. data/lib/kurchatov/mixin/ohai.rb +22 -0
  54. data/lib/kurchatov/mixin/queue.rb +14 -0
  55. data/lib/kurchatov/monitor.rb +62 -0
  56. data/lib/kurchatov/plugin/config.rb +68 -0
  57. data/lib/kurchatov/plugin/dsl.rb +81 -0
  58. data/lib/kurchatov/plugin/riemann.rb +54 -0
  59. data/lib/kurchatov/plugin.rb +15 -0
  60. data/lib/kurchatov/queue.rb +28 -0
  61. data/lib/kurchatov/responders/http.rb +36 -0
  62. data/lib/kurchatov/responders/init.rb +3 -0
  63. data/lib/kurchatov/responders/riemann.rb +46 -0
  64. data/lib/kurchatov/responders/udp.rb +32 -0
  65. data/lib/kurchatov/riemann/client.rb +49 -0
  66. data/lib/kurchatov/riemann/event.rb +42 -0
  67. data/lib/kurchatov/riemann/message.rb +18 -0
  68. data/lib/kurchatov/version.rb +3 -0
  69. data/lib/kurchatov.rb +3 -0
  70. data/lib/ohai/plugins/darwin/hostname.rb +22 -0
  71. data/lib/ohai/plugins/darwin/platform.rb +38 -0
  72. data/lib/ohai/plugins/hostname.rb +27 -0
  73. data/lib/ohai/plugins/linux/hostname.rb +26 -0
  74. data/lib/ohai/plugins/linux/platform.rb +113 -0
  75. data/lib/ohai/plugins/linux/virtualization.rb +125 -0
  76. data/lib/ohai/plugins/os.rb +53 -0
  77. data/lib/ohai/plugins/platform.rb +28 -0
  78. data/lib/ohai/plugins/virtualization.rb +86 -0
  79. data/lib/ohai/plugins/windows/hostname.rb +33 -0
  80. data/lib/ohai/plugins/windows/platform.rb +27 -0
  81. data/tests/run.sh +55 -0
  82. metadata +209 -0
@@ -0,0 +1,86 @@
1
+ #
2
+ # Author:: Benjamin Black (<bb@opscode.com>)
3
+ # Copyright:: Copyright (c) 2009 Opscode, Inc.
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
+ require_plugin "#{os}::virtualization"
22
+
23
+ unless virtualization.nil? || !(virtualization[:role].eql?("host"))
24
+ begin
25
+ require 'libvirt'
26
+ require 'hpricot'
27
+
28
+ emu = (virtualization[:system].eql?('kvm') ? 'qemu' : virtualization[:system])
29
+ virtualization[:libvirt_version] = Libvirt::version(emu)[0].to_s
30
+
31
+ virtconn = Libvirt::open_read_only("#{emu}:///system")
32
+
33
+ virtualization[:uri] = virtconn.uri
34
+ virtualization[:capabilities] = Mash.new
35
+ virtualization[:capabilities][:xml_desc] = (virtconn.capabilities.split("\n").collect {|line| line.strip}).join
36
+ #xdoc = Hpricot virtualization[:capabilities][:xml_desc]
37
+
38
+ virtualization[:nodeinfo] = Mash.new
39
+ ni = virtconn.node_get_info
40
+ ['cores','cpus','memory','mhz','model','nodes','sockets','threads'].each {|a| virtualization[:nodeinfo][a] = ni.send(a)}
41
+
42
+ virtualization[:domains] = Mash.new
43
+ virtconn.list_domains.each do |d|
44
+ dv = virtconn.lookup_domain_by_id d
45
+ virtualization[:domains][dv.name] = Mash.new
46
+ virtualization[:domains][dv.name][:id] = d
47
+ virtualization[:domains][dv.name][:xml_desc] = (dv.xml_desc.split("\n").collect {|line| line.strip}).join
48
+ ['os_type','uuid'].each {|a| virtualization[:domains][dv.name][a] = dv.send(a)}
49
+ ['cpu_time','max_mem','memory','nr_virt_cpu','state'].each {|a| virtualization[:domains][dv.name][a] = dv.info.send(a)}
50
+ #xdoc = Hpricot virtualization[:domains][dv.name][:xml_desc]
51
+
52
+ end
53
+
54
+ virtualization[:networks] = Mash.new
55
+ virtconn.list_networks.each do |n|
56
+ nv = virtconn.lookup_network_by_name n
57
+ virtualization[:networks][n] = Mash.new
58
+ virtualization[:networks][n][:xml_desc] = (nv.xml_desc.split("\n").collect {|line| line.strip}).join
59
+ ['bridge_name','uuid'].each {|a| virtualization[:networks][n][a] = nv.send(a)}
60
+ #xdoc = Hpricot virtualization[:networks][n][:xml_desc]
61
+
62
+ end
63
+
64
+ virtualization[:storage] = Mash.new
65
+ virtconn.list_storage_pools.each do |pool|
66
+ sp = virtconn.lookup_storage_pool_by_name pool
67
+ virtualization[:storage][pool] = Mash.new
68
+ virtualization[:storage][pool][:xml_desc] = (sp.xml_desc.split("\n").collect {|line| line.strip}).join
69
+ ['autostart','uuid'].each {|a| virtualization[:storage][pool][a] = sp.send(a)}
70
+ ['allocation','available','capacity','state'].each {|a| virtualization[:storage][pool][a] = sp.info.send(a)}
71
+ #xdoc = Hpricot virtualization[:storage][pool][:xml_desc]
72
+
73
+ virtualization[:storage][pool][:volumes] = Mash.new
74
+ sp.list_volumes.each do |v|
75
+ virtualization[:storage][pool][:volumes][v] = Mash.new
76
+ sv = sp.lookup_volume_by_name v
77
+ ['key','name','path'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.send(a)}
78
+ ['allocation','capacity','type'].each {|a| virtualization[:storage][pool][:volumes][v][a] = sv.info.send(a)}
79
+ end
80
+ end
81
+
82
+ virtconn.close
83
+ rescue LoadError => e
84
+ Ohai::Log.debug("Can't load gem: #{e}. virtualization plugin is disabled.")
85
+ end
86
+ end
@@ -0,0 +1,33 @@
1
+ #
2
+ # Author:: James Gartrell (<jgartrel@gmail.com>)
3
+ # Copyright:: Copyright (c) 2009 Opscode, Inc.
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
+ require 'ruby-wmi'
20
+ require 'socket'
21
+
22
+ host = WMI::Win32_ComputerSystem.find(:first)
23
+ hostname "#{host.Name}"
24
+
25
+ info = Socket.gethostbyname(Socket.gethostname)
26
+ if info.first =~ /.+?\.(.*)/
27
+ fqdn info.first
28
+ else
29
+ #host is not in dns. optionally use:
30
+ #C:\WINDOWS\system32\drivers\etc\hosts
31
+ fqdn Socket.gethostbyaddr(info.last).first
32
+ end
33
+
@@ -0,0 +1,27 @@
1
+ #
2
+ # Author:: James Gartrell (<jgartrel@gmail.com>)
3
+ # Copyright:: Copyright (c) 2009 Opscode, Inc.
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
+ # After long discussion in IRC the "powers that be" have come to a concensus
20
+ # that there is no other Windows platforms exist that were not based on the
21
+ # Windows_NT kernel, so we herby decree that "windows" will refer to all
22
+ # platforms built upon the Windows_NT kernel and have access to win32 or win64
23
+ # subsystems.
24
+ platform os
25
+ platform_version kernel['release']
26
+ platform_family "windows"
27
+
data/tests/run.sh ADDED
@@ -0,0 +1,55 @@
1
+ #!/bin/sh -e
2
+
3
+
4
+ nc -l 5555 &
5
+
6
+ rm -rf ./tmp
7
+ mkdir -p ./tmp
8
+ cat > tmp/config.yml <<EOF
9
+ test2:
10
+ url: './tests/run.sh'
11
+ cmd: 'ls'
12
+ parent: 'test'
13
+ counter: 5
14
+ test:
15
+ - url: 'http://google.com'
16
+ cmd: 'test -f ./tests/run.sh'
17
+ - url: 'https://www.kernel.org'
18
+ cmd: 'ps'
19
+ EOF
20
+
21
+ cat > tmp/test1.rb <<EOF
22
+ interval 10
23
+ name "test"
24
+
25
+ default[:host] = 'http://notexists'
26
+ default[:cmd] = 'ls -1 && ls /notexists'
27
+
28
+ collect do
29
+ @counter ||= 0
30
+ Log.info "file command #{plugin.cmd} return: #{shell(plugin.cmd)}"
31
+ Log.info "get size from #{plugin.url}: #{rest_get(plugin.url).size}"
32
+ @counter += 1
33
+ exit 0 if plugin.counter && @counter > plugin.counter.to_i
34
+ end
35
+ EOF
36
+
37
+ # --test-plugin
38
+ bundle exec ./bin/kurchatov --test-plugin ./tmp/test1.rb --logfile ./tmp/testplugin.log -l debug || echo "Mock error in 'ls /notexists'"
39
+ echo "Stdout --test-plugin:"
40
+ cat ./tmp/testplugin.log
41
+ grep -q 'STDERR: ls: cannot access /notexists' ./tmp/testplugin.log
42
+
43
+ # load config and helpers
44
+ bundle exec ./bin/kurchatov -d ./tmp/ -c ./tmp/config.yml --hosts 127.0.0.1 -l debug --stop-on-error --logfile ./tmp/loadplugins.log
45
+ echo "Stdout loader"
46
+ cat ./tmp/loadplugins.log
47
+ grep 'Plugins to start' ./tmp/loadplugins.log | grep -q '@name="test_0"'
48
+ grep 'Plugins to start' ./tmp/loadplugins.log | grep -q '@name="test_1"'
49
+ grep 'Plugins to start' ./tmp/loadplugins.log | grep -q '@name="test2"'
50
+ grep 'file command ls return: Gemfile' ./tmp/loadplugins.log
51
+ grep 'get size from http://google.com:' ./tmp/loadplugins.log
52
+ grep 'get size from https://www.kernel.org' ./tmp/loadplugins.log
53
+ grep 'get size from ./tests/run.sh' ./tmp/loadplugins.log
54
+
55
+ pkill -9 nc || exit 0
metadata ADDED
@@ -0,0 +1,209 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kurchatov
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vasiliev Dmitry
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: beefcake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.3.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.3.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: ohai
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 6.20.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 6.20.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: ruby-prof
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Gem for monitoring with riemann.
98
+ email:
99
+ - vadv.mkn@gmail.com
100
+ executables:
101
+ - kurchatov
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - .travis.yml
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - Vagrantfile
112
+ - bin/kurchatov
113
+ - examples/check_file_contains.rb
114
+ - examples/count_proc.rb
115
+ - examples/cpu.rb
116
+ - examples/disk.rb
117
+ - examples/disk_stat.rb
118
+ - examples/dns_check.rb
119
+ - examples/exim.rb
120
+ - examples/file_age.rb
121
+ - examples/find_files.rb
122
+ - examples/http.rb
123
+ - examples/iptables.rb
124
+ - examples/la.rb
125
+ - examples/mdadm.rb
126
+ - examples/megacli.rb
127
+ - examples/memory.rb
128
+ - examples/net.rb
129
+ - examples/net_stat.rb
130
+ - examples/nfs.rb
131
+ - examples/nginx.rb
132
+ - examples/nginx_500.rb
133
+ - examples/ntp.rb
134
+ - examples/openfiles.rb
135
+ - examples/pgsql.rb
136
+ - examples/ping_icmp.rb
137
+ - examples/ping_tcp.rb
138
+ - examples/proc_mem.rb
139
+ - examples/process_usage.rb
140
+ - examples/rabbitmq.rb
141
+ - examples/runit.rb
142
+ - examples/sidekiq.rb
143
+ - examples/sidekiq_queue_state.rb
144
+ - examples/status_file.rb
145
+ - examples/tw_cli.rb
146
+ - examples/uptime.rb
147
+ - kurchatov.gemspec
148
+ - lib/kurchatov.rb
149
+ - lib/kurchatov/application.rb
150
+ - lib/kurchatov/config.rb
151
+ - lib/kurchatov/log.rb
152
+ - lib/kurchatov/mashie.rb
153
+ - lib/kurchatov/mixin/command.rb
154
+ - lib/kurchatov/mixin/event.rb
155
+ - lib/kurchatov/mixin/http.rb
156
+ - lib/kurchatov/mixin/init.rb
157
+ - lib/kurchatov/mixin/ohai.rb
158
+ - lib/kurchatov/mixin/queue.rb
159
+ - lib/kurchatov/monitor.rb
160
+ - lib/kurchatov/plugin.rb
161
+ - lib/kurchatov/plugin/config.rb
162
+ - lib/kurchatov/plugin/dsl.rb
163
+ - lib/kurchatov/plugin/riemann.rb
164
+ - lib/kurchatov/queue.rb
165
+ - lib/kurchatov/responders/http.rb
166
+ - lib/kurchatov/responders/init.rb
167
+ - lib/kurchatov/responders/riemann.rb
168
+ - lib/kurchatov/responders/udp.rb
169
+ - lib/kurchatov/riemann/client.rb
170
+ - lib/kurchatov/riemann/event.rb
171
+ - lib/kurchatov/riemann/message.rb
172
+ - lib/kurchatov/version.rb
173
+ - lib/ohai/plugins/darwin/hostname.rb
174
+ - lib/ohai/plugins/darwin/platform.rb
175
+ - lib/ohai/plugins/hostname.rb
176
+ - lib/ohai/plugins/linux/hostname.rb
177
+ - lib/ohai/plugins/linux/platform.rb
178
+ - lib/ohai/plugins/linux/virtualization.rb
179
+ - lib/ohai/plugins/os.rb
180
+ - lib/ohai/plugins/platform.rb
181
+ - lib/ohai/plugins/virtualization.rb
182
+ - lib/ohai/plugins/windows/hostname.rb
183
+ - lib/ohai/plugins/windows/platform.rb
184
+ - tests/run.sh
185
+ homepage: https://github.com/vadv/kurchatov
186
+ licenses:
187
+ - MIT
188
+ metadata: {}
189
+ post_install_message:
190
+ rdoc_options: []
191
+ require_paths:
192
+ - lib
193
+ required_ruby_version: !ruby/object:Gem::Requirement
194
+ requirements:
195
+ - - '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ required_rubygems_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - '>='
201
+ - !ruby/object:Gem::Version
202
+ version: '0'
203
+ requirements: []
204
+ rubyforge_project:
205
+ rubygems_version: 2.0.3
206
+ signing_key:
207
+ specification_version: 4
208
+ summary: Gem for monitoring with riemann.
209
+ test_files: []