sensu-plugins-edgelab 1.8.2 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. metadata +1 -17
  3. data/bin/metrics-mysql-processes.rb +0 -132
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23b5d03c3ae962090927d753366931efbcc2d5f9
4
- data.tar.gz: 350b9cc9a9e386712cc440077db5ddc1f8aa5b07
3
+ metadata.gz: c9e92924cd81db3d31cf53390c03a1fb43baf159
4
+ data.tar.gz: 3a73bbdcf0f345e6d4a4aeca49b9993519d53284
5
5
  SHA512:
6
- metadata.gz: ccd604183a08f436b98b593e0454e1fb1720b4886cae9b02e31db31d8b9b74b26daf3c6c7c48b120a6d1a4a08297dec058a9a2f333e1f044dd1745ee5ea5c933
7
- data.tar.gz: 1f235092d9a9f9b3f58f83d1bf5796c32cd900f9a478582ac4bd300c92be57223794e84c0c7d90874a37cca5d52ed0f5a10962ffb06b34b732d5ea5e6e7b7d8e
6
+ metadata.gz: 1c42851612e95f363cb601a59e0c83eb84a857eda418686cce0c1c78164a85eed311c08819e3e005315a20f387354ee78e64ad8b1d296bd52d4b094d4e03b767
7
+ data.tar.gz: c341c07c2eafa55e0f481843cdd3057f97a9d3f2bab3d92a74faca4acaf591ab78481c99a279406fa66ae4caa437f97180128aff4b395946fd8f40d81811f839
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-edgelab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgelab
@@ -66,20 +66,6 @@ dependencies:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.8.0
69
- - !ruby/object:Gem::Dependency
70
- name: ruby-mysql
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '2.9'
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: '2.9'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: redis
85
71
  requirement: !ruby/object:Gem::Requirement
@@ -161,7 +147,6 @@ executables:
161
147
  - check-swarm-cluster.rb
162
148
  - metrics-aws-rds.rb
163
149
  - metrics-aws-asg.rb
164
- - metrics-mysql-processes.rb
165
150
  - check-consul-services.rb
166
151
  - check-nomad-leader.rb
167
152
  - check-nomad-jobs.rb
@@ -177,7 +162,6 @@ files:
177
162
  - bin/metrics-aws-elb.rb
178
163
  - bin/metrics-aws-rds.rb
179
164
  - bin/metrics-es-indices.rb
180
- - bin/metrics-mysql-processes.rb
181
165
  - bin/metrics-redis-key-pattern.rb
182
166
  - bin/metrics-swarm-cluster.rb
183
167
  homepage:
@@ -1,132 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- # metrics-mysql-processes
4
- #
5
- # DESCRIPTION:
6
- # Gets metrics out of of MySQL's "SHOW PROCESSLIST" query.
7
- #
8
- # Output number of connections per-users, number of connections
9
- # per-databases, number of the different commands running.
10
- #
11
- # OUTPUT:
12
- # metric-data
13
- #
14
- # PLATFORMS:
15
- # Linux, Windows, BSD, Solaris, etc
16
- #
17
- # DEPENDENCIES:
18
- # gem: sensu-plugin
19
- # gem: mysql
20
- #
21
- # USAGE:
22
- # This was implemented to load mysql credentials without parsing the username/password.
23
- # The ini file should be readable by the sensu user/group.
24
- # Ref: http://eric.lubow.org/2009/ruby/parsing-ini-files-with-ruby/
25
- #
26
- # EXAMPLE
27
- # mysql-alive.rb -h db01 --ini '/etc/sensu/my.cnf'
28
- #
29
- # MY.CNF INI FORMAT
30
- # [client]
31
- # user=sensu
32
- # password="abcd1234"
33
- #
34
- # NOTES:
35
- #
36
- # LICENSE:
37
- # Jonathan Ballet <jballet@edgelab.ch>
38
- # Released under the same terms as Sensu (the MIT license); see LICENSE
39
- # for details.
40
-
41
- require 'sensu-plugin/metric/cli'
42
- require 'mysql'
43
- require 'socket'
44
- require 'inifile'
45
-
46
- class MetricsMySQLProcesses < Sensu::Plugin::Metric::CLI::Graphite
47
- option :host,
48
- short: '-h HOST',
49
- long: '--host HOST',
50
- description: 'MySQL Host to connect to',
51
- required: true
52
-
53
- option :port,
54
- short: '-P PORT',
55
- long: '--port PORT',
56
- description: 'MySQL Port to connect to',
57
- proc: proc(&:to_i),
58
- default: 3306
59
-
60
- option :username,
61
- short: '-u USERNAME',
62
- long: '--user USERNAME',
63
- description: 'MySQL Username'
64
-
65
- option :password,
66
- short: '-p PASSWORD',
67
- long: '--pass PASSWORD',
68
- description: 'MySQL password',
69
- default: ''
70
-
71
- option :ini,
72
- short: '-i',
73
- long: '--ini VALUE',
74
- description: 'My.cnf ini file'
75
-
76
- option :scheme,
77
- description: 'Metric naming scheme, text to prepend to metric',
78
- short: '-s SCHEME',
79
- long: '--scheme SCHEME',
80
- default: "#{Socket.gethostname}.mysql"
81
-
82
- option :socket,
83
- short: '-S SOCKET',
84
- long: '--socket SOCKET',
85
- description: 'MySQL Unix socket to connect to'
86
-
87
- def run
88
- config[:host].split(' ').each do |mysql_host|
89
- mysql_shorthostname = mysql_host.split('.')[0]
90
- if config[:ini]
91
- ini = IniFile.load(config[:ini])
92
- section = ini['client']
93
- db_user = section['user']
94
- db_pass = section['password']
95
- else
96
- db_user = config[:username]
97
- db_pass = config[:password]
98
- end
99
- begin
100
- mysql = Mysql.new(mysql_host, db_user, db_pass, nil, config[:port], config[:socket])
101
-
102
- results = mysql.query('SHOW PROCESSLIST')
103
- rescue => e
104
- unknown "Unable to query MySQL: #{e.message}"
105
- end
106
-
107
- metrics = {
108
- 'user' => {},
109
- 'database' => {},
110
- 'command' => {}
111
- }
112
-
113
- metrics.each_value { |value| value.default = 0 }
114
-
115
- results.each_hash do |row|
116
- metrics['user'][row['User']] += 1
117
- if row['db'] # If no database has been selected by the process, it is set to nil.
118
- metrics['database'][row['db']] += 1
119
- end
120
- metrics['command'][row['Command']] += 1
121
- end
122
-
123
- metrics.each do |key, value|
124
- value.each do |instance, count|
125
- output "#{config[:scheme]}.#{mysql_shorthostname}.#{key}.#{instance}", count
126
- end
127
- end
128
- end
129
-
130
- ok
131
- end
132
- end