<commit_before>require 'serverspec'

set :backend, :exec

describe file('/etc/nagios/mysql.cnf') do
  its(:content) { should match(/user = monitor/) }
  its(:content) { should match(/password = <PASSWORD>/) }
  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 <PASSWORD>/) }
  it { should be_mode 600 }
  it { should be_owned_by 'munin' }
  it { should be_grouped_into 'munin' }
end

%w(
  bin_relay_log
  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<commit_msg>Remove bin_relay_log from mon serverspec<commit_after>require 'serverspec'

set :backend, :exec

describe file('/etc/nagios/mysql.cnf') do
  its(:content) { should match(/user = monitor/) }
  its(:content) { should match(/password = <PASSWORD>/) }
  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 <PASSWORD>/) }
  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
{'fraction_non_alphanumeric': 0.14054232804232805, 'fraction_numerical': 0.008597883597883597, 'mean_word_length': 3.6538461538461537, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6603427', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1134, 'n_words': 254}