[bradm] Add nagios checks
This commit is contained in:
parent
81534722c9
commit
2211f4642a
17
config.yaml
17
config.yaml
|
@ -68,4 +68,19 @@ options:
|
|||
InnoDB table into separate .idb file. Existing InnoDB tables will remain
|
||||
in ibdata1 file - full dump/import is needed to get rid of large
|
||||
ibdata1 file
|
||||
|
||||
nagios_context:
|
||||
default: "juju"
|
||||
type: string
|
||||
description: |
|
||||
Used by the nrpe-external-master subordinate charm.
|
||||
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: ""
|
||||
type: string
|
||||
description: |
|
||||
A comma-separated list of nagios servicegroups.
|
||||
If left empty, the nagios_context will be used as the servicegroup
|
||||
|
|
|
@ -69,6 +69,8 @@ from charmhelpers.contrib.network.ip import (
|
|||
is_address_in_network,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.charmsupport import nrpe
|
||||
|
||||
hooks = Hooks()
|
||||
|
||||
LEADER_RES = 'grp_percona_cluster'
|
||||
|
@ -424,6 +426,23 @@ def ha_relation_changed():
|
|||
relation_clear(r_id)
|
||||
|
||||
|
||||
@hooks.hook('nrpe-external-master-relation-joined',
|
||||
'nrpe-external-master-relation-changed')
|
||||
def update_nrpe_config():
|
||||
# python-dbus is used by check_upstart_job
|
||||
apt_install('python-dbus')
|
||||
hostname = nrpe.get_nagios_hostname()
|
||||
current_unit = nrpe.get_nagios_unit_name()
|
||||
nrpe_setup = nrpe.NRPE(hostname=hostname)
|
||||
nrpe.add_init_service_checks(nrpe_setup, 'mysql', current_unit)
|
||||
nrpe_setup.add_check(
|
||||
shortname='mysql_proc',
|
||||
description='Check MySQL process {%s}' % current_unit,
|
||||
check_cmd='check_procs -c 1:1 -C mysqld'
|
||||
)
|
||||
nrpe_setup.write()
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
hooks.execute(sys.argv)
|
||||
|
|
Loading…
Reference in New Issue