/
mon_spec.rb
64 lines (58 loc) · 1.5 KB
/
mon_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
require 'serverspec'
set :backend, :exec
describe file('/etc/nagios/mysql.cnf') do
its(:content) { should match(/user = monitor/) }
its(:content) { should match(/password = ToJzwUyqQmyV4GgMVpz0/) }
it { should be_mode 600 }
it { should be_owned_by 'nrpe' }
it { should be_grouped_into 'nrpe' }
end
%w(
innodb
pidfile
processlist
replication-delay
).each do |p|
describe file("/etc/nagios/nrpe.d/pmp-check-mysql-#{p}.cfg") do
its(:content) do
should match(%r{command\[pmp-check-mysql-#{p}\]=\
/usr/lib64/nagios/plugins/pmp-check-mysql-#{p}})
end
end
describe command("/usr/lib64/nagios/plugins/pmp-check-mysql-#{p}") do
its(:stdout) { should match(/^OK/) }
its(:exit_status) { should eq 0 }
end
end
describe file('/etc/munin/plugin-conf.d/mysql') do
its(:content) { should match(/env.mysqluser monitor/) }
its(:content) { should match(/env.mysqlpassword ToJzwUyqQmyV4GgMVpz0/) }
it { should be_mode 600 }
it { should be_owned_by 'munin' }
it { should be_grouped_into 'munin' }
end
# bin_relay_log
# is excluded from here since it doesn't work
# for a single-node mysql installation
%w(
commands
connections
innodb_bpool
innodb_bpool_act
innodb_semaphores
qcache
qcache_mem
queries
slow
slowqueries
table_locks
threads
tmp_tables
).each do |p|
describe command("/usr/sbin/munin-run mysql_#{p}") do
its(:exit_status) { should eq 0 }
end
end
describe command('/usr/local/libexec/mysql-accounting') do
its(:exit_status) { should eq 0 }
end