当前位置: 首页>>代码示例>>Python>>正文


Python NSCP.Registry类代码示例

本文整理汇总了Python中NSCP.Registry的典型用法代码示例。如果您正苦于以下问题:Python Registry类的具体用法?Python Registry怎么用?Python Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Registry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init

	def init(self, plugin_id, prefix):
		self.key = '_%stest_command'%prefix
		self.reg = Registry.get(plugin_id)
		self.core = Core.get(plugin_id)
		self.conf = Settings.get(plugin_id)

		None
开发者ID:Vilse1202,项目名称:nscp,代码行数:7,代码来源:test_python.py

示例2: setup

	def setup(self, plugin_id, prefix):
		self.reg = Registry.get(plugin_id)
		self.reg.simple_function(self.command, StressTest.random_check_handler, 'This is a simple noop command')
		self.reg.simple_subscription(self.python_channel, StressTest.on_stress_handler)
		conf = Settings.get()
		conf.set_string(self.sched_base_path, 'threads', '%d'%use_threads)
		core.reload(self.sched_alias)
开发者ID:Vilse1202,项目名称:nscp,代码行数:7,代码来源:test_stress.py

示例3: init

def init(pid, plugin_alias, script_alias):
    global world_status, plugin_id
    plugin_id = pid

    conf = Settings.get(plugin_id)
    conf.register_path('/settings/cool script', "Sample script config", "This is a sample script which demonstrates how to interact with NSClient++")
    conf.register_key('/settings/cool script', 'world', 'string', "A key", "Never ever change this key: or the world will break", "safe")

    world_status = conf.get_string('/settings/cool script', 'world', 'true')
    if world_status != 'safe':
        log('My god: its full of stars: %s'%world_status)
    
    log('Adding a simple function/cmd line')
    reg = Registry.get(plugin_id)
    reg.simple_cmdline('help', get_help)

    reg.simple_function('check_world', check_world, 'Check if the world is safe')
    reg.simple_function('break_world', break_world, 'Break the world')
    reg.simple_function('fix_world', fix_world, 'Fix the world')
    reg.simple_function('save_world', save_world, 'Save the world')
    
    reg.simple_function('show_metrics', fun_show_metrics, 'Enable displaying metrics or not')

    reg.submit_metrics(submit_metrics)
    reg.fetch_metrics(fetch_metrics)
开发者ID:Fox-Alpha,项目名称:nscp,代码行数:25,代码来源:sample.py

示例4: setup

	def setup(self, plugin_id, prefix):
		self.reg = Registry.get(plugin_id)
		self.temp_path = core.expand_path('${temp}')
		log('Temp: %s'%self.temp_path)
		self.work_path = os.path.join(self.temp_path, '%s'%uuid.uuid4())
		log('Work: %s'%self.work_path)
		os.mkdir(self.work_path)
开发者ID:Vilse1202,项目名称:nscp,代码行数:7,代码来源:test_w32_file.py

示例5: __init__

	def __init__(self, plugin_id, plugin_alias, script_alias):
		self.plugin_id = plugin_id
		self.plugin_alias = plugin_alias
		self.script_alias = script_alias
		self.conf = Settings.get(self.plugin_id)
		self.registry = Registry.get(self.plugin_id)
		self.core = Core.get(self.plugin_id)
开发者ID:borgified,项目名称:nscp,代码行数:7,代码来源:docs.py

示例6: init

def init(pid, plugin_alias, script_alias):
    global server_name, plugin_id, icinga_url, icinga_auth
    plugin_id = pid
    server_name = socket.gethostname()

    reg = Registry.get(plugin_id)
    core = Core.get(plugin_id)
    reg.event('name', on_event)
    reg.submit_metrics(submit_metrics)
    
    conf = Settings.get(plugin_id)
    conf.register_key('/settings/icinga', 'url', 'string', "The URL of the icinga API port", "The icinga base for the api: https://icinga.com:5665", "")
    conf.register_key('/settings/icinga', 'user', 'string', "The user id of the icinga API", "The icinga API user: root", "")
    conf.register_key('/settings/icinga', 'password', 'string', "The user id of the icinga API", "The icinga API password: hopefully not icinga", "")
    
    icinga_url = conf.get_string('/settings/icinga', 'url', '')
    usr = conf.get_string('/settings/icinga', 'user', '')
    pwd = conf.get_string('/settings/icinga', 'password', '')
    icinga_auth = requests.auth.HTTPBasicAuth(usr, pwd)
    
    (res, os_version, perf) = core.simple_query('check_os_version', ["top-syntax=${list}"])
    add_host(server_name, socket.gethostbyname(server_name), os_version)
    add_nrpe_service(server_name, 'check_cpu', 'check_cpu', 'CPU Load')
    add_nrpe_service(server_name, 'check_memory', 'check_memory', 'CPU Load')

    for k in ['check_cpu', 'check_memory']:
        conf.set_string('/settings/scheduler/schedules/%s'%k, 'command', k)
        conf.set_string('/settings/scheduler/schedules/%s'%k, 'channel', 'icinga_passive')
        conf.set_string('/settings/scheduler/schedules/%s'%k, 'interval', '30s')
    core.load_module('Scheduler', '')

    reg.simple_subscription('icinga_passive', icinga_passive)
开发者ID:mickem,项目名称:nscp,代码行数:32,代码来源:icinga.py

示例7: setup

 def setup(self, plugin_id, prefix):
     self.reg = Registry.get(plugin_id)
     self.temp_path = self.core.expand_path("${temp}")
     log("Temp: %s" % self.temp_path)
     self.work_path = os.path.join(self.temp_path, "%s.txt" % uuid.uuid4())
     log("Work: %s" % self.work_path)
     create_test_data(self.work_path)
开发者ID:Fox-Alpha,项目名称:nscp,代码行数:7,代码来源:test_log_file.py

示例8: setup

	def setup(self, plugin_id, prefix):
		self.reg = Registry.get(plugin_id)
		self.temp_path = self.core.expand_path('${temp}')
		log('Temp: %s'%self.temp_path)
		self.work_path = os.path.join(self.temp_path, '%s.txt'%uuid.uuid4())
		log('Work: %s'%self.work_path)
		create_test_data(self.work_path)
开发者ID:0000-bigtree,项目名称:nscp,代码行数:7,代码来源:test_log_file.py

示例9: setup

	def setup(self, plugin_id, prefix):
		log('Loading Python unit tests')
		self.key = '_%stest_command'%prefix
		self.reg = Registry.get(plugin_id)
		self.reg.simple_function('py_stress_noop', PythonTest.noop_handler, 'This is a simple noop command')
		self.reg.simple_subscription('py_stress_test', PythonTest.stress_handler)
		conf = Settings.get()
		conf.set_string('/settings/test_scheduler', 'threads', '50')
		core.reload('test_scheduler')
开发者ID:jkells,项目名称:nscp,代码行数:9,代码来源:test_python.py

示例10: __init__

 def __init__(self, plugin_id, plugin_alias, script_alias):
     self.plugin_id = plugin_id
     self.plugin_alias = plugin_alias
     self.script_alias = script_alias
     self.conf = Settings.get(self.plugin_id)
     self.registry = Registry.get(self.plugin_id)
     self.core = Core.get(self.plugin_id)
     self.command_cache = {}
     self.folder = None
开发者ID:wyrover,项目名称:nscp,代码行数:9,代码来源:docs.py

示例11: create_test_manager

def create_test_manager(plugin_id=0, plugin_alias="", script_alias=""):
    global test_manager
    if not test_manager:
        test_manager = TestManager(plugin_id, plugin_alias, script_alias)

        reg = Registry.get(plugin_id)

        reg.simple_cmdline("help", display_help)
        reg.simple_cmdline("install_python_test", install_tests)
        reg.simple_cmdline("run_python_test", run_tests)

        reg.simple_function("py_unittest", run_tests, "Run python unit test suite")

    return test_manager
开发者ID:jkells,项目名称:nscp,代码行数:14,代码来源:test_helper.py

示例12: create_test_manager

def create_test_manager(plugin_id = 0, plugin_alias = '', script_alias = ''):
	global test_manager
	if not test_manager:
		test_manager = TestManager(plugin_id, plugin_alias, script_alias)
		
		reg = Registry.get(plugin_id)
		
		reg.simple_cmdline('help', display_help)
		reg.simple_cmdline('install_python_test', install_tests)
		reg.simple_cmdline('run_python_test', run_tests)

		reg.simple_function('py_unittest', run_tests, 'Run python unit test suite')
	
	return test_manager
开发者ID:Fox-Alpha,项目名称:nscp,代码行数:14,代码来源:test_helper.py

示例13: create_test_manager

def create_test_manager(plugin_id = 0, plugin_alias = '', script_alias = ''):
    global test_manager
    if not test_manager:
        test_manager = TestManager(plugin_id, plugin_alias, script_alias)
        
        reg = Registry.get(plugin_id)
        
        reg.simple_cmdline('help', display_help)
        reg.simple_cmdline('install_python_test', install_tests)
        reg.simple_cmdline('run_python_test', run_tests)

        reg.simple_function('py_unittest', run_tests, 'Run python unit test suite')
        reg.simple_function('py_unittest_show_ok', set_show_ok, 'Set verbouse log')
        reg.simple_function('py_unittest_add_case', add_case, 'Set which cases to run')
    
    return test_manager
开发者ID:mickem,项目名称:nscp,代码行数:16,代码来源:test_helper.py

示例14: init

def init(pid, plugin_alias, script_alias):
	global prefix
	global plugin_id
	plugin_id = pid
	if script_alias:
		prefix = '%s_'%script_alias

	conf = Settings.get()
	#val = conf.get_string('/modules', 'PythonScript', 'foo')

	#log('Got it: %s'%val)
	
	log('Testing to register a function')
	reg = Registry.get(plugin_id)
	
	reg.simple_cmdline('help', get_help)
	reg.simple_cmdline('install_python_test', install_test)

	reg.simple_function('%stest'%prefix, test, 'Run python unittest')
开发者ID:0000-bigtree,项目名称:nscp,代码行数:19,代码来源:sample.py

示例15: setup

	def setup(self, plugin_id, prefix):
		self.reg = Registry.get(plugin_id)
开发者ID:Vilse1202,项目名称:nscp,代码行数:2,代码来源:test_w32_wmi.py


注:本文中的NSCP.Registry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。