• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python NSCP.Registry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: init

 def init(self, plugin_id, prefix):
     self.plugin_id = plugin_id
     self.reg = Registry.get(plugin_id)
     self.core = Core.get(plugin_id)
     self.conf = Settings.get(plugin_id)
开发者ID:mickem,项目名称:nscp,代码行数:5,代码来源:test_w32_schetask.py


示例17: setup

	def setup(self, plugin_id, prefix):
		self.key = '_%stest_command'%prefix
		self.reg = Registry.get(plugin_id)
		self.reg.simple_subscription('nsca_test_inbox', NSCAServerTest.simple_inbox_handler)
		self.reg.subscription('nsca_test_inbox', NSCAServerTest.inbox_handler)
开发者ID:0000-bigtree,项目名称:nscp,代码行数:5,代码来源:test_nsca.py


示例18: setup

	def setup(self, plugin_id, prefix):
		self.key = '_%stest_command'%prefix
		self.reg = Registry.get(plugin_id)
		self.reg.simple_function('%s_001'%self.key, CommandTest.test_command_handler_001, 'This is a sample command')
开发者ID:0000-bigtree,项目名称:nscp,代码行数:4,代码来源:sample.py


示例19: setup

	def setup(self, plugin_id, prefix):
		self.key = '_%stest_command'%prefix
		self.reg = Registry.get(plugin_id)
开发者ID:dataliven,项目名称:nscp,代码行数:3,代码来源:test_external_script.py


示例20: setup

	def setup(self, plugin_id, prefix):
		self.channel = '_%stest_channel'%prefix
		self.reg = Registry.get(plugin_id)
		self.reg.simple_subscription(self.channel, ChannelTest.test_submission_handler_001)
		self.reg.simple_function(self.channel, ChannelTest.test_command_handler_001, 'This is a sample command')
开发者ID:0000-bigtree,项目名称:nscp,代码行数:5,代码来源:test_pb.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python NSCP.Settings类代码示例发布时间:2022-05-24
下一篇:
Python NSCP.Core类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap