onering-report-mysql 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,78 @@
|
|
1
|
+
if Facter::Util::Resolution.which('mysqld') or Facter::Util::Resolution.which('mysqld_safe')
|
2
|
+
mysql_servers = []
|
3
|
+
|
4
|
+
Dir['/proc/[0-9]*/cmdline'].select{|i| File.read(i).include?("mysqld\0") }.each do |proc|
|
5
|
+
command = File.read(proc).split("\0")
|
6
|
+
params = Hash[command[1..-1].collect{|i| i.gsub(/^--/,'').split('=',2) }]
|
7
|
+
config_file = nil
|
8
|
+
config = nil
|
9
|
+
|
10
|
+
%W{
|
11
|
+
#{params['defaults-file']}
|
12
|
+
/etc/my.cnf
|
13
|
+
/etc/mysql/my.cnf
|
14
|
+
}.each do |f|
|
15
|
+
next if f.empty?
|
16
|
+
|
17
|
+
if File.exists?(f)
|
18
|
+
config_file = f
|
19
|
+
|
20
|
+
stanza = nil
|
21
|
+
config = {}
|
22
|
+
|
23
|
+
# read config file
|
24
|
+
File.read(f).reject{|i| i.empty? or i =~ /^\s*#/ }.each do |line|
|
25
|
+
line = line.chomp.strip
|
26
|
+
if line[0].chr == '['
|
27
|
+
stanza = line[1..-2]
|
28
|
+
config[stanza] ||= {}
|
29
|
+
next
|
30
|
+
end
|
31
|
+
|
32
|
+
key, value = line.split(/\s*=\s*/,2)
|
33
|
+
config[stanza][key] = (value || true)
|
34
|
+
end
|
35
|
+
|
36
|
+
break
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
unless config_file.nil?
|
41
|
+
pid = proc.split('/')[2].to_i
|
42
|
+
|
43
|
+
server = {
|
44
|
+
:command => command.join(' '),
|
45
|
+
:pid => pid,
|
46
|
+
:params => params,
|
47
|
+
:configfile => config_file,
|
48
|
+
:config => config
|
49
|
+
}
|
50
|
+
|
51
|
+
# probe for the actual sockets used by this process
|
52
|
+
if Onering::Config.get('plugins.mysql.options.sockprobe', true) and pid > 0
|
53
|
+
IO.popen("netstat --numeric-hosts --numeric-ports --programs --tcp --unix -ee -l | grep '#{pid}/mysqld'").lines.each do |line|
|
54
|
+
line = line.chomp.strip.split(/\s+/)
|
55
|
+
|
56
|
+
case line.first
|
57
|
+
when 'tcp'
|
58
|
+
server[:port] = line[3].split(':').last.to_i rescue nil
|
59
|
+
when 'unix'
|
60
|
+
server[:socket] = line[-1] rescue nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
mysql_servers << server.compact
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
unless mysql_servers.empty?
|
70
|
+
Facter.add("mysql") do
|
71
|
+
setcode do
|
72
|
+
{
|
73
|
+
:servers => mysql_servers
|
74
|
+
}.compact
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: onering-report-mysql
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Gary Hetzel
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: onering-client
|
16
|
+
requirement: &19917300 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *19917300
|
25
|
+
description: Plugin for information about MySQL via the Onering client utility
|
26
|
+
email: ghetzel@outbrain.com
|
27
|
+
executables: []
|
28
|
+
extensions: []
|
29
|
+
extra_rdoc_files: []
|
30
|
+
files:
|
31
|
+
- lib/facter/onering_properties_mysql.rb
|
32
|
+
- lib/reporter/default/properties_mysql.rb
|
33
|
+
homepage: https://github.com/outbrain/onering-report-mysql
|
34
|
+
licenses: []
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 1.8.11
|
54
|
+
signing_key:
|
55
|
+
specification_version: 3
|
56
|
+
summary: MySQL plugin for Onering client
|
57
|
+
test_files: []
|