8
d = amulet.Deployment(series='trusty')
14
d.relate('nagios:monitors', 'mysql:monitors')
15
d.relate('nrpe:monitors', 'nagios:monitors')
16
d.relate('nrpe:local-monitors', 'mysql:local-monitors')
21
d.setup(timeout=seconds)
22
except amulet.helpers.TimeoutError:
23
amulet.raise_status(amulet.SKIP, msg="Environment wasn't stood up in time")
29
# Set relationship aliases
31
mysql_unit = d.sentry.unit['mysql/0']
32
nagios_unit = d.sentry.unit['nagios/0']
35
def test_nrpe_monitors_config():
36
# look for procrunning in nrpe config
38
mysql_unit.file_contents('/etc/nagios/nrpe.d/procrunning_mysqld.cfg')
40
amulet.raise_status(amulet.ERROR,
41
msg="procrunning config not found. Error:" +
45
def test_nagios_monitors_response():
46
# look for mysql_database requests
47
nagpwd = nagios_unit.file_contents('/var/lib/juju/nagios.passwd').strip()
48
host_url = ("http://%s/cgi-bin/nagios3/status.cgi?"
50
r = requests.get(host_url % nagios_unit.info['public-address'],
51
auth=('nagiosadmin', nagpwd))
52
if not r.text.find('mysql-0-basic'):
53
amulet.raise_status(amulet.ERROR,
54
msg='Nagios is not monitoring the' +
55
' hosts it supposed to.')
57
test_nrpe_monitors_config()
58
test_nagios_monitors_response()