Merge lp:~chris-gondolin/charms/precise/nrpe-external-master/trunk into lp:charms/nrpe-external-master

Proposed by Chris Stratford
Status: Merged
Merged at revision: 29
Proposed branch: lp:~chris-gondolin/charms/precise/nrpe-external-master/trunk
Merge into: lp:charms/nrpe-external-master
Diff against target: 61 lines (+20/-2)
3 files modified
config.yaml (+7/-0)
hooks/config-changed (+12/-2)
metadata.yaml (+1/-0)
To merge this branch: bzr merge lp:~chris-gondolin/charms/precise/nrpe-external-master/trunk
Reviewer Review Type Date Requested Status
Charles Butler (community) Approve
charmers Pending
Review via email: mp+208332@code.launchpad.net

Description of the change

Added a nagios_hostname_type option. If set to "unit" (the default) the nagios hostname follows the usual Juju unit naming scheme (i.e. <juju-context>-<charm-name>-<unit-number>). If set to "host" the nagios hostname is the server's full hostname.

Both nagios_hostname and nagios_host_context are now exported to any relations, allowing other charms to have a consistent hostname, rather than forcing each one to figure out which hostname to report in its checks.

The merge proposal is the correct way around this time.

To post a comment you must log in.
Revision history for this message
Charles Butler (lazypower) wrote :

+1 LGTM

review: Approve
29. By Liam Young

[chris-gondolin,r=lazypower] Added a nagios_hostname_type config option to decide whether to use Juju unit-style hostname or the real FQDN (useful for MaaS servers)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2013-10-15 11:41:03 +0000
3+++ config.yaml 2014-02-26 11:09:24 +0000
4@@ -16,6 +16,13 @@
5 juju-postgresql-0
6 If you're running multiple environments with the same services in them
7 this allows you to differentiate between them.
8+ nagios_hostname_type:
9+ default: "unit"
10+ type: string
11+ description: |
12+ Determines whether a server is identified by its unit name or
13+ host name. If you're in a virtual environment, "unit" is
14+ probably best. If you're using MaaS, you may prefer "host".
15 disk_root:
16 default: "-u GB -w 25% -c 20% -K 5%"
17 type: string
18
19=== modified file 'hooks/config-changed'
20--- hooks/config-changed 2014-02-07 11:30:53 +0000
21+++ hooks/config-changed 2014-02-26 11:09:24 +0000
22@@ -22,6 +22,7 @@
23
24 export NAGIOS_MASTER=$(config-get nagios_master)
25 export SERVER_PORT=$(config-get server_port)
26+export NAGIOS_HOSTNAME_TYPE=$(config-get nagios_hostname_type)
27 cheetah fill --env --oext compiled templates/nrpe.cfg.tmpl
28 cp templates/nrpe.cfg.compiled /etc/nagios/nrpe.cfg
29 if [[ -d /etc/rsyncd.d ]]; then
30@@ -82,8 +83,17 @@
31 if [ -z "$RELATION" ]; then
32 RELATION="$JUJU_UNIT_NAME"
33 fi
34-export NAGIOS_HOSTNAME="$(config-get nagios_host_context)-${RELATION}"
35-export NAGIOS_HOSTNAME=${NAGIOS_HOSTNAME//\//-}
36+if [ "$NAGIOS_HOSTNAME_TYPE" = "host" ]; then
37+ export NAGIOS_HOSTNAME=$(hostname --fqdn)
38+else
39+ export NAGIOS_HOSTNAME="$(config-get nagios_host_context)-${RELATION}"
40+ export NAGIOS_HOSTNAME=${NAGIOS_HOSTNAME//\//-}
41+fi
42+RELATION_IDS=$(relation-ids nrpe-external-master)
43+for id in $RELATION_IDS; do
44+ relation-set -r $id nagios_hostname=${NAGIOS_HOSTNAME}
45+ relation-set -r $id nagios_host_context=$(config-get nagios_host_context)
46+done
47 export IPADDRESS=$(get_ipaddress $(unit-get private-address))
48 export HOSTCHECK_INHERIT=$(config-get hostcheck_inherit)
49 export HOSTGROUPS=$(config-get hostgroups)
50
51=== modified file 'metadata.yaml'
52--- metadata.yaml 2012-10-02 19:33:44 +0000
53+++ metadata.yaml 2014-02-26 11:09:24 +0000
54@@ -19,6 +19,7 @@
55 nrpe-external-master:
56 interface: nrpe-external-master
57 scope: container
58+ sets: [nagios_hostname, nagios_host_context]
59 general-info:
60 interface: juju-info
61 scope: container

Subscribers

People subscribed via source and target branches

to all changes: