sensu-plugins-mysql 2.7.0 → 3.0.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/bin/check-mysql-disk.rb +3 -6
- data/bin/check-mysql-innodb-lock.rb +0 -1
- data/bin/check-mysql-msr-replication-status.rb +12 -8
- data/bin/check-mysql-query-result-count.rb +1 -4
- data/bin/check-mysql-replication-status.rb +21 -11
- data/bin/check-mysql-select-count.rb +0 -3
- data/bin/check-mysql-status.rb +4 -4
- data/bin/metrics-mysql-graphite.rb +21 -16
- data/bin/metrics-mysql-processes.rb +24 -17
- data/bin/metrics-mysql-query-result-count.rb +1 -4
- data/bin/metrics-mysql-raw.rb +13 -12
- data/bin/metrics-mysql-select-count.rb +0 -3
- data/lib/sensu-plugins-mysql/version.rb +2 -2
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5922468dc21649e24a29345516eb02ff4f9002aee5415d1aa6248a5cd387bbd9
|
4
|
+
data.tar.gz: c934f6e0c33d107072e897ad3a1ae1e8e316cdfd029df64100114f6f2aae849c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20418c01d373e088978a0162297164776e1a2e4eeed071a9fa45218906ddaa2fa00980215c7fd4362b01b9f164fb24afbf29762d69e063c0d5fdce40a1da5e57
|
7
|
+
data.tar.gz: 7202eeb5502b433c9aced5191a8cb9ebb1287cff3fc977535276042acf97f77665fabed0a4738b9be5a077d29a67cb4f44d6e165a9e243c9c9f19cb320659247
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,17 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
|
9
|
+
## [3.0.0] - 2018-12-04
|
10
|
+
### Security
|
11
|
+
- updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@majormoses)
|
12
|
+
|
13
|
+
### Breaking Changes
|
14
|
+
- removed < ruby 2.3 support as they are EOL (@majormoses)
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
- appeased the cops (@majormoses)
|
18
|
+
|
8
19
|
## [2.7.0] - 2018-11-25
|
9
20
|
### Added
|
10
21
|
- metrics-mysql-select-count.rb script (@nagyt234)
|
@@ -141,7 +152,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
141
152
|
### Added
|
142
153
|
- initial release
|
143
154
|
|
144
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/
|
155
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/3.0.0...HEAD
|
156
|
+
[3.0.0]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.7.0...3.0.0
|
145
157
|
[2.7.0]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.6.0...2.7.0
|
146
158
|
[2.6.0]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.5.1...2.6.0
|
147
159
|
[2.5.1]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.5.0...2.5.1
|
data/bin/check-mysql-disk.rb
CHANGED
@@ -97,7 +97,7 @@ class CheckMysqlDisk < Sensu::Plugin::Check::CLI
|
|
97
97
|
total_size = 0.0
|
98
98
|
db = Mysql.real_connect(config[:host], db_user, db_pass, nil, config[:port], config[:socket])
|
99
99
|
|
100
|
-
results = db.query <<-
|
100
|
+
results = db.query <<-SQL
|
101
101
|
SELECT table_schema,
|
102
102
|
count(*) TABLES,
|
103
103
|
concat(round(sum(table_rows)/1000000,2),'M') rows,
|
@@ -106,7 +106,7 @@ class CheckMysqlDisk < Sensu::Plugin::Check::CLI
|
|
106
106
|
round(sum(data_length+index_length)/(1024*1024*1024),2) total_size,
|
107
107
|
round(sum(index_length)/sum(data_length),2) idxfrac
|
108
108
|
FROM information_schema.TABLES group by table_schema
|
109
|
-
|
109
|
+
SQL
|
110
110
|
|
111
111
|
unless results.nil?
|
112
112
|
results.each_hash do |row|
|
@@ -125,14 +125,11 @@ class CheckMysqlDisk < Sensu::Plugin::Check::CLI
|
|
125
125
|
else
|
126
126
|
ok diskstr
|
127
127
|
end
|
128
|
-
|
129
128
|
rescue Mysql::Error => e
|
130
129
|
errstr = "Error code: #{e.errno} Error message: #{e.error}"
|
131
130
|
critical "#{errstr} SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate')
|
132
|
-
|
133
|
-
rescue => e
|
131
|
+
rescue StandardError => e
|
134
132
|
critical e
|
135
|
-
|
136
133
|
ensure
|
137
134
|
db.close if db
|
138
135
|
end
|
@@ -74,6 +74,16 @@ class CheckMysqlMSRReplicationStatus < Sensu::Plugin::Check::CLI
|
|
74
74
|
default: 1800,
|
75
75
|
proc: proc(&:to_i)
|
76
76
|
|
77
|
+
def set_status(io_thread_status, sql_thread_status, seconds_behind_master)
|
78
|
+
if io_thread_status == 'No' || sql_thread_status == 'No' || seconds_behind_master > config[:crit]
|
79
|
+
2
|
80
|
+
elsif seconds_behind_master > config[:warn] && seconds_behind_master <= config[:crit]
|
81
|
+
1
|
82
|
+
else
|
83
|
+
0
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
77
87
|
def run
|
78
88
|
if config[:ini]
|
79
89
|
ini = IniFile.load(config[:ini])
|
@@ -106,19 +116,13 @@ class CheckMysqlMSRReplicationStatus < Sensu::Plugin::Check::CLI
|
|
106
116
|
io_thread_status = row['Slave_IO_Running']
|
107
117
|
sql_thread_status = row['Slave_SQL_Running']
|
108
118
|
seconds_behind_master = row['Seconds_Behind_Master'].to_i
|
109
|
-
status =
|
110
|
-
if io_thread_status == 'No' || sql_thread_status == 'No' || seconds_behind_master > config[:crit]
|
111
|
-
status = 2
|
112
|
-
end
|
113
|
-
if seconds_behind_master > config[:warn] && seconds_behind_master <= config[:crit]
|
114
|
-
status = 1
|
115
|
-
end
|
119
|
+
status = set_status
|
116
120
|
message = "#{channel['channel_name']} STATES:"
|
117
121
|
message += " Slave_IO_Running=#{io_thread_status}"
|
118
122
|
message += ", Slave_SQL_Running=#{sql_thread_status}"
|
119
123
|
message += ", Seconds_Behind_Master=#{seconds_behind_master}"
|
120
124
|
|
121
|
-
if status
|
125
|
+
if status == 0
|
122
126
|
ok_statuses << message
|
123
127
|
elsif status == 1
|
124
128
|
warn_statuses << message
|
@@ -99,14 +99,11 @@ class MysqlQueryCountCheck < Sensu::Plugin::Check::CLI
|
|
99
99
|
else
|
100
100
|
ok 'Result count length is below thresholds'
|
101
101
|
end
|
102
|
-
|
103
102
|
rescue Mysql::Error => e
|
104
103
|
errstr = "Error code: #{e.errno} Error message: #{e.error}"
|
105
104
|
critical "#{errstr} SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate')
|
106
|
-
|
107
|
-
rescue => e
|
105
|
+
rescue StandardError => e
|
108
106
|
critical e
|
109
|
-
|
110
107
|
ensure
|
111
108
|
db.close if db
|
112
109
|
end
|
@@ -93,6 +93,24 @@ class CheckMysqlReplicationStatus < Sensu::Plugin::Check::CLI
|
|
93
93
|
# #YELLOW
|
94
94
|
proc: lambda { |s| s.to_i } # rubocop:disable Lambda
|
95
95
|
|
96
|
+
def detect_replication_status?(row)
|
97
|
+
%w[
|
98
|
+
Slave_IO_State
|
99
|
+
Slave_IO_Running
|
100
|
+
Slave_SQL_Running
|
101
|
+
Last_IO_Error
|
102
|
+
Last_SQL_Error
|
103
|
+
Seconds_Behind_Master
|
104
|
+
].all? { |key| row.key? key }
|
105
|
+
end
|
106
|
+
|
107
|
+
def slave_running?(row)
|
108
|
+
%w[
|
109
|
+
Slave_IO_Running
|
110
|
+
Slave_SQL_Running
|
111
|
+
].all? { |key| row[key] =~ /Yes/ }
|
112
|
+
end
|
113
|
+
|
96
114
|
def run
|
97
115
|
if config[:ini]
|
98
116
|
ini = IniFile.load(config[:ini])
|
@@ -121,14 +139,9 @@ class CheckMysqlReplicationStatus < Sensu::Plugin::Check::CLI
|
|
121
139
|
|
122
140
|
unless results.nil?
|
123
141
|
results.each_hash do |row|
|
124
|
-
warn "couldn't detect replication status" unless
|
125
|
-
%w(Slave_IO_State Slave_IO_Running Slave_SQL_Running Last_IO_Error Last_SQL_Error Seconds_Behind_Master).all? do |key|
|
126
|
-
row.key? key
|
127
|
-
end
|
142
|
+
warn "couldn't detect replication status" unless detect_replication_status?(row)
|
128
143
|
|
129
|
-
slave_running =
|
130
|
-
row[key] =~ /Yes/
|
131
|
-
end
|
144
|
+
slave_running = slave_running?(row)
|
132
145
|
|
133
146
|
output = if db_conn.nil?
|
134
147
|
'Slave not running!'
|
@@ -160,14 +173,11 @@ class CheckMysqlReplicationStatus < Sensu::Plugin::Check::CLI
|
|
160
173
|
end
|
161
174
|
ok 'show slave status was nil. This server is not a slave.'
|
162
175
|
end
|
163
|
-
|
164
176
|
rescue Mysql::Error => e
|
165
177
|
errstr = "Error code: #{e.errno} Error message: #{e.error}"
|
166
178
|
critical "#{errstr} SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate')
|
167
|
-
|
168
|
-
rescue => e
|
179
|
+
rescue StandardError => e
|
169
180
|
critical e
|
170
|
-
|
171
181
|
ensure
|
172
182
|
db.close if db
|
173
183
|
end
|
@@ -102,14 +102,11 @@ class MysqlSelectCountCheck < Sensu::Plugin::Check::CLI
|
|
102
102
|
else
|
103
103
|
ok "Count is below thresholds : #{count} count"
|
104
104
|
end
|
105
|
-
|
106
105
|
rescue Mysql::Error => e
|
107
106
|
errstr = "Error code: #{e.errno} Error message: #{e.error}"
|
108
107
|
critical "#{errstr} SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate')
|
109
|
-
|
110
108
|
rescue StandardError => e
|
111
109
|
critical "unhandled exception: #{e}"
|
112
|
-
|
113
110
|
ensure
|
114
111
|
db.close if db
|
115
112
|
end
|
data/bin/check-mysql-status.rb
CHANGED
@@ -139,7 +139,7 @@ class CheckMySQLStatus < Sensu::Plugin::Check::CLI
|
|
139
139
|
else
|
140
140
|
critical "Error message: status: #{status}"
|
141
141
|
end
|
142
|
-
rescue => e
|
142
|
+
rescue StandardError => e
|
143
143
|
critical "Error message: status: #{status} | Exception: #{e}"
|
144
144
|
ensure
|
145
145
|
puts ''
|
@@ -162,14 +162,14 @@ class CheckMySQLStatus < Sensu::Plugin::Check::CLI
|
|
162
162
|
end
|
163
163
|
dict = []
|
164
164
|
table.keys.to_a.each do |k|
|
165
|
-
%w
|
165
|
+
%w[Slave_IO_State Slave_IO_Running Slave_SQL_Running Last_IO_Error Last_SQL_Error Seconds_Behind_Master].each do |key|
|
166
166
|
dict.push(k.strip.to_s) if key.strip == k.strip
|
167
167
|
end
|
168
168
|
end
|
169
169
|
table.each do |attribute, value|
|
170
170
|
puts "#{attribute} : #{value}" if config[:debug]
|
171
171
|
warn "couldn't detect replication status :#{dict.size}" unless dict.size == 6
|
172
|
-
slave_running = %w
|
172
|
+
slave_running = %w[Slave_IO_Running Slave_SQL_Running].all? do |key|
|
173
173
|
table[key].to_s =~ /Yes/
|
174
174
|
end
|
175
175
|
output = 'Slave not running!'
|
@@ -189,7 +189,7 @@ class CheckMySQLStatus < Sensu::Plugin::Check::CLI
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
ok 'show slave status was nil. This server is not a slave.'
|
192
|
-
rescue => e
|
192
|
+
rescue StandardError => e
|
193
193
|
critical "Error message: status: #{status} | Exception: #{e}"
|
194
194
|
end
|
195
195
|
end
|
@@ -90,10 +90,8 @@ class MysqlGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
90
90
|
long: '--verbose',
|
91
91
|
boolean: true
|
92
92
|
|
93
|
-
def
|
94
|
-
|
95
|
-
|
96
|
-
metrics = {
|
93
|
+
def metrics_hash
|
94
|
+
{
|
97
95
|
'general' => {
|
98
96
|
'Bytes_received' => 'rxBytes',
|
99
97
|
'Bytes_sent' => 'txBytes',
|
@@ -117,14 +115,14 @@ class MysqlGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
117
115
|
'Select_range' => 'selectRange',
|
118
116
|
'Select_range_check' => 'selectRange_check',
|
119
117
|
'Select_scan' => 'selectScan',
|
120
|
-
'Slow_queries' => 'slowQueries'
|
118
|
+
'Slow_queries' => 'slowQueries',
|
121
119
|
},
|
122
120
|
'querycache' => {
|
123
121
|
'Qcache_queries_in_cache' => 'queriesInCache',
|
124
122
|
'Qcache_hits' => 'cacheHits',
|
125
123
|
'Qcache_inserts' => 'inserts',
|
126
124
|
'Qcache_not_cached' => 'notCached',
|
127
|
-
'Qcache_lowmem_prunes' => 'lowMemPrunes'
|
125
|
+
'Qcache_lowmem_prunes' => 'lowMemPrunes',
|
128
126
|
},
|
129
127
|
'commands' => {
|
130
128
|
'Com_admin_commands' => 'admin_commands',
|
@@ -159,7 +157,7 @@ class MysqlGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
159
157
|
'Com_lock_tables' => 'lock_tables',
|
160
158
|
'Com_show_create_table' => 'show_create_table',
|
161
159
|
'Com_unlock_tables' => 'unlock_tables',
|
162
|
-
'Com_alter_table' => 'alter_table'
|
160
|
+
'Com_alter_table' => 'alter_table',
|
163
161
|
},
|
164
162
|
'counters' => {
|
165
163
|
'Handler_write' => 'handlerWrite',
|
@@ -174,7 +172,7 @@ class MysqlGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
174
172
|
'Handler_commit' => 'handlerCommit',
|
175
173
|
'Handler_rollback' => 'handlerRollback',
|
176
174
|
'Handler_savepoint' => 'handlerSavepoint',
|
177
|
-
'Handler_savepoint_rollback' => 'handlerSavepointRollback'
|
175
|
+
'Handler_savepoint_rollback' => 'handlerSavepointRollback',
|
178
176
|
},
|
179
177
|
'innodb' => {
|
180
178
|
'Innodb_buffer_pool_pages_total' => 'bufferTotal_pages',
|
@@ -195,15 +193,22 @@ class MysqlGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
195
193
|
'Innodb_rows_updated' => 'rowsUpdated',
|
196
194
|
'Innodb_rows_read' => 'rowsRead',
|
197
195
|
'Innodb_rows_deleted' => 'rowsDeleted',
|
198
|
-
'Innodb_rows_inserted' => 'rowsInserted'
|
196
|
+
'Innodb_rows_inserted' => 'rowsInserted',
|
199
197
|
},
|
200
198
|
'configuration' => {
|
201
199
|
'max_connections' => 'MaxConnections',
|
202
|
-
'Max_prepared_stmt_count' => 'MaxPreparedStmtCount'
|
203
|
-
}
|
200
|
+
'Max_prepared_stmt_count' => 'MaxPreparedStmtCount',
|
201
|
+
},
|
204
202
|
}
|
203
|
+
end
|
204
|
+
|
205
|
+
def run
|
206
|
+
# props to https://github.com/coredump/hoardd/blob/master/scripts-available/mysql.coffee
|
207
|
+
|
208
|
+
metrics = metrics_hash
|
205
209
|
|
206
|
-
|
210
|
+
# FIXME: break this up
|
211
|
+
config[:host].split(' ').each do |mysql_host| # rubocop:disable Metrics/BlockLength
|
207
212
|
mysql_shorthostname = mysql_host.split('.')[0]
|
208
213
|
if config[:ini]
|
209
214
|
ini = IniFile.load(config[:ini])
|
@@ -218,7 +223,7 @@ class MysqlGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
218
223
|
mysql = Mysql.new(mysql_host, db_user, db_pass, nil, config[:port], config[:socket])
|
219
224
|
|
220
225
|
results = mysql.query('SHOW GLOBAL STATUS')
|
221
|
-
rescue => e
|
226
|
+
rescue StandardError => e
|
222
227
|
puts e.message
|
223
228
|
end
|
224
229
|
|
@@ -241,7 +246,7 @@ class MysqlGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
241
246
|
output "#{config[:scheme]}.#{mysql_shorthostname}.general.#{metrics['general'][key]}", value
|
242
247
|
end
|
243
248
|
end
|
244
|
-
rescue => e
|
249
|
+
rescue StandardError => e
|
245
250
|
puts "Error querying slave status: #{e}" if config[:verbose]
|
246
251
|
end
|
247
252
|
|
@@ -251,12 +256,12 @@ class MysqlGraphite < Sensu::Plugin::Metric::CLI::Graphite
|
|
251
256
|
category = 'configuration'
|
252
257
|
variables_results.each_hash do |row|
|
253
258
|
metrics[category].each do |metric, desc|
|
254
|
-
if metric.casecmp(row['Variable_name'])
|
259
|
+
if metric.casecmp(row['Variable_name']).zero?
|
255
260
|
output "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.#{desc}", row['Value']
|
256
261
|
end
|
257
262
|
end
|
258
263
|
end
|
259
|
-
rescue => e
|
264
|
+
rescue StandardError => e
|
260
265
|
puts e.message
|
261
266
|
end
|
262
267
|
|
@@ -94,33 +94,40 @@ class MetricsMySQLProcesses < Sensu::Plugin::Metric::CLI::Graphite
|
|
94
94
|
long: '--socket SOCKET',
|
95
95
|
description: 'MySQL Unix socket to connect to'
|
96
96
|
|
97
|
+
def set_default_metrics
|
98
|
+
{
|
99
|
+
'user' => {},
|
100
|
+
'database' => {},
|
101
|
+
'command' => {},
|
102
|
+
}.each_value { |value| value.default = 0 }
|
103
|
+
end
|
104
|
+
|
105
|
+
def db_connection_creds
|
106
|
+
if config[:ini]
|
107
|
+
ini = IniFile.load(config[:ini])
|
108
|
+
section = ini[config[:ini_section]]
|
109
|
+
db_user = section['user']
|
110
|
+
db_pass = section['password']
|
111
|
+
else
|
112
|
+
db_user = config[:username]
|
113
|
+
db_pass = config[:password]
|
114
|
+
end
|
115
|
+
[db_user, db_pass]
|
116
|
+
end
|
117
|
+
|
97
118
|
def run
|
98
119
|
config[:host].split(' ').each do |mysql_host|
|
99
120
|
mysql_shorthostname = mysql_host.split('.')[0]
|
100
|
-
|
101
|
-
ini = IniFile.load(config[:ini])
|
102
|
-
section = ini[config[:ini_section]]
|
103
|
-
db_user = section['user']
|
104
|
-
db_pass = section['password']
|
105
|
-
else
|
106
|
-
db_user = config[:username]
|
107
|
-
db_pass = config[:password]
|
108
|
-
end
|
121
|
+
db_user, db_pass = db_connection_creds
|
109
122
|
begin
|
110
123
|
mysql = Mysql.new(mysql_host, db_user, db_pass, nil, config[:port], config[:socket])
|
111
124
|
|
112
125
|
results = mysql.query('SHOW PROCESSLIST')
|
113
|
-
rescue => e
|
126
|
+
rescue StandardError => e
|
114
127
|
unknown "Unable to query MySQL: #{e.message}"
|
115
128
|
end
|
116
129
|
|
117
|
-
metrics =
|
118
|
-
'user' => {},
|
119
|
-
'database' => {},
|
120
|
-
'command' => {}
|
121
|
-
}
|
122
|
-
|
123
|
-
metrics.each_value { |value| value.default = 0 }
|
130
|
+
metrics = set_default_metrics
|
124
131
|
|
125
132
|
results.each_hash do |row|
|
126
133
|
metrics['user'][row['User']] += 1
|
@@ -86,14 +86,11 @@ class MysqlQueryCountMetric < Sensu::Plugin::Metric::CLI::Graphite
|
|
86
86
|
|
87
87
|
output config[:name], length
|
88
88
|
ok
|
89
|
-
|
90
89
|
rescue Mysql::Error => e
|
91
90
|
errstr = "Error code: #{e.errno} Error message: #{e.error}"
|
92
91
|
critical "#{errstr} SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate')
|
93
|
-
|
94
|
-
rescue => e
|
92
|
+
rescue StandardError => e
|
95
93
|
critical e
|
96
|
-
|
97
94
|
ensure
|
98
95
|
db.close if db
|
99
96
|
end
|
data/bin/metrics-mysql-raw.rb
CHANGED
@@ -182,7 +182,7 @@ class MetricsMySQLRaw < Sensu::Plugin::Metric::CLI::Graphite
|
|
182
182
|
'Select_range' => 'selectRange',
|
183
183
|
'Select_range_check' => 'selectRange_check',
|
184
184
|
'Select_scan' => 'selectScan',
|
185
|
-
'Slow_queries' => 'slowQueries'
|
185
|
+
'Slow_queries' => 'slowQueries',
|
186
186
|
},
|
187
187
|
'querycache' => {
|
188
188
|
'Qcache_queries_in_cache' => 'queriesInCache',
|
@@ -190,7 +190,7 @@ class MetricsMySQLRaw < Sensu::Plugin::Metric::CLI::Graphite
|
|
190
190
|
'Qcache_inserts' => 'inserts',
|
191
191
|
'Qcache_not_cached' => 'notCached',
|
192
192
|
'Qcache_lowmem_prunes' => 'lowMemPrunes',
|
193
|
-
'Qcache_free_memory' => 'freeMemory'
|
193
|
+
'Qcache_free_memory' => 'freeMemory',
|
194
194
|
},
|
195
195
|
'commands' => {
|
196
196
|
'Com_admin_commands' => 'admin_commands',
|
@@ -225,7 +225,7 @@ class MetricsMySQLRaw < Sensu::Plugin::Metric::CLI::Graphite
|
|
225
225
|
'Com_lock_tables' => 'lock_tables',
|
226
226
|
'Com_show_create_table' => 'show_create_table',
|
227
227
|
'Com_unlock_tables' => 'unlock_tables',
|
228
|
-
'Com_alter_table' => 'alter_table'
|
228
|
+
'Com_alter_table' => 'alter_table',
|
229
229
|
},
|
230
230
|
'counters' => {
|
231
231
|
'Handler_write' => 'handlerWrite',
|
@@ -240,7 +240,7 @@ class MetricsMySQLRaw < Sensu::Plugin::Metric::CLI::Graphite
|
|
240
240
|
'Handler_commit' => 'handlerCommit',
|
241
241
|
'Handler_rollback' => 'handlerRollback',
|
242
242
|
'Handler_savepoint' => 'handlerSavepoint',
|
243
|
-
'Handler_savepoint_rollback' => 'handlerSavepointRollback'
|
243
|
+
'Handler_savepoint_rollback' => 'handlerSavepointRollback',
|
244
244
|
},
|
245
245
|
'innodb' => {
|
246
246
|
'Innodb_buffer_pool_pages_total' => 'bufferTotal_pages',
|
@@ -261,11 +261,11 @@ class MetricsMySQLRaw < Sensu::Plugin::Metric::CLI::Graphite
|
|
261
261
|
'Innodb_rows_updated' => 'rowsUpdated',
|
262
262
|
'Innodb_rows_read' => 'rowsRead',
|
263
263
|
'Innodb_rows_deleted' => 'rowsDeleted',
|
264
|
-
'Innodb_rows_inserted' => 'rowsInserted'
|
264
|
+
'Innodb_rows_inserted' => 'rowsInserted',
|
265
265
|
},
|
266
266
|
'configuration' => {
|
267
|
-
'Max_prepared_stmt_count' => 'MaxPreparedStmtCount'
|
268
|
-
}
|
267
|
+
'Max_prepared_stmt_count' => 'MaxPreparedStmtCount',
|
268
|
+
},
|
269
269
|
}
|
270
270
|
metrics
|
271
271
|
end
|
@@ -299,7 +299,7 @@ class MetricsMySQLRaw < Sensu::Plugin::Metric::CLI::Graphite
|
|
299
299
|
output "#{config[:scheme]}.#{mysql_shorthostname}.general.#{metrics['general'][key]}", value
|
300
300
|
end
|
301
301
|
end
|
302
|
-
rescue => e
|
302
|
+
rescue StandardError => e
|
303
303
|
puts "Error querying slave status: #{e}" if config[:verbose]
|
304
304
|
end
|
305
305
|
|
@@ -332,14 +332,15 @@ class MetricsMySQLRaw < Sensu::Plugin::Metric::CLI::Graphite
|
|
332
332
|
end
|
333
333
|
end
|
334
334
|
end
|
335
|
-
rescue => e
|
335
|
+
rescue StandardError => e
|
336
336
|
puts e.message
|
337
337
|
end
|
338
338
|
|
339
339
|
# Fetch MySQL metrics
|
340
340
|
def fetcher(db_user, db_pass, db_socket)
|
341
341
|
metrics = metrics_hash
|
342
|
-
|
342
|
+
# FIXME: this needs refactoring
|
343
|
+
if config[:check] == 'metric' # rubocop:disable Style/GuardClause
|
343
344
|
mysql_shorthostname = config[:hostname].tr('.', '_')
|
344
345
|
begin
|
345
346
|
table = []
|
@@ -362,7 +363,7 @@ class MetricsMySQLRaw < Sensu::Plugin::Metric::CLI::Graphite
|
|
362
363
|
table.each do |row|
|
363
364
|
metrics.each do |category, var_mapping|
|
364
365
|
row_var_name = row['Variable_name'].to_s
|
365
|
-
var_mapping.
|
366
|
+
var_mapping.each_key do |vmkey|
|
366
367
|
if row_var_name.to_s == vmkey.to_s
|
367
368
|
prefix = "#{config[:scheme]}.#{mysql_shorthostname}.#{category}.#{vmkey[row_var_name]}"
|
368
369
|
output prefix, row['Value'] unless mysql_shorthostname.to_s.chomp.empty?
|
@@ -373,7 +374,7 @@ class MetricsMySQLRaw < Sensu::Plugin::Metric::CLI::Graphite
|
|
373
374
|
# Slave and configuration metrics here
|
374
375
|
slave_metrics(metrics)
|
375
376
|
configuration_metrics(metrics, db_user, db_pass, db_socket)
|
376
|
-
rescue => e
|
377
|
+
rescue StandardError => e
|
377
378
|
critical "Error message: status: #{status} | Exception: #{e.backtrace}"
|
378
379
|
ensure
|
379
380
|
ok ''
|
@@ -88,14 +88,11 @@ class MysqlQueryCountMetric < Sensu::Plugin::Metric::CLI::Graphite
|
|
88
88
|
|
89
89
|
output config[:name], count
|
90
90
|
ok
|
91
|
-
|
92
91
|
rescue Mysql::Error => e
|
93
92
|
errstr = "Error code: #{e.errno} Error message: #{e.error}"
|
94
93
|
critical "#{errstr} SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate')
|
95
|
-
|
96
94
|
rescue StandardError => e
|
97
95
|
critical "unhandled exception: #{e}"
|
98
|
-
|
99
96
|
ensure
|
100
97
|
db.close if db
|
101
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-mysql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sensu-Plugins and contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inifile
|
@@ -53,33 +53,33 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.7'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.7'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: codeclimate-test-reporter
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: github-markup
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 0.51.0
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
166
|
+
version: 0.51.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: yard
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,7 +245,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
245
245
|
requirements:
|
246
246
|
- - ">="
|
247
247
|
- !ruby/object:Gem::Version
|
248
|
-
version: 2.
|
248
|
+
version: 2.3.0
|
249
249
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
250
250
|
requirements:
|
251
251
|
- - ">="
|