本文整理汇总了Python中charmhelpers.contrib.charmsupport.nrpe.add_init_service_checks方法的典型用法代码示例。如果您正苦于以下问题:Python nrpe.add_init_service_checks方法的具体用法?Python nrpe.add_init_service_checks怎么用?Python nrpe.add_init_service_checks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类charmhelpers.contrib.charmsupport.nrpe
的用法示例。
在下文中一共展示了nrpe.add_init_service_checks方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import add_init_service_checks [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 add_init_service_checks [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 add_init_service_checks [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 add_init_service_checks [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 add_init_service_checks [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 add_init_service_checks [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()
示例7: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import add_init_service_checks [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()
示例8: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import add_init_service_checks [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()
示例9: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import add_init_service_checks [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()
示例10: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import add_init_service_checks [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()
示例11: update_nrpe_config
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import add_init_service_checks [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()
示例12: test_add_init_service_checks
# 需要导入模块: from charmhelpers.contrib.charmsupport import nrpe [as 别名]
# 或者: from charmhelpers.contrib.charmsupport.nrpe import add_init_service_checks [as 别名]
def test_add_init_service_checks(self, mock_isdir):
def _exists(init_file):
files = ['/etc/init/apache2.conf',
'/usr/lib/nagios/plugins/check_upstart_job',
'/etc/init.d/haproxy',
'/usr/lib/nagios/plugins/check_status_file.py',
'/etc/cron.d/nagios-service-check-haproxy',
'/var/lib/nagios/service-check-haproxy.txt',
'/usr/lib/nagios/plugins/check_systemd.py'
]
return init_file in files
self.patched['exists'].side_effect = _exists
# Test without systemd and /var/lib/nagios does not exist
self.patched['init_is_systemd'].return_value = False
mock_isdir.return_value = False
bill = nrpe.NRPE()
services = ['apache2', 'haproxy']
nrpe.add_init_service_checks(bill, services, 'testunit')
mock_isdir.assert_called_with('/var/lib/nagios')
self.patched['call'].assert_not_called()
expect_cmds = {
'apache2': '/usr/lib/nagios/plugins/check_upstart_job apache2',
'haproxy': '/usr/lib/nagios/plugins/check_status_file.py -f '
'/var/lib/nagios/service-check-haproxy.txt',
}
self.assertEqual(bill.checks[0].shortname, 'apache2')
self.assertEqual(bill.checks[0].check_cmd, expect_cmds['apache2'])
self.assertEqual(bill.checks[1].shortname, 'haproxy')
self.assertEqual(bill.checks[1].check_cmd, expect_cmds['haproxy'])
# without systemd and /var/lib/nagios does exist
mock_isdir.return_value = True
f = MagicMock()
self.patched['open'].return_value = f
bill = nrpe.NRPE()
services = ['apache2', 'haproxy']
nrpe.add_init_service_checks(bill, services, 'testunit')
mock_isdir.assert_called_with('/var/lib/nagios')
self.patched['call'].assert_called_with(
['/usr/local/lib/nagios/plugins/check_exit_status.pl', '-e', '-s',
'/etc/init.d/haproxy', 'status'], stdout=f,
stderr=subprocess.STDOUT)
# Test regular services and snap services with systemd
services = ['apache2', 'haproxy', 'snap.test.test']
self.patched['init_is_systemd'].return_value = True
nrpe.add_init_service_checks(bill, services, 'testunit')
expect_cmds = {
'apache2': '/usr/lib/nagios/plugins/check_systemd.py apache2',
'haproxy': '/usr/lib/nagios/plugins/check_systemd.py haproxy',
'snap.test.test': '/usr/lib/nagios/plugins/check_systemd.py snap.test.test',
}
self.assertEqual(bill.checks[2].shortname, 'apache2')
self.assertEqual(bill.checks[2].check_cmd, expect_cmds['apache2'])
self.assertEqual(bill.checks[3].shortname, 'haproxy')
self.assertEqual(bill.checks[3].check_cmd, expect_cmds['haproxy'])
self.assertEqual(bill.checks[4].shortname, 'snap.test.test')
self.assertEqual(bill.checks[4].check_cmd, expect_cmds['snap.test.test'])