Incorrect host_name used when nagios_hostname_type is "host"

Bug #1532281 reported by Andreas Hasenack
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Landscape Server
Fix Released
Undecided
Andreas Hasenack
nrpe (Juju Charms Collection)
Fix Released
Undecided
Chad Smith

Bug Description

When deploying the nrpe charm with the nagios_hostname_type option set to "host", the host_name option in the service files in /var/lib/nagios/export is incorrect.

Instead of pointing at the actual hostname, host_name still points at the unit name, as if nagios_hostname_type was still set to "unit" (which is the default, btw):

root@andreas-local-machine-5:/var/lib/nagios/export# ls -la
total 12
drwxr-xr-x 1 root root 224 Jan 8 15:41 .
drwxr-xr-x 1 nagios nagios 12 Jan 8 15:40 ..
-r--r--r-- 1 root root 265 Jan 8 15:41 host__andreas-local-machine-5.cfg
-rw-r--r-- 1 root root 435 Jan 8 15:41 service__juju-mysql-0_check_mysql.cfg
-rw-r--r-- 1 root root 440 Jan 8 15:41 service__juju-mysql-0_check_mysql_proc.cfg

root@andreas-local-machine-5:/var/lib/nagios/export# cat host__andreas-local-machine-5.cfg
#---------------------------------------------------
# This file is Juju managed
#--------------------------------------------------

define host {
    address 10.0.3.77
    host_name andreas-local-machine-5 <----- correct value
    use server
    hostgroups machines,
}

root@andreas-local-machine-5:/var/lib/nagios/export# cat service__juju-mysql-0_check_mysql.cfg

#---------------------------------------------------
# This file is Juju managed
#---------------------------------------------------
define service {
    use active-service
    host_name juju-mysql-0 <---- INCORRECT, should have been andreas-local-machine-5
    service_description juju-mysql-0[mysql] Check MySQL connectivity
    check_command check_nrpe!check_mysql
    servicegroups juju
}

Here is a simple deployer file that shows the problem:
nrpe-test:
    services:
        apache2:
            charm: cs:trusty/apache2
        mysql:
            charm: cs:trusty/mysql
            to: [apache2]
        nrpe:
            charm: cs:trusty/nrpe
            options:
                export_nagios_definitions: true
                nagios_host_context: "region1"
                nagios_master: "10.0.3.75"
                nagios_hostname_type: "host"
    relations:
        - ["apache2:nrpe-external-master", "nrpe:nrpe-external-master"]
        - ["mysql:nrpe-external-master", "nrpe:nrpe-external-master"]

Related branches

tags: added: kanban-cross-team
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

It looks like the nagios_hostname relation data is never set on the nrpe-external-master relation.

Revision history for this message
Andreas Hasenack (ahasenack) wrote :

I ran this to fix the service config files:
juju run --all 'cd /var/lib/nagios/export; for n in service__*; do sudo sed -i -r "s/host_name([[:blank:]]+).*/host_name\1$(hostname)/" $n; done'

Chad Smith (chad.smith)
Changed in nrpe (Juju Charms Collection):
status: New → In Progress
assignee: nobody → Chad Smith (chad.smith)
tags: added: kanban
Stuart Bishop (stub)
Changed in nrpe (Juju Charms Collection):
status: In Progress → Fix Released
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Was fixed in landscape trunk r9629.

tags: added: bug-squad landscape
Changed in landscape:
assignee: nobody → Andreas Hasenack (ahasenack)
milestone: none → 16.02
status: New → Fix Committed
tags: removed: kanban
Changed in landscape:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.