charmhelpers.contrib.charmsupport package¶
charmhelpers.contrib.charmsupport.nrpe module¶
Compatibility with the nrpe-external-master charm
-
class
charmhelpers.contrib.charmsupport.nrpe.
Check
(shortname, description, check_cmd)¶ Bases:
object
-
remove
(hostname)¶
-
run
()¶
-
service_template
= '\n#---------------------------------------------------\n# This file is Juju managed\n#---------------------------------------------------\ndefine service {{\n use active-service\n host_name {nagios_hostname}\n service_description {nagios_hostname}[{shortname}] {description}\n check_command check_nrpe!{command}\n servicegroups {nagios_servicegroup}\n}}\n'¶
-
shortname_re
= '[A-Za-z0-9-_.@]+$'¶
-
write
(nagios_context, hostname, nagios_servicegroups)¶
-
write_service_config
(nagios_context, hostname, nagios_servicegroups)¶
-
-
exception
charmhelpers.contrib.charmsupport.nrpe.
CheckException
¶ Bases:
Exception
-
class
charmhelpers.contrib.charmsupport.nrpe.
NRPE
(hostname=None, primary=True)¶ Bases:
object
-
add_check
(*args, **kwargs)¶
-
homedir
= '/var/lib/nagios'¶
-
nagios_exportdir
= '/var/lib/nagios/export'¶
-
nagios_logdir
= '/var/log/nagios'¶
-
nrpe_confdir
= '/etc/nagios/nrpe.d'¶
-
remove_check
(*args, **kwargs)¶
-
write
()¶
-
-
charmhelpers.contrib.charmsupport.nrpe.
add_haproxy_checks
(nrpe, unit_name)¶ Add checks for each service in list
Parameters: - nrpe (NRPE) – NRPE object to add check to
- unit_name (str) – Unit name to use in check description
-
charmhelpers.contrib.charmsupport.nrpe.
add_init_service_checks
(nrpe, services, unit_name, immediate_check=True)¶ Add checks for each service in list
Parameters: - nrpe (NRPE) – NRPE object to add check to
- services (list) – List of services to check
- unit_name (str) – Unit name to use in check description
- immediate_check (bool) – For sysv init, run the service check immediately
-
charmhelpers.contrib.charmsupport.nrpe.
copy_nrpe_checks
(nrpe_files_dir=None)¶ Copy the nrpe checks into place
-
charmhelpers.contrib.charmsupport.nrpe.
get_nagios_hostcontext
(relation_name='nrpe-external-master')¶ Query relation with nrpe subordinate, return the nagios_host_context
Parameters: relation_name (str) – Name of relation nrpe sub joined to
-
charmhelpers.contrib.charmsupport.nrpe.
get_nagios_hostname
(relation_name='nrpe-external-master')¶ Query relation with nrpe subordinate, return the nagios_hostname
Parameters: relation_name (str) – Name of relation nrpe sub joined to
-
charmhelpers.contrib.charmsupport.nrpe.
get_nagios_unit_name
(relation_name='nrpe-external-master')¶ Return the nagios unit name prepended with host_context if needed
Parameters: relation_name (str) – Name of relation nrpe sub joined to
charmhelpers.contrib.charmsupport.volumes module¶
Functions for managing volumes in juju units. One volume is supported per unit. Subordinates may have their own storage, provided it is on its own partition.
Configuration stanzas:
volume-ephemeral:
type: boolean
default: true
description: >
If false, a volume is mounted as sepecified in "volume-map"
If true, ephemeral storage will be used, meaning that log data
will only exist as long as the machine. YOU HAVE BEEN WARNED.
volume-map:
type: string
default: {}
description: >
YAML map of units to device names, e.g:
"{ rsyslog/0: /dev/vdb, rsyslog/1: /dev/vdb }"
Service units will raise a configure-error if volume-ephemeral
is 'true' and no volume-map value is set. Use 'juju set' to set a
value and 'juju resolved' to complete configuration.
Usage:
from charmsupport.volumes import configure_volume, VolumeConfigurationError
from charmsupport.hookenv import log, ERROR
def post_mount_hook():
stop_service('myservice')
def post_mount_hook():
start_service('myservice')
if __name__ == '__main__':
try:
configure_volume(before_change=pre_mount_hook,
after_change=post_mount_hook)
except VolumeConfigurationError:
log('Storage could not be configured', ERROR)
-
exception
charmhelpers.contrib.charmsupport.volumes.
VolumeConfigurationError
¶ Bases:
Exception
Volume configuration data is missing or invalid
-
charmhelpers.contrib.charmsupport.volumes.
configure_volume
(before_change=<function <lambda>>, after_change=<function <lambda>>)¶ Set up storage (or don’t) according to the charm’s volume configuration. Returns the mount point or “ephemeral”. before_change and after_change are optional functions to be called if the volume configuration changes.
-
charmhelpers.contrib.charmsupport.volumes.
get_config
()¶ Gather and sanity-check volume configuration data
-
charmhelpers.contrib.charmsupport.volumes.
managed_mounts
()¶ List of all mounted managed volumes
-
charmhelpers.contrib.charmsupport.volumes.
mount_volume
(config)¶
-
charmhelpers.contrib.charmsupport.volumes.
unmount_volume
(config)¶