sensu-plugins-mysql 2.2.1 → 2.3.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 +5 -5
- data/CHANGELOG.md +9 -1
- data/README.md +7 -0
- data/bin/check-mysql-msr-replication-status.rb +153 -0
- data/lib/sensu-plugins-mysql/version.rb +2 -2
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b5e5653712ab73a7fb12a37a97c8472ffab497df
|
4
|
+
data.tar.gz: 556cff86d0e9ceb1a7a2954527f858a2e5b7be1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0166be616c39d39a56314c683e3f91fe09aad4cdad696a34a5115fb14fcc2f77ff389e149f5733d523e36c290719189f1ab3279f57f919bc6b900e20209e2c39
|
7
|
+
data.tar.gz: 900c46efc192ba7c71b9ac3d975dd924e6ffc9beec6e75f366178e0498a6e6041219de8db613a8cdfe09d2e8381fb8c237c3ae717badde9a8d5ef5414d2205b7
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,13 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [2.3.0] - 2018-03-17
|
9
|
+
### Added
|
10
|
+
- check-mysql-msr-replication-status.rb: new script that helps with monitoring mysql multi-source replication (@ndelic0)
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- appeased cops (@majormoses)
|
14
|
+
|
8
15
|
## [2.1.1] - 2018-02-07
|
9
16
|
### Fixed
|
10
17
|
- check-mysql-status.rb: if --socket flag is specified, it overrides config (@tinle)
|
@@ -114,7 +121,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
|
|
114
121
|
### Added
|
115
122
|
- initial release
|
116
123
|
|
117
|
-
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.
|
124
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.3.0...HEAD
|
125
|
+
[2.3.0]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.2.1...2.3.0
|
118
126
|
[2.2.1]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.2.0..2.2.1
|
119
127
|
[2.2.0]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.1.1...2.2.0
|
120
128
|
[2.1.2]: https://github.com/sensu-plugins/sensu-plugins-mysql/compare/2.1.1...2.1.2
|
data/README.md
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
* bin/check-mysql-innodb-lock.rb
|
18
18
|
* bin/check-mysql-threads.rb
|
19
19
|
* bin/check-mysql-query-result-count.rb
|
20
|
+
* bin/check-mysql-msr-replication-status.rb
|
20
21
|
* bin/metrics-mysql-graphite.rb
|
21
22
|
* bin/metrics-mysql-processes.rb
|
22
23
|
* bin/metrics-mysql-raw.rb
|
@@ -76,6 +77,11 @@ $ /opt/sensu/embedded/bin/check-mysql-threads.rb --host=<DBHOST> --ini=/etc/sens
|
|
76
77
|
$ /opt/sensu/embedded/bin/check-mysql-replication-status.rb --host=<SLAVE> --ini=/etc/sensu/my.ini
|
77
78
|
```
|
78
79
|
|
80
|
+
**check-mysql-msr-replication-status** example
|
81
|
+
```bash
|
82
|
+
$ /opt/sensu/embedded/bin/check-mysql-replication-status.rb --host=<SLAVE> --ini=/etc/sensu/my.ini
|
83
|
+
```
|
84
|
+
|
79
85
|
**check-mysql-query-result-count** example
|
80
86
|
```bash
|
81
87
|
/opt/sensu/embedded/bin$ /opt/sensu/embedded/bin/ruby check-mysql-query-result-count.rb --host=localhost --port=3306 --user=collectd --pass=tflypass --socket=/data/mysql.sock --warning 1 --critical 10 --query 'SELECT DISTINCT(t.id) FROM table t where t.failed = true'
|
@@ -98,6 +104,7 @@ In keeping with the principle of least privilege you should create a new user wi
|
|
98
104
|
| check-mysql-innodb-lock.rb | `PROCESS` |
|
99
105
|
| check-mysql-query-result-count.rb | depends on query |
|
100
106
|
| check-mysql-replication-status.rb | `SUPER` OR `REPLICATION_CLIENT` (the latter is preferable)|
|
107
|
+
| check-mysql-msr-replication-status.rb | `SELECT` |
|
101
108
|
| check-mysql-status.rb | `SELECT` |
|
102
109
|
| check-mysql-threads.rb | `SELECT` |
|
103
110
|
| metrics-mysql-graphite.rb | `SELECT` |
|
@@ -0,0 +1,153 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# MySQL Multi-source Replication Status
|
4
|
+
# ===
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# EXAMPLE
|
8
|
+
# check-mysql-msr-replication-status.rb -h db01 --ini '/etc/sensu/my.cnf'
|
9
|
+
# check-mysql-msr-replication-status.rb -h db01 --ini '/etc/sensu/my.cnf' --ini-section customsection
|
10
|
+
#
|
11
|
+
# MY.CNF INI FORMAT
|
12
|
+
# [client]
|
13
|
+
# user=sensu
|
14
|
+
# password="abcd1234"
|
15
|
+
#
|
16
|
+
# [customsection]
|
17
|
+
# user=user
|
18
|
+
# password="password"
|
19
|
+
#
|
20
|
+
|
21
|
+
require 'sensu-plugin/check/cli'
|
22
|
+
require 'mysql'
|
23
|
+
require 'inifile'
|
24
|
+
|
25
|
+
class CheckMysqlMSRReplicationStatus < Sensu::Plugin::Check::CLI
|
26
|
+
option :host,
|
27
|
+
short: '-h',
|
28
|
+
long: '--host VALUE',
|
29
|
+
description: 'Database host'
|
30
|
+
|
31
|
+
option :port,
|
32
|
+
short: '-P',
|
33
|
+
long: '--port VALUE',
|
34
|
+
description: 'Database port',
|
35
|
+
default: 3306,
|
36
|
+
proc: proc(&:to_i)
|
37
|
+
|
38
|
+
option :socket,
|
39
|
+
short: '-s SOCKET',
|
40
|
+
long: '--socket SOCKET',
|
41
|
+
description: 'Socket to use'
|
42
|
+
|
43
|
+
option :user,
|
44
|
+
short: '-u',
|
45
|
+
long: '--username VALUE',
|
46
|
+
description: 'Database username'
|
47
|
+
|
48
|
+
option :pass,
|
49
|
+
short: '-p',
|
50
|
+
long: '--password VALUE',
|
51
|
+
description: 'Database password'
|
52
|
+
|
53
|
+
option :ini,
|
54
|
+
short: '-i',
|
55
|
+
long: '--ini VALUE',
|
56
|
+
description: 'My.cnf ini file'
|
57
|
+
|
58
|
+
option :ini_section,
|
59
|
+
description: 'Section in my.cnf ini file',
|
60
|
+
long: '--ini-section VALUE',
|
61
|
+
default: 'client'
|
62
|
+
|
63
|
+
option :warn,
|
64
|
+
short: '-w',
|
65
|
+
long: '--warning VALUE',
|
66
|
+
description: 'Warning threshold for replication lag',
|
67
|
+
default: 900,
|
68
|
+
proc: proc(&:to_i)
|
69
|
+
|
70
|
+
option :crit,
|
71
|
+
short: '-c',
|
72
|
+
long: '--critical=VALUE',
|
73
|
+
description: 'Critical threshold for replication lag',
|
74
|
+
default: 1800,
|
75
|
+
proc: proc(&:to_i)
|
76
|
+
|
77
|
+
def run
|
78
|
+
if config[:ini]
|
79
|
+
ini = IniFile.load(config[:ini])
|
80
|
+
section = ini[config[:ini_section]]
|
81
|
+
db_user = section['user']
|
82
|
+
db_pass = section['password']
|
83
|
+
else
|
84
|
+
db_user = config[:user]
|
85
|
+
db_pass = config[:pass]
|
86
|
+
end
|
87
|
+
db_host = config[:host]
|
88
|
+
|
89
|
+
if [db_host, db_user, db_pass].any?(&:nil?)
|
90
|
+
unknown 'Must specify host, user, password'
|
91
|
+
end
|
92
|
+
|
93
|
+
begin
|
94
|
+
ok_statuses = []
|
95
|
+
warn_statuses = []
|
96
|
+
crit_statuses = []
|
97
|
+
output = []
|
98
|
+
|
99
|
+
db = Mysql.new(db_host, db_user, db_pass, nil, config[:port], config[:socket])
|
100
|
+
channels = db.query('SELECT channel_name FROM performance_schema.replication_connection_status')
|
101
|
+
|
102
|
+
channels.num_rows.times do
|
103
|
+
channel = channels.fetch_hash
|
104
|
+
results = db.query("SHOW SLAVE STATUS FOR CHANNEL \'#{channel['channel_name']}\'")
|
105
|
+
results.each_hash do |row|
|
106
|
+
io_thread_status = row['Slave_IO_Running']
|
107
|
+
sql_thread_status = row['Slave_SQL_Running']
|
108
|
+
seconds_behind_master = row['Seconds_Behind_Master'].to_i
|
109
|
+
status = 0
|
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
|
116
|
+
message = "#{channel['channel_name']} STATES:"
|
117
|
+
message += " Slave_IO_Running=#{io_thread_status}"
|
118
|
+
message += ", Slave_SQL_Running=#{sql_thread_status}"
|
119
|
+
message += ", Seconds_Behind_Master=#{seconds_behind_master}"
|
120
|
+
|
121
|
+
if status.zero?
|
122
|
+
ok_statuses << message
|
123
|
+
elsif status == 1
|
124
|
+
warn_statuses << message
|
125
|
+
elsif status == 2
|
126
|
+
crit_statuses << message
|
127
|
+
else
|
128
|
+
puts 'Undefined status.'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
output << crit_statuses unless crit_statuses.empty?
|
133
|
+
output << warn_statuses unless warn_statuses.empty?
|
134
|
+
output << ok_statuses unless ok_statuses.empty?
|
135
|
+
|
136
|
+
if !crit_statuses.empty?
|
137
|
+
critical output
|
138
|
+
elsif !warn_statuses.empty?
|
139
|
+
warning output
|
140
|
+
else
|
141
|
+
ok output
|
142
|
+
end
|
143
|
+
rescue Mysql::Error => e
|
144
|
+
errstr = "Error code: #{e.errno} Error message: #{e.error}"
|
145
|
+
errstr += "SQLSTATE: #{e.sqlstate}" if e.respond_to?('sqlstate')
|
146
|
+
critical errstr
|
147
|
+
rescue StandardError => e
|
148
|
+
critical "unhandled exception: #{e}"
|
149
|
+
ensure
|
150
|
+
db.close if db
|
151
|
+
end
|
152
|
+
end
|
153
|
+
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: 2.
|
4
|
+
version: 2.3.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-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inifile
|
@@ -186,19 +186,20 @@ description: |-
|
|
186
186
|
sending metrics to a MySQL database.
|
187
187
|
email: "<sensu-users@googlegroups.com>"
|
188
188
|
executables:
|
189
|
-
-
|
190
|
-
- check-mysql-connections.rb
|
189
|
+
- metrics-mysql-query-result-count.rb
|
191
190
|
- check-mysql-disk.rb
|
191
|
+
- metrics-mysql.rb
|
192
192
|
- check-mysql-innodb-lock.rb
|
193
|
+
- check-mysql-alive.rb
|
193
194
|
- check-mysql-query-result-count.rb
|
195
|
+
- metrics-mysql-graphite.rb
|
194
196
|
- check-mysql-replication-status.rb
|
195
|
-
- check-mysql-status.rb
|
196
197
|
- check-mysql-threads.rb
|
197
|
-
-
|
198
|
+
- check-mysql-msr-replication-status.rb
|
198
199
|
- metrics-mysql-processes.rb
|
199
|
-
- metrics-mysql-query-result-count.rb
|
200
200
|
- metrics-mysql-raw.rb
|
201
|
-
-
|
201
|
+
- check-mysql-connections.rb
|
202
|
+
- check-mysql-status.rb
|
202
203
|
extensions: []
|
203
204
|
extra_rdoc_files: []
|
204
205
|
files:
|
@@ -209,6 +210,7 @@ files:
|
|
209
210
|
- bin/check-mysql-connections.rb
|
210
211
|
- bin/check-mysql-disk.rb
|
211
212
|
- bin/check-mysql-innodb-lock.rb
|
213
|
+
- bin/check-mysql-msr-replication-status.rb
|
212
214
|
- bin/check-mysql-query-result-count.rb
|
213
215
|
- bin/check-mysql-replication-status.rb
|
214
216
|
- bin/check-mysql-status.rb
|
@@ -247,7 +249,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
247
249
|
version: '0'
|
248
250
|
requirements: []
|
249
251
|
rubyforge_project:
|
250
|
-
rubygems_version: 2.
|
252
|
+
rubygems_version: 2.5.2.1
|
251
253
|
signing_key:
|
252
254
|
specification_version: 4
|
253
255
|
summary: Sensu plugins for MySql
|