sensu-plugins-mysql 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4af0df514e24dc11d4e69d12c66947a196248d02
4
- data.tar.gz: 47b20d16ac0a763a24ed85a57530f1b69ae6e824
3
+ metadata.gz: 481c23c6d191fbb357eb02f3dbb577b59d662592
4
+ data.tar.gz: 2f21d675e9dee317be43c6130204796625bf2552
5
5
  SHA512:
6
- metadata.gz: d38e71b0fbfc6616c81fd68894b8f3322871c1c71937150f4780b1bce49d3ab7023bbfcfbf732e83281da5a027835234c6b5cb19fe33fb380be2a1cfde079199
7
- data.tar.gz: 56f8f70caede904ae42435cf05576edc90960ed6e252a928f808f66fcd9d30b456ebc2970297ae1ee1f007d59de3b8be390219d3609645dc3f045a4543d948ad
6
+ metadata.gz: c16f46e42b91517cb01c49420353f51f3dfa8036de139dfabe34e31c3afc77b2f03058142ed465a25d6f0af90aa737f367d88f5b2dce9ca84d1ec9c2fb7ee4c7
7
+ data.tar.gz: f03353f1dd829e06b72f649c3da30d197bac17e14891e5c43cb7ad9966d537216da8bd004438ba12616def3c843c9d7da7ceb796c37ef2579944802504a3298a
data/CHANGELOG.md CHANGED
@@ -3,8 +3,20 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
- ## [Unreleased][unreleased]
7
- - nothing
6
+ ## [Unreleased]
7
+
8
+ ## [1.0.0] - 2016-08-15
9
+ ### Added
10
+ - added check-mysql-threads.rb script
11
+ - changed metrics-mysql-graphite.rb to use mysql / ruby-mysql gem
12
+
13
+ ### Changed
14
+ - Removed compatibility with Ruby 1.9
15
+ - Updated sensu-plugin dependency from `= 1.2.0` to `~> 1.2`
16
+ - removed --help option as it comes from opt parser
17
+
18
+ ### Removed
19
+ - check-cloudwatch-mysql-sensu.rb - sensu-plugins-aws check-cloudwatch-metric.rb should be used
8
20
 
9
21
  ## [0.0.4] - 2015-08-04
10
22
  ### Changed
@@ -18,14 +30,18 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
18
30
  - ability to read configuration data from an ini file
19
31
 
20
32
  ## [0.0.2] - 2015-06-03
21
-
22
33
  ### Fixed
23
34
  - added binstubs
24
35
 
25
36
  ### Changed
26
37
  - removed cruft from /lib
27
38
 
28
- ##[0.0.1] - 2015-05-29
29
-
39
+ ## 0.0.1 - 2015-05-29
30
40
  ### Added
31
41
  - initial release
42
+
43
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/1.0.0...HEAD
44
+ [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/0.0.4...1.0.0
45
+ [0.0.4]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/0.0.3...0.0.4
46
+ [0.0.3]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/0.0.2...0.0.3
47
+ [0.0.2]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/0.0.1...0.0.2
data/README.md CHANGED
@@ -5,7 +5,6 @@
5
5
  [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-mysql/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-mysql)
6
6
  [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-mysql/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-mysql)
7
7
  [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-mysql.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-mysql)
8
- [![Codeship Status for sensu-plugins/sensu-plugins-mysql](https://codeship.com/projects/266116c0-e896-0132-af9a-62885e5c211b/status?branch=master)](https://codeship.com/projects/82837)
9
8
 
10
9
  ## Functionality
11
10
 
@@ -15,6 +14,7 @@
15
14
  * bin/check-mysql-connections.rb
16
15
  * bin/check-mysql-disk.rb
17
16
  * bin/check-mysql-innodb-lock.rb
17
+ * bin/check-mysql-threads.rb
18
18
  * bin/metrics-mysql-graphite.rb
19
19
  * bin/metrics-mysql.rb
20
20
  * bin/mysql-metrics.sql
@@ -32,8 +32,38 @@
32
32
  }
33
33
  ```
34
34
 
35
+ **metrics-mysql-graphite** example:
36
+ ```bash
37
+ /opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby metrics-mysql-graphite.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock
38
+ ```
39
+
40
+ **check-mysql-connections** example
41
+ ```bash
42
+ /opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby check-mysql-connections.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock
43
+ ```
44
+
35
45
  ## Installation
36
46
 
37
47
  [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
38
48
 
39
49
  ## Notes
50
+ The ruby executables are install in path similar to `/opt/sensu/embedded/lib/ruby/gems/2.0.0/gems/sensu-plugins-mysql-0.0.4/bin`
51
+
52
+ ## Troubleshooting
53
+ When used in `chef`, if the dependencies are missing, an error may abort the chef-client run:
54
+ ```bash
55
+ *** extconf.rb failed ***
56
+ Could not create Makefile due to some reason, probably lack of
57
+ necessary libraries and/or headers. Check the mkmf.log file for more
58
+ details. You may need configuration options.
59
+ ```
60
+ This may be fixed by installing the mysql client library before the plugin:
61
+ ```ruby
62
+ # http://serverfault.com/questions/415392/install-mysql-gem-for-use-in-chef-client
63
+ package "libmysqlclient-dev" do
64
+ action :install
65
+ end
66
+
67
+ sensu_gem 'sensu-plugins-mysql' do version '0.0.4' end
68
+
69
+ ```
@@ -1,4 +1,4 @@
1
- # !/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  #
3
3
  # MySQL Alive Plugin
4
4
  # ===
@@ -1,4 +1,4 @@
1
- # !/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  #
3
3
  # MySQL Health Plugin
4
4
  # ===
@@ -91,15 +91,15 @@ class CheckMySQLHealth < Sensu::Plugin::Check::CLI
91
91
  pc = used_con.fdiv(max_con) * 100
92
92
  critical "Max connections reached in MySQL: #{used_con} out of #{max_con}" if pc >= config[:maxcrit].to_i
93
93
  warning "Max connections reached in MySQL: #{used_con} out of #{max_con}" if pc >= config[:maxwarn].to_i
94
- ok "Max connections is under limit in MySQL: #{used_con} out of #{max_con}"
94
+ ok "Max connections is under limit in MySQL: #{used_con} out of #{max_con}" # rubocop:disable Style/IdenticalConditionalBranches
95
95
  else
96
96
  critical "Max connections reached in MySQL: #{used_con} out of #{max_con}" if used_con >= config[:maxcrit].to_i
97
97
  warning "Max connections reached in MySQL: #{used_con} out of #{max_con}" if used_con >= config[:maxwarn].to_i
98
- ok "Max connections is under limit in MySQL: #{used_con} out of #{max_con}"
98
+ ok "Max connections is under limit in MySQL: #{used_con} out of #{max_con}" # rubocop:disable Style/IdenticalConditionalBranches
99
99
  end
100
- rescue Mysql::Error => e
101
- critical "MySQL check failed: #{e.error}"
102
- ensure
103
- db.close if db
100
+ rescue Mysql::Error => e
101
+ critical "MySQL check failed: #{e.error}"
102
+ ensure
103
+ db.close if db
104
104
  end
105
105
  end
@@ -1,4 +1,4 @@
1
- # !/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  #
3
3
  # MySQL Disk Usage Check
4
4
  # ===
@@ -52,15 +52,6 @@ class CheckMysqlDisk < Sensu::Plugin::Check::CLI
52
52
  description: 'Critical threshold',
53
53
  default: '95'
54
54
 
55
- option :help,
56
- short: '-h',
57
- long: '--help',
58
- description: 'Check RDS disk usage',
59
- on: :tail,
60
- boolean: true,
61
- show_options: true,
62
- exit: 0
63
-
64
55
  def run
65
56
  if config[:ini]
66
57
  ini = IniFile.load(config[:ini])
@@ -1,4 +1,4 @@
1
- # !/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  #
3
3
  # MySQL InnoDB Lock Check Plugin
4
4
  # ===
@@ -128,7 +128,7 @@ class CheckMySQLInnoDBLock < Sensu::Plugin::Check::CLI
128
128
  lock_info.push(h)
129
129
  end
130
130
 
131
- if lock_info.length == 0
131
+ if lock_info.length == 0 # rubocop:disable Style/ZeroLengthPredicate
132
132
  ok
133
133
  elsif is_crit == false
134
134
  warning "Detected Locks #{lock_info}"
@@ -1,4 +1,4 @@
1
- # !/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  #
3
3
  # MySQL Replication Status (modded from disk)
4
4
  # ===
@@ -67,7 +67,7 @@ class CheckMysqlReplicationStatus < Sensu::Plugin::Check::CLI
67
67
  description: 'Warning threshold for replication lag',
68
68
  default: 900,
69
69
  # #YELLOW
70
- proc: lambda { |s| s.to_i } # rubocop:disable Lambda
70
+ proc: lambda { |s| s.to_i } # rubocop:disable Lambda
71
71
 
72
72
  option :crit,
73
73
  short: '-c',
@@ -75,16 +75,7 @@ class CheckMysqlReplicationStatus < Sensu::Plugin::Check::CLI
75
75
  description: 'Critical threshold for replication lag',
76
76
  default: 1800,
77
77
  # #YELLOW
78
- proc: lambda { |s| s.to_i } # rubocop:disable Lambda
79
-
80
- option :help,
81
- short: '-h',
82
- long: '--help',
83
- description: 'Check MySQL replication status',
84
- on: :tail,
85
- boolean: true,
86
- show_options: true,
87
- exit: 0
78
+ proc: lambda { |s| s.to_i } # rubocop:disable Lambda
88
79
 
89
80
  def run
90
81
  if config[:ini]
@@ -0,0 +1,99 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # check-mysql-threads.rb
4
+ #
5
+ # DESCRIPTION:
6
+ # MySQL Threads Health plugin
7
+ # This plugin evaluates the number of MySQL running threads and warns you according to specified limits
8
+ #
9
+ # OUTPUT:
10
+ # plain text
11
+ #
12
+ # PLATFORMS:
13
+ # All
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ #
18
+ # USAGE:
19
+ # check-mysql-threads.rb -w [threshold] -c [threshold]
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Author: Guillaume Lefranc <guillaume@mariadb.com>
25
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
26
+ # for details.
27
+ #
28
+
29
+ require 'sensu-plugin/check/cli'
30
+ require 'mysql'
31
+ require 'inifile'
32
+
33
+ class CheckMySQLHealth < Sensu::Plugin::Check::CLI
34
+ option :user,
35
+ description: 'MySQL User',
36
+ short: '-u USER',
37
+ long: '--user USER',
38
+ default: 'root'
39
+
40
+ option :password,
41
+ description: 'MySQL Password',
42
+ short: '-p PASS',
43
+ long: '--password PASS'
44
+
45
+ option :ini,
46
+ description: 'My.cnf ini file',
47
+ short: '-i',
48
+ long: '--ini VALUE'
49
+
50
+ option :hostname,
51
+ description: 'Hostname to login to',
52
+ short: '-h HOST',
53
+ long: '--hostname HOST',
54
+ default: 'localhost'
55
+
56
+ option :port,
57
+ description: 'Port to connect to',
58
+ short: '-P PORT',
59
+ long: '--port PORT',
60
+ default: '3306'
61
+
62
+ option :socket,
63
+ description: 'Socket to use',
64
+ short: '-s SOCKET',
65
+ long: '--socket SOCKET'
66
+
67
+ option :maxwarn,
68
+ description: "Number of running threads upon which we'll issue a warning",
69
+ short: '-w NUMBER',
70
+ long: '--warnnum NUMBER',
71
+ default: 20
72
+
73
+ option :maxcrit,
74
+ description: "Number of running threads upon which we'll issue an alert",
75
+ short: '-c NUMBER',
76
+ long: '--critnum NUMBER',
77
+ default: 25
78
+
79
+ def run
80
+ if config[:ini]
81
+ ini = IniFile.load(config[:ini])
82
+ section = ini['client']
83
+ db_user = section['user']
84
+ db_pass = section['password']
85
+ else
86
+ db_user = config[:user]
87
+ db_pass = config[:password]
88
+ end
89
+ db = Mysql.real_connect(config[:hostname], db_user, db_pass, config[:database], config[:port].to_i, config[:socket])
90
+ run_thr = db.query("SHOW GLOBAL STATUS LIKE 'Threads_running'").fetch_hash.fetch('Value').to_i
91
+ critical "MySQL currently running threads: #{run_thr}" if run_thr >= config[:maxcrit].to_i
92
+ warning "MySQL currently running threads: #{run_thr}" if run_thr >= config[:maxwarn].to_i
93
+ ok "Currently running threads are under limit in MySQL: #{run_thr}"
94
+ rescue Mysql::Error => e
95
+ critical "MySQL check failed: #{e.error}"
96
+ ensure
97
+ db.close if db
98
+ end
99
+ end
@@ -1,4 +1,4 @@
1
- # !/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
2
  #
3
3
  # Push mysql stats into graphite
4
4
  # ===
@@ -31,11 +31,11 @@
31
31
  #
32
32
 
33
33
  require 'sensu-plugin/metric/cli'
34
- require 'mysql2'
34
+ require 'mysql'
35
35
  require 'socket'
36
36
  require 'inifile'
37
37
 
38
- class Mysql2Graphite < Sensu::Plugin::Metric::CLI::Graphite
38
+ class MysqlGraphite < Sensu::Plugin::Metric::CLI::Graphite
39
39
  option :host,
40
40
  short: '-h HOST',
41
41
  long: '--host HOST',
@@ -188,6 +188,7 @@ class Mysql2Graphite < Sensu::Plugin::Metric::CLI::Graphite
188
188
  'Innodb_rows_inserted' => 'rowsInserted'
189
189
  },
190
190
  'configuration' => {
191
+ 'max_connections' => 'MaxConnections',
191
192
  'Max_prepared_stmt_count' => 'MaxPreparedStmtCount'
192
193
  }
193
194
  }
@@ -204,20 +205,14 @@ class Mysql2Graphite < Sensu::Plugin::Metric::CLI::Graphite
204
205
  db_pass = config[:password]
205
206
  end
206
207
  begin
207
- mysql = Mysql2::Client.new(
208
- host: mysql_host,
209
- port: config[:port],
210
- username: db_user,
211
- password: db_pass,
212
- socket: config[:socket]
213
- )
208
+ mysql = Mysql.new(mysql_host, db_user, db_pass, nil, config[:port], config[:socket])
214
209
 
215
210
  results = mysql.query('SHOW GLOBAL STATUS')
216
211
  rescue => e
217
212
  puts e.message
218
213
  end
219
214
 
220
- results.each do |row|
215
+ results.each_hash do |row|
221
216
  metrics.each do |category, var_mapping|
222
217
  if var_mapping.key?(row['Variable_name'])
223
218
  output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.#{var_mapping[row['Variable_name']]}", row['Value']
@@ -229,7 +224,7 @@ class Mysql2Graphite < Sensu::Plugin::Metric::CLI::Graphite
229
224
  slave_results = mysql.query('SHOW SLAVE STATUS')
230
225
  # should return a single element array containing one hash
231
226
  # #YELLOW
232
- slave_results.first.each do |key, value| # rubocop:disable Style/Next
227
+ slave_results.fetch_hash.each_pair do |key, value|
233
228
  if metrics['general'].include?(key)
234
229
  # Replication lag being null is bad, very bad, so negativate it here
235
230
  value = -1 if key == 'Seconds_Behind_Master' && value.nil?
@@ -244,7 +239,7 @@ class Mysql2Graphite < Sensu::Plugin::Metric::CLI::Graphite
244
239
  variables_results = mysql.query('SHOW GLOBAL VARIABLES')
245
240
 
246
241
  category = 'configuration'
247
- variables_results.each do |row|
242
+ variables_results.each_hash do |row|
248
243
  metrics[category].each do |metric, desc|
249
244
  if metric.casecmp(row['Variable_name']) == 0
250
245
  output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.#{desc}", row['Value']
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsMySql
2
2
  module Version
3
- MAJOR = 0
3
+ MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 4
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,51 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
14
- am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
15
- A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
16
- CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
17
- LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
18
- CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
19
- zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
20
- qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
21
- k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
22
- oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
23
- 0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
24
- HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
25
- QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
26
- MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
27
- rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
28
- UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
29
- JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
30
- 8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
- HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
- -----END CERTIFICATE-----
33
- date: 2015-08-05 00:00:00.000000000 Z
10
+ cert_chain: []
11
+ date: 2016-08-16 00:00:00.000000000 Z
34
12
  dependencies:
35
- - !ruby/object:Gem::Dependency
36
- name: aws
37
- requirement: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - '='
40
- - !ruby/object:Gem::Version
41
- version: 2.10.2
42
- type: :runtime
43
- prerelease: false
44
- version_requirements: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - '='
47
- - !ruby/object:Gem::Version
48
- version: 2.10.2
49
13
  - !ruby/object:Gem::Dependency
50
14
  name: inifile
51
15
  requirement: !ruby/object:Gem::Requirement
@@ -61,47 +25,33 @@ dependencies:
61
25
  - !ruby/object:Gem::Version
62
26
  version: 3.0.0
63
27
  - !ruby/object:Gem::Dependency
64
- name: mysql
28
+ name: ruby-mysql
65
29
  requirement: !ruby/object:Gem::Requirement
66
30
  requirements:
67
- - - '='
68
- - !ruby/object:Gem::Version
69
- version: 2.9.1
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - '='
75
- - !ruby/object:Gem::Version
76
- version: 2.9.1
77
- - !ruby/object:Gem::Dependency
78
- name: mysql2
79
- requirement: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - '='
31
+ - - "~>"
82
32
  - !ruby/object:Gem::Version
83
- version: 0.3.18
33
+ version: '2.9'
84
34
  type: :runtime
85
35
  prerelease: false
86
36
  version_requirements: !ruby/object:Gem::Requirement
87
37
  requirements:
88
- - - '='
38
+ - - "~>"
89
39
  - !ruby/object:Gem::Version
90
- version: 0.3.18
40
+ version: '2.9'
91
41
  - !ruby/object:Gem::Dependency
92
42
  name: sensu-plugin
93
43
  requirement: !ruby/object:Gem::Requirement
94
44
  requirements:
95
- - - '='
45
+ - - "~>"
96
46
  - !ruby/object:Gem::Version
97
- version: 1.2.0
47
+ version: '1.2'
98
48
  type: :runtime
99
49
  prerelease: false
100
50
  version_requirements: !ruby/object:Gem::Requirement
101
51
  requirements:
102
- - - '='
52
+ - - "~>"
103
53
  - !ruby/object:Gem::Version
104
- version: 1.2.0
54
+ version: '1.2'
105
55
  - !ruby/object:Gem::Dependency
106
56
  name: codeclimate-test-reporter
107
57
  requirement: !ruby/object:Gem::Requirement
@@ -204,16 +154,16 @@ dependencies:
204
154
  name: rubocop
205
155
  requirement: !ruby/object:Gem::Requirement
206
156
  requirements:
207
- - - '='
157
+ - - "~>"
208
158
  - !ruby/object:Gem::Version
209
- version: 0.32.1
159
+ version: 0.40.0
210
160
  type: :development
211
161
  prerelease: false
212
162
  version_requirements: !ruby/object:Gem::Requirement
213
163
  requirements:
214
- - - '='
164
+ - - "~>"
215
165
  - !ruby/object:Gem::Version
216
- version: 0.32.1
166
+ version: 0.40.0
217
167
  - !ruby/object:Gem::Dependency
218
168
  name: yard
219
169
  requirement: !ruby/object:Gem::Requirement
@@ -236,27 +186,26 @@ description: |-
236
186
  sending metrics to a MySQL database.
237
187
  email: "<sensu-users@googlegroups.com>"
238
188
  executables:
239
- - mysql-metrics.sql
240
- - metrics-mysql.rb
241
- - metrics-mysql-graphite.rb
242
- - check-mysql-replication-status.rb
243
- - check-mysql-innodb-lock.rb
244
- - check-mysql-disk.rb
245
- - check-mysql-connections.rb
246
189
  - check-mysql-alive.rb
247
- - check-cloudwatch-mysql-sensu.rb
190
+ - check-mysql-connections.rb
191
+ - check-mysql-disk.rb
192
+ - check-mysql-innodb-lock.rb
193
+ - check-mysql-replication-status.rb
194
+ - check-mysql-threads.rb
195
+ - metrics-mysql-graphite.rb
196
+ - metrics-mysql.rb
248
197
  extensions: []
249
198
  extra_rdoc_files: []
250
199
  files:
251
200
  - CHANGELOG.md
252
201
  - LICENSE
253
202
  - README.md
254
- - bin/check-cloudwatch-mysql-sensu.rb
255
203
  - bin/check-mysql-alive.rb
256
204
  - bin/check-mysql-connections.rb
257
205
  - bin/check-mysql-disk.rb
258
206
  - bin/check-mysql-innodb-lock.rb
259
207
  - bin/check-mysql-replication-status.rb
208
+ - bin/check-mysql-threads.rb
260
209
  - bin/metrics-mysql-graphite.rb
261
210
  - bin/metrics-mysql.rb
262
211
  - bin/mysql-metrics.sql
@@ -280,7 +229,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
280
229
  requirements:
281
230
  - - ">="
282
231
  - !ruby/object:Gem::Version
283
- version: 1.9.3
232
+ version: 2.0.0
284
233
  required_rubygems_version: !ruby/object:Gem::Requirement
285
234
  requirements:
286
235
  - - ">="
@@ -288,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
288
237
  version: '0'
289
238
  requirements: []
290
239
  rubyforge_project:
291
- rubygems_version: 2.4.8
240
+ rubygems_version: 2.5.1
292
241
  signing_key:
293
242
  specification_version: 4
294
243
  summary: Sensu plugins for MySql
checksums.yaml.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- U�k�өn��AG��+N�����R
2
- �sإ�Q�0���Wk*����k�HE
data.tar.gz.sig DELETED
@@ -1 +0,0 @@
1
- ��������.հ�� �,�h�e��{���^��j� x]���N���w�˴�b<� &�d0�o��kb��ao� � Vfu0��0�8Pv�E��@�#4��9�@C�Ѯ���� �"u7�Qe!h1�k��ՈY~:���/�Z�j�cC�j�|Vhk�ghc�3�BC��Q� �P�˓k�r.F�����#�J��<Geb-�[*�V�9����qa*bL�N8arhӥ�k�+M]p��'�M�t6��G*퓆�7�
@@ -1,157 +0,0 @@
1
- #! /usr/bin/env ruby
2
- #
3
- # <script name>
4
- #
5
- # DESCRIPTION:
6
- # what is this thing supposed to do, monitor? How do alerts or
7
- # alarms work?
8
- #
9
- # OUTPUT:
10
- # plain text, metric data, etc
11
- #
12
- # PLATFORMS:
13
- # Linux, Windows, BSD, Solaris, etc
14
- #
15
- # DEPENDENCIES:
16
- # gem: sensu-plugin
17
- # gem: aws
18
- #
19
- # USAGE:
20
- # example commands
21
- #
22
- # NOTES:
23
- # Does it behave differently on specific platforms, specific use cases, etc
24
- #
25
- # LICENSE:
26
- # <your name> <your email>
27
- # Released under the same terms as Sensu (the MIT license); see LICENSE
28
- # for details.
29
- #
30
-
31
- # !/usr/bin/env ruby
32
- #
33
- # Amazon RDS cloudwatch sensu plugin
34
- # ===
35
- #
36
- # Dependencies
37
- # -----------
38
- # - http://docs.aws.amazon.com/AmazonRDS/latest/CommandLineReference/StartCLI.html
39
- #
40
- #
41
- # Authors: Micah Hoffmann <https://github.com/SeattleMicah> Kristopher Zentner <https://github.com/kaezi>
42
- #
43
- #
44
- # Released under the same terms as Sensu (the MIT license); see LICENSE
45
- # for details.
46
-
47
- require 'aws/cloud_watch'
48
- require 'optparse'
49
- require 'pp'
50
-
51
- aws_access_key_id = ''
52
- aws_secret_key = ''
53
- aws_region = ''
54
- aws_debug = false
55
-
56
- options = {}
57
- optparse = OptionParser.new do|opts|
58
- opts.on('-h', '--help', '') do
59
- puts opts
60
- exit
61
- end
62
-
63
- opts.on('-H', '--host HOST', 'Hostname') do |host|
64
- options[:host] = host
65
- end
66
-
67
- opts.on('-w', '--warn WARN', 'Warning threshold') do |warn|
68
- options[:warn] = warn
69
- end
70
-
71
- opts.on('-c', '--crit CRIT', 'Critical threshold') do |crit|
72
- options[:crit] = crit
73
- end
74
-
75
- opts.on('-s', '--stat STAT', 'Statistic') do|stat|
76
- options[:stat] = stat
77
- end
78
-
79
- opts.on('-l', '--lessthan', 'Threshold is less than') do|lessthan|
80
- options[:lessthan] = lessthan
81
- end
82
- end
83
- begin
84
- optparse.parse!
85
- mandatory = [:warn, :crit, :stat, :host] # Enforce the presence of
86
- missing = mandatory.select { |param| options[param].nil? } # the -t and -f switches
87
- unless missing.empty? #
88
- puts "Missing options: #{missing.join(', ')}" #
89
- puts optparse #
90
- exit #
91
- end #
92
- rescue OptionParser::InvalidOption, OptionParser::MissingArgument #
93
- puts $ERROR_INFO.to_s # Friendly output when parsing fails
94
- puts optparse #
95
- exit #
96
- end
97
-
98
- AWS.config(access_key_id: aws_access_key_id,
99
- secret_access_key: aws_secret_key,
100
- region: aws_region,
101
- http_wire_trace: aws_debug)
102
-
103
- metric = AWS::CloudWatch::Metric.new('AWS/RDS', "#{options[:stat]}",
104
- dimensions: [
105
- { name: 'DBInstanceIdentifier', value: "#{options[:host]}" }
106
- ])
107
- stats = metric.statistics(
108
- start_time: Time.now - 600,
109
- end_time: Time.now,
110
- statistics: ['Average'])
111
- latest = stats.first
112
- # puts "#{stats.metric.name}: #{latest[:average]} #{latest[:unit]}"
113
- # puts "#{options[:crit].to_f}"
114
- if latest.nil?
115
- msg = "WARNING: #{options[:host]} is not returning data! Is it deleted? Slave dead? "
116
- msg += 'It could possibly mean there is no data to return, but make sure host is alive!'
117
- puts msg
118
- exit 2
119
- end
120
-
121
- average = latest[:average]
122
- unit = latest[:unit]
123
-
124
- # Determine the unit for the average returned and convert if needed
125
- if unit == 'Bytes' && options[:stat] == 'FreeStorageSpace'
126
- average = (latest[:average] / 1_073_741_824).round(0)
127
- unit = 'GigaBytes'
128
- elsif unit == 'Bytes'
129
- average = (latest[:average] / 1_048_576).round(0)
130
- unit = 'MegaBytes'
131
- else
132
- average = latest[:average]
133
- end
134
-
135
- # Depending on if the stat is less than or greater than use the -l option
136
- if options[:lessthan] == true
137
- # Begin the check of the average and against the warn and crit parameters
138
- if average.to_f < options[:crit].to_f
139
- puts "CRITICAL: #{options[:host]} statistic #{options[:stat]} is at #{average} #{unit} which is below threshold #{options[:crit]} #{unit}"
140
- exit 1
141
- elsif average.to_f < options[:warn].to_f
142
- puts "WARNING: #{options[:host]} statistic #{options[:stat]} is at #{average} #{unit} which is below threshold #{options[:warn]} #{unit}"
143
- exit 2
144
- else
145
- puts "OK: #{options[:host]} statistic #{options[:stat]} is #{average} #{unit}"
146
- end
147
- else
148
- if average.to_f > options[:crit].to_f
149
- puts "CRITICAL: #{options[:host]} statistic #{options[:stat]} is at #{average} #{unit} which is above threshold #{options[:crit]} #{unit}"
150
- exit 1
151
- elsif average.to_f > options[:warn].to_f
152
- puts "WARNING: #{options[:host]} statistic #{options[:stat]} is at #{average} #{unit} which is above threshold #{options[:warn]} #{unit}"
153
- exit 2
154
- else
155
- puts "OK: #{options[:host]} statistic #{options[:stat]} is #{average} #{unit}"
156
- end
157
- end
metadata.gz.sig DELETED
@@ -1 +0,0 @@
1
- dL�4��/�a�4 z�צ=3cE��̈@�)���:���T����ٻ�,��w��J|�ʴ�d�;9�.���o�R|K�`��Q���I������nM�#+�����w���m� ������/��#���fK��>A��Kd� �=�9:Ng��lƒ��LX H�J��I��qc���=��;f6�s�>V��t��`��go��