~brad-marshall/charms/trusty/nrpe-external-master/add-daemon-checks

« back to all changes in this revision

Viewing changes to hooks/config-changed

  • Committer: Brad Marshall
  • Date: 2014-10-09 03:16:48 UTC
  • mfrom: (33.1.1 nrpe-external-master)
  • Revision ID: brad.marshall@canonical.com-20141009031648-781l94hilu7gd6au
[brad-marshall, r=chris-gondolin] Fixes an issue with the nagios hostname being empty if hostname --fqdn errors out, which can happen with LXCs or other oddness with DNS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
    RELATION="$JUJU_UNIT_NAME"
95
95
fi
96
96
if [ "$NAGIOS_HOSTNAME_TYPE" = "host" ]; then
97
 
    export NAGIOS_HOSTNAME=$(hostname --fqdn)
 
97
    if hostname --fqdn>/dev/null; then
 
98
        export NAGIOS_HOSTNAME=$(hostname --fqdn)
 
99
    else
 
100
        export NAGIOS_HOSTNAME=$(hostname)
 
101
    fi
 
102
  
98
103
else
99
104
    export NAGIOS_HOSTNAME="$(config-get nagios_host_context)-${RELATION}"
100
105
    export NAGIOS_HOSTNAME=${NAGIOS_HOSTNAME//\//-}