[bradm] Check if host_context is defined before using it

This commit is contained in:
Brad Marshall
2014-11-06 17:33:27 +10:00
parent 0d202349de
commit 18ce99fa23

View File

@@ -197,6 +197,7 @@ def website_relation_joined():
def update_nrpe_config():
# Find out if nrpe set nagios_hostname
hostname = None
host_context = None
for rel in relations_of_type('nrpe-external-master'):
if 'nagios_hostname' in rel:
hostname = rel['nagios_hostname']
@@ -204,7 +205,10 @@ def update_nrpe_config():
break
nrpe_compat = nrpe.NRPE(hostname=hostname)
current_unit = "%s:%s" % (host_context, local_unit())
if host_context:
current_unit = "%s:%s" % (host_context, local_unit())
else:
current_unit = local_unit()
conf = nrpe_compat.config
check_http_params = conf.get('nagios_check_http_params')