from charms.reactive import (
when,
when_not,
set_state)
from charmhelpers.core import hookenv
@when_not('testme.installed')
def install_testme():
set_state('testme.installed')
@when_not('testme.ready')
def status_testme():
hookenv.status_set('active', 'ready')
set_state('testme.ready')
@when('local-monitors.available')
def setup_nagios(nagios):
hookenv.status_set('maintenance', 'Creating Nagios check')
config = hookenv.config()
unit_name = hookenv.local_unit()
nagios.add_check(['/usr/lib/nagios/plugins/check_http',
'-I', '127.0.0.1', '-p', str(config['port']),
'-e', " 200 OK", '-u', '/publickey'],
name="check_http",
description="Verify my awesome service is responding",
context=config["nagios_context"],
unit=unit_name,)