本文整理汇总了Python中charmhelpers.contrib.charmsupport.nrpe.get_nagios_unit_name方法的典型用法代码示例。如果您正苦于以下问题:Python nrpe.get_nagios_unit_name方法的具体用法?Python nrpe.get_nagios_unit_name怎么用?Python nrpe.get_nagios_unit_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.contrib.charmsupport.nrpe
的用法示例。
在下文中一共展示了nrpe.get_nagios_unit_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
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.copy_nrpe_checks()
nrpe.add_init_service_checks(nrpe_setup, services(), current_unit)
nrpe.add_haproxy_checks(nrpe_setup, current_unit)
api_port = determine_api_port(config('bind-port'),
singlenode_mode=True)
nrpe_setup.add_check(
shortname="swift-proxy-healthcheck",
description="Check Swift Proxy Healthcheck",
check_cmd="/usr/lib/nagios/plugins/check_http \
-I localhost -u /healthcheck -p {} \
-e \"OK\"".format(api_port)
)
nrpe_setup.write()
示例2: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
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.copy_nrpe_checks()
nrpe.add_init_service_checks(nrpe_setup, services(), current_unit)
nrpe.add_haproxy_checks(nrpe_setup, current_unit)
conf = nrpe_setup.config
check_http_params = conf.get('nagios_check_http_params')
if check_http_params:
nrpe_setup.add_check(
shortname='vhost',
description='Check Virtual Host {%s}' % current_unit,
check_cmd='check_http %s' % check_http_params
)
nrpe_setup.write()
示例3: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
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.copy_nrpe_checks()
_services = []
for service in services():
if service.startswith('snap.'):
service = service.split('.')[1]
_services.append(service)
nrpe.add_init_service_checks(nrpe_setup, _services, current_unit)
nrpe.add_haproxy_checks(nrpe_setup, current_unit)
nrpe_setup.write()
示例4: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
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.copy_nrpe_checks()
nrpe.add_init_service_checks(nrpe_setup, services(), current_unit)
nrpe.add_haproxy_checks(nrpe_setup, current_unit)
nrpe_setup.write()
示例5: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
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)
monitored_services = services()
try:
# qemu-kvm is a one-shot service
monitored_services.remove('qemu-kvm')
except ValueError:
pass
nrpe.add_init_service_checks(nrpe_setup, monitored_services, current_unit)
nrpe_setup.write()
示例6: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
def update_nrpe_config():
# python-dbus is used by check_upstart_job
apt_install('python3-dbus')
hostname = nrpe.get_nagios_hostname()
current_unit = nrpe.get_nagios_unit_name()
nrpe_setup = nrpe.NRPE(hostname=hostname)
nrpe_setup.add_check(
shortname='ceph-osd',
description='process check {%s}' % current_unit,
check_cmd=('/bin/cat /var/lib/ceph/osd/ceph-*/whoami |'
'xargs [email protected] status ceph-osd id=@ && exit 0 || exit 2')
)
nrpe_setup.write()
示例7: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
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.copy_nrpe_checks()
nrpe.add_init_service_checks(nrpe_setup, services(), current_unit)
nrpe.add_haproxy_checks(nrpe_setup, current_unit)
nrpe_setup.write()
示例8: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
def update_nrpe_config():
# python-dbus is used by check_upstart_job
apt_install(['python-dbus', 'lockfile-progs'])
log('Refreshing nagios checks')
if os.path.isdir(NAGIOS_PLUGINS):
rsync(os.path.join(os.getenv('CHARM_DIR'), 'files', 'nagios',
'check_ceph_status.py'),
os.path.join(NAGIOS_PLUGINS, 'check_ceph_status.py'))
script = os.path.join(SCRIPTS_DIR, 'collect_ceph_status.sh')
rsync(os.path.join(os.getenv('CHARM_DIR'), 'files',
'nagios', 'collect_ceph_status.sh'),
script)
cronjob = "{} root {}\n".format('*/5 * * * *', script)
write_file(STATUS_CRONFILE, cronjob)
# Find out if nrpe set nagios_hostname
hostname = nrpe.get_nagios_hostname()
current_unit = nrpe.get_nagios_unit_name()
nrpe_setup = nrpe.NRPE(hostname=hostname)
check_cmd = 'check_ceph_status.py -f {} --degraded_thresh {}' \
' --misplaced_thresh {}' \
' --recovery_rate {}'.format(STATUS_FILE,
config('nagios_degraded_thresh'),
config('nagios_misplaced_thresh'),
config('nagios_recovery_rate'))
if config('nagios_ignore_nodeepscub'):
check_cmd = check_cmd + ' --ignore_nodeepscrub'
nrpe_setup.add_check(
shortname="ceph",
description='Check Ceph health {{{}}}'.format(current_unit),
check_cmd=check_cmd
)
nrpe_setup.write()
示例9: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
def update_nrpe_config():
# python-dbus is used by check_upstart_job
# lockfile-create is used by collect_ceph_status
apt_install(['python-dbus', 'lockfile-progs'])
log('Refreshing nagios checks')
if os.path.isdir(NAGIOS_PLUGINS):
rsync(os.path.join(os.getenv('CHARM_DIR'), 'files', 'nagios',
'check_ceph_status.py'),
os.path.join(NAGIOS_PLUGINS, 'check_ceph_status.py'))
script = os.path.join(SCRIPTS_DIR, 'collect_ceph_status.sh')
rsync(os.path.join(os.getenv('CHARM_DIR'), 'files',
'nagios', 'collect_ceph_status.sh'),
script)
cronjob = "{} root {}\n".format('*/5 * * * *', script)
write_file(STATUS_CRONFILE, cronjob)
# Find out if nrpe set nagios_hostname
hostname = nrpe.get_nagios_hostname()
current_unit = nrpe.get_nagios_unit_name()
nrpe_setup = nrpe.NRPE(hostname=hostname)
nrpe_setup.add_check(
shortname="ceph",
description='Check Ceph health {%s}' % current_unit,
check_cmd='check_ceph_status.py -f {}'.format(STATUS_FILE)
)
nrpe_setup.write()
示例10: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
def update_nrpe_config(svc):
# python-dbus is used by check_upstart_job
fetch.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, [SVCNAME], current_unit)
nrpe_setup.write()
示例11: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
def update_nrpe_config():
# python-dbus is used by check_upstart_job
apt_install('python-dbus')
log('Refreshing nrpe checks')
if not os.path.exists(NAGIOS_PLUGINS):
mkpath(NAGIOS_PLUGINS)
rsync(os.path.join(os.getenv('CHARM_DIR'), 'files', 'nrpe-external-master',
'check_swift_storage.py'),
os.path.join(NAGIOS_PLUGINS, 'check_swift_storage.py'))
rsync(os.path.join(os.getenv('CHARM_DIR'), 'files', 'nrpe-external-master',
'check_swift_service'),
os.path.join(NAGIOS_PLUGINS, 'check_swift_service'))
rsync(os.path.join(os.getenv('CHARM_DIR'), 'files', 'sudo',
'swift-storage'),
os.path.join(SUDOERS_D, 'swift-storage'))
# Find out if nrpe set nagios_hostname
hostname = nrpe.get_nagios_hostname()
current_unit = nrpe.get_nagios_unit_name()
nrpe_setup = nrpe.NRPE(hostname=hostname)
# check the rings and replication
nrpe_setup.add_check(
shortname='swift_storage',
description='Check swift storage ring hashes and replication'
' {%s}' % current_unit,
check_cmd='check_swift_storage.py {}'.format(
config('nagios-check-params'))
)
nrpe.add_init_service_checks(nrpe_setup, SWIFT_SVCS, current_unit)
nrpe_setup.write()
示例12: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
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()
示例13: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
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, services(), current_unit)
nrpe_setup.write()
示例14: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
def update_nrpe_config(unused=None):
# List of systemd services that will be checked
services = ('snap.etcd.etcd',)
# The current nrpe-external-master interface doesn't handle a lot of logic,
# use the charm-helpers code for now.
hostname = nrpe.get_nagios_hostname()
current_unit = nrpe.get_nagios_unit_name()
nrpe_setup = nrpe.NRPE(hostname=hostname, primary=False)
nrpe.add_init_service_checks(nrpe_setup, services, current_unit)
nrpe_setup.write()
示例15: test_get_nagios_unit_name
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import get_nagios_unit_name [as 别名]
def test_get_nagios_unit_name(self):
rel_info = {
'nagios_hostname': 'bob-openstack-dashboard-0',
'private-address': '10.5.3.103',
'__unit__': u'dashboard-nrpe/1',
'__relid__': u'nrpe-external-master:2',
'nagios_host_context': u'bob',
}
self.patched['relations_of_type'].return_value = [rel_info]
self.assertEqual(nrpe.get_nagios_unit_name(), 'bob:testunit')