Merge ~brad-marshall/charm-prometheus-ceph-exporter/+git/prometheus-ceph-exporter-charm:add-nem-interface into ~prometheus-charmers/charm-prometheus-ceph-exporter/+git/prometheus-ceph-exporter-charm:master

Proposed by Brad Marshall
Status: Merged
Approved by: James Hebden
Approved revision: a2aaf2533cf799f2ba0632d70fe5ce82f51f1fdd
Merged at revision: a2aaf2533cf799f2ba0632d70fe5ce82f51f1fdd
Proposed branch: ~brad-marshall/charm-prometheus-ceph-exporter/+git/prometheus-ceph-exporter-charm:add-nem-interface
Merge into: ~prometheus-charmers/charm-prometheus-ceph-exporter/+git/prometheus-ceph-exporter-charm:master
Diff against target: 81 lines (+31/-1)
4 files modified
config.yaml (+14/-0)
layer.yaml (+1/-1)
metadata.yaml (+4/-0)
reactive/prometheus-ceph-exporter.py (+12/-0)
Reviewer Review Type Date Requested Status
James Hebden (community) Approve
Review via email: mp+328901@code.launchpad.net

Description of the change

Added nrpe-external-master interface and a http check

To post a comment you must log in.
Revision history for this message
James Hebden (ec0) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/config.yaml b/config.yaml
2index 4cf7a63..afca810 100644
3--- a/config.yaml
4+++ b/config.yaml
5@@ -7,3 +7,17 @@ options:
6 description: Daemon arguments to pass to the exporter.
7 type: string
8 default: ""
9+ nagios_context:
10+ default: "juju"
11+ type: string
12+ description: |
13+ A string that will be prepended to instance name to set the host name
14+ in nagios. So for instance the hostname would be something like:
15+ juju-myservice-0
16+ If you're running multiple environments with the same services in them
17+ this allows you to differentiate between them.
18+ nagios_servicegroups:
19+ default: "juju"
20+ type: string
21+ description: |
22+ Comma separated list of nagios servicegroups for the graphite check
23diff --git a/layer.yaml b/layer.yaml
24index 96ddd93..0cb8df6 100644
25--- a/layer.yaml
26+++ b/layer.yaml
27@@ -1,4 +1,4 @@
28-includes: ['layer:basic', 'interface:http', 'layer:snap', 'interface:ceph-client']
29+includes: ['layer:basic', 'interface:http', 'layer:snap', 'interface:ceph-client', 'interface:nrpe-external-master']
30 repo: 'https://git.launchpad.net/prometheus-ceph-exporter-charm'
31 ignore: ['.*.swp' ]
32 options:
33diff --git a/metadata.yaml b/metadata.yaml
34index 55f3cf5..11d8741 100644
35--- a/metadata.yaml
36+++ b/metadata.yaml
37@@ -7,6 +7,7 @@ description: |
38 tags:
39 - monitoring
40 - prometheus
41+ - ceph
42 series:
43 - xenial
44 - trusty
45@@ -14,6 +15,9 @@ subordinate: false
46 provides:
47 ceph-exporter:
48 interface: http
49+ nrpe-external-master:
50+ interface: nrpe-external-master
51+ scope: container
52 requires:
53 ceph:
54 interface: ceph-client
55diff --git a/reactive/prometheus-ceph-exporter.py b/reactive/prometheus-ceph-exporter.py
56index 9d6fb73..91de7cc 100644
57--- a/reactive/prometheus-ceph-exporter.py
58+++ b/reactive/prometheus-ceph-exporter.py
59@@ -21,6 +21,7 @@ from charms.reactive import (
60 when, when_any, set_state, remove_state
61 )
62 from charms.reactive.helpers import any_file_changed, data_changed
63+from charmhelpers.contrib.charmsupport import nrpe
64 # from charms.layer import snap
65
66 from charmhelpers.fetch import (
67@@ -121,3 +122,14 @@ def restart_ceph_exporter():
68 @when('ceph-exporter.available') # Relation name is "ceph-exporter"
69 def configure_ceph_exporter_relation(target):
70 target.configure(PORT_DEF)
71+
72+
73+@when('nrpe-external-master.available')
74+def update_nrpe_config(svc):
75+ hostname = nrpe.get_nagios_hostname()
76+ nrpe_setup = nrpe.NRPE(hostname=hostname)
77+ nrpe_setup.add_check('prometheus_ceph_exporter_http',
78+ 'Prometheus Ceph Exporter HTTP check',
79+ 'check_http -I 127.0.0.1 -p {} -u /metrics'.format(PORT_DEF)
80+ )
81+ nrpe_setup.write()

Subscribers

People subscribed via source and target branches