deploy a simple service check

This commit is contained in:
Paul Collins 2017-05-26 11:05:54 +12:00
parent 880bae771c
commit f15f9cda9b
4 changed files with 38 additions and 0 deletions

View File

@ -8,6 +8,20 @@ options:
When this option is set, vault will be unable to prevent secrets
from being paged out, so use it with extreme caution.
nagios_context:
default: "juju"
type: string
description: |
A string that will be prepended to instance name to set the host name
in nagios. So for instance the hostname would be something like:
juju-myservice-0
If you're running multiple environments with the same services in them
this allows you to differentiate between them.
nagios_servicegroups:
default: "juju"
type: string
description: |
Comma separated list of nagios servicegroups for the graphite check
ssl-cert:
type: string
default: ""

View File

@ -1,6 +1,7 @@
includes:
- layer:basic
- layer:snap
- interface:nrpe-external-master
- interface:pgsql
options:
basic:

View File

@ -6,3 +6,7 @@ description: seriously, it's just a vault charm
requires:
db:
interface: pgsql
provides:
nrpe-external-master:
interface: nrpe-external-master
scope: container

View File

@ -1,6 +1,13 @@
import base64
import psycopg2
from charmhelpers.contrib.charmsupport.nrpe import (
NRPE,
add_init_service_checks,
get_nagios_hostname,
get_nagios_unit_name,
)
from charmhelpers.core.hookenv import (
config,
open_port,
@ -140,3 +147,15 @@ def ssl_chain_changed():
@when('config.changed.ssl-key')
def ssl_key_changed():
remove_state('vault.ssl.configured')
@when('configured')
@when('nrpe-external-master.available')
def update_nagios(svc):
status_set('maintenance', 'configuring Nagios checks')
hostname = get_nagios_hostname()
current_unit = get_nagios_unit_name()
nrpe = NRPE(hostname=hostname)
add_init_service_checks(nrpe, ['vault'], current_unit)
nrpe.write()
status_set('active', 'Nagios checks configured')