當前位置: 首頁>>代碼示例>>Python>>正文


Python nrpe.get_nagios_unit_name方法代碼示例

本文整理匯總了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() 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:21,代碼來源:swift_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-openstack-dashboard,代碼行數:20,代碼來源:horizon_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-keystone,代碼行數:17,代碼來源:keystone_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-nova-cloud-controller,代碼行數:12,代碼來源:nova_cc_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-nova-compute,代碼行數:16,代碼來源:nova_compute_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-ceph-osd,代碼行數:15,代碼來源:ceph_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-neutron-api,代碼行數:13,代碼來源:neutron_api_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-ceph-mon,代碼行數:36,代碼來源:ceph_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-ceph,代碼行數:29,代碼來源:ceph_hooks.py

示例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() 
開發者ID:tasdomas,項目名稱:juju-charm-prometheus,代碼行數:10,代碼來源:prometheus.py

示例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() 
開發者ID:openstack,項目名稱:charm-swift-storage,代碼行數:33,代碼來源:swift_storage_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-percona-cluster,代碼行數:15,代碼來源:percona_hooks.py

示例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() 
開發者ID:openstack,項目名稱:charm-ceilometer-agent,代碼行數:10,代碼來源:ceilometer_hooks.py

示例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() 
開發者ID:juju-solutions,項目名稱:layer-etcd,代碼行數:13,代碼來源:etcd.py

示例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') 
開發者ID:juju,項目名稱:charm-helpers,代碼行數:12,代碼來源:test_nrpe.py


注:本文中的charmhelpers.contrib.charmsupport.nrpe.get_nagios_unit_name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。