Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't mangle hostname from nrpe #95

Open
axinojolais opened this issue Sep 4, 2020 · 2 comments
Open

Don't mangle hostname from nrpe #95

axinojolais opened this issue Sep 4, 2020 · 2 comments

Comments

@axinojolais
Copy link

I think the following code is buggy :

# We have to strip the nagios host context from the nagios hostname
# since the nagios.add_check will put it back again...
nagios_hostname = rel['nagios_hostname']
if nagios_hostname.startswith(nagios_host_context + '-'):
nagios_hostname = nagios_hostname[len(nagios_host_context +
'-'):]

The charm should use the hostname as given by the relation. It shouldn't modify it.

I ran into this issue while deploying this charm, where the hostname on the generated check was mangled.
Removing the if block above fixed this problem.

@mthaddon
Copy link
Collaborator

Looking at https://github.com/cmars/nrpe-external-master-interface/blob/master/provides.py#L22 host_name seems to be:

if not unit:
    unit = hookenv.local_unit()
unit = unit.replace('/', '-')
context = self.get_remote('nagios_host_context', context)
host_name = self.get_remote('nagios_hostname', '%s-%s' % (context, unit))

So it looks like the interface code is prepending nagios_context into nagios_hostname. What was nagios_context set to in your case?

@axinojolais
Copy link
Author

That was a while ago, I don't remember sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants