本文整理汇总了Python中NSCP.Settings类的典型用法代码示例。如果您正苦于以下问题:Python Settings类的具体用法?Python Settings怎么用?Python Settings使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Settings类的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: 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
示例3: install
def install(self, arguments):
conf = Settings.get()
conf.set_string('/modules', 'pytest', 'PythonScript')
conf.set_string('/settings/pytest/scripts', 'test_pb', 'test_pb.py')
conf.save()
开发者ID:0000-bigtree,项目名称:nscp,代码行数:7,代码来源:test_pb.py
示例4: __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
示例5: test_one_crypto
def test_one_crypto(self, crypto, length=512):
conf = Settings.get()
conf.set_string('/settings/NSCA/test_nsca_server', 'encryption', '%s'%crypto)
conf.set_string('/settings/NSCA/test_nsca_server', 'password', 'pwd-%s'%crypto)
conf.set_int('/settings/NSCA/test_nsca_server', 'payload length', length)
core.reload('test_nsca_server')
conf.set_string('/settings/NSCA/test_nsca_client/targets/default', 'address', 'nsca://127.0.0.1:35667')
conf.set_string('/settings/NSCA/test_nsca_client/targets/default', 'encryption', '%s'%crypto)
conf.set_string('/settings/NSCA/test_nsca_client/targets/default', 'password', 'default-%s'%crypto)
conf.set_int('/settings/NSCA/test_nsca_client/targets/default', 'payload length', length*3)
conf.set_string('/settings/NSCA/test_nsca_client/targets/invalid', 'address', 'nsca://127.0.0.1:25667')
conf.set_string('/settings/NSCA/test_nsca_client/targets/invalid', 'encryption', 'none')
conf.set_string('/settings/NSCA/test_nsca_client/targets/invalid', 'password', 'invalid-%s'%crypto)
conf.set_int('/settings/NSCA/test_nsca_client/targets/invalid', 'payload length', length*2)
conf.set_string('/settings/NSCA/test_nsca_client/targets/valid', 'address', 'nsca://127.0.0.1:15667')
conf.set_string('/settings/NSCA/test_nsca_client/targets/valid', 'encryption', '%s'%crypto)
conf.set_string('/settings/NSCA/test_nsca_client/targets/valid', 'password', 'pwd-%s'%crypto)
conf.set_int('/settings/NSCA/test_nsca_client/targets/valid', 'payload length', length)
core.reload('test_nsca_client')
result = TestResult('Testing: %s/%d'%(crypto, length))
result.add_message(isOpen('localhost', 15667), 'Checking that port is open')
for target in ['valid', 'test_rp', 'invalid']:
result.add(self.test_one_crypto_full(crypto, status.UNKNOWN, 'unknown', target, length))
result.add(self.test_one_crypto_full(crypto, status.OK, 'ok', target, length))
result.add(self.test_one_crypto_full(crypto, status.WARNING, 'warn', target, length))
result.add(self.test_one_crypto_full(crypto, status.CRITICAL, 'crit', target, length))
return result
开发者ID:jkells,项目名称:nscp,代码行数:33,代码来源:test_nsca.py
示例6: do_one_test
def do_one_test(self, ssl=True, length=1024):
conf = Settings.get()
conf.set_int('/settings/NRPE/test_nrpe_server', 'payload length', length)
conf.set_bool('/settings/NRPE/test_nrpe_server', 'use ssl', ssl)
conf.set_bool('/settings/NRPE/test_nrpe_server', 'allow arguments', True)
# TODO: conf.set_string('/settings/NRPE/test_nrpe_server', 'certificate', ssl)
core.reload('test_nrpe_server')
conf.set_string('/settings/NRPE/test_nrpe_client/targets/default', 'address', 'nrpe://127.0.0.1:35666')
conf.set_bool('/settings/NRPE/test_nrpe_client/targets/default', 'use ssl', not ssl)
conf.set_int('/settings/NRPE/test_nrpe_client/targets/default', 'payload length', length*3)
conf.set_string('/settings/NRPE/test_nrpe_client/targets/invalid', 'address', 'nrpe://127.0.0.1:25666')
conf.set_bool('/settings/NRPE/test_nrpe_client/targets/invalid', 'use ssl', not ssl)
conf.set_int('/settings/NRPE/test_nrpe_client/targets/invalid', 'payload length', length*2)
conf.set_string('/settings/NRPE/test_nrpe_client/targets/valid', 'address', 'nrpe://127.0.0.1:15666')
conf.set_bool('/settings/NRPE/test_nrpe_client/targets/valid', 'use ssl', ssl)
conf.set_int('/settings/NRPE/test_nrpe_client/targets/valid', 'payload length', length)
core.reload('test_nrpe_client')
result = TestResult()
result.add_message(isOpen('127.0.0.1', 15666), 'Checking that port is open (server is up)')
result.add(self.test_one(ssl, length, state = status.UNKNOWN, tag = 'unknown'))
result.add(self.test_one(ssl, length, state = status.OK, tag = 'ok'))
result.add(self.test_one(ssl, length, state = status.WARNING, tag = 'warn'))
result.add(self.test_one(ssl, length, state = status.CRITICAL, tag = 'crit'))
return result
开发者ID:jkells,项目名称:nscp,代码行数:28,代码来源:test_nrpe.py
示例7: 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
示例8: 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
示例9: install
def install(self, arguments):
conf = Settings.get()
conf.set_string('/modules', 'pytest', 'PythonScript')
fn = os.path.basename(self.__source__)
(sn, ext) = os.path.splitext(fn)
conf.register_key('/settings/pytest/scripts', sn, 'string', 'UNIT TEST SCRIPT: %s'%self.title(), 'A script for running unittests for: %s'%self.desc(), fn)
conf.set_string('/settings/pytest/scripts', sn, fn)
conf.save()
开发者ID:Fox-Alpha,项目名称:nscp,代码行数:9,代码来源:test_helper.py
示例10: 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
示例11: __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
示例12: install
def install(self, arguments):
global is_windows, route_via_python, route_via_nsca, use_threads
conf = Settings.get()
# Configure required modules
if route_via_python:
conf.set_string('/modules', 'pytest', 'PythonScript')
conf.set_string('/modules', self.sched_alias, 'Scheduler')
if is_windows:
conf.set_string('/modules', 'CheckSystem', 'enabled')
conf.set_string('/modules', 'CheckHelpers', 'enabled')
if route_via_nsca:
conf.set_string('/modules', self.nsca_server_alias, 'NSCAServer')
conf.set_string('/modules', self.nsca_client_alias, 'NSCAClient')
# Configure NSCA Server
conf.set_string('/settings/NSCA/%s'%self.nsca_server_alias, 'port', '%d'%self.port)
conf.set_string('/settings/NSCA/%s'%self.nsca_server_alias, 'inbox', self.python_channel)
conf.set_string('/settings/NSCA/%s'%self.nsca_server_alias, 'encryption', 'aes')
# Configure NSCA Client
conf.set_string('/settings/NSCA/%s/targets/default'%self.nsca_client_alias, 'address', 'nsca://127.0.0.1:%d'%self.port)
conf.set_string('/settings/NSCA/%s/targets/default'%self.nsca_client_alias, 'encryption', 'aes')
conf.set_string('/settings/NSCA/%s'%self.nsca_client_alias, 'channel', self.nsca_channel)
# Configure python
if route_via_python:
conf.set_string('/settings/pytest/scripts', 'test_stress', 'test_stress.py')
# Configure Scheduler
if route_via_python:
conf.set_string(self.sched_base_path, 'threads', '0')
else:
conf.set_string(self.sched_base_path, 'threads', '50')
default_path = '%s/default'%self.sched_base_path
if route_via_nsca:
conf.set_string(default_path, 'channel', self.nsca_channel)
else:
conf.set_string(default_path, 'channel', self.python_channel)
conf.set_string(default_path, 'alias', 'stress')
#conf.set_string(default_path, 'target', 'stress_001')
use_command = self.command
if not route_via_python:
use_command = 'CheckOK'
conf.set_string(default_path, 'command', use_command)
conf.set_string(default_path, 'interval', '5s')
for i in range(1, (check_per_second*5)+1):
alias = 'stress_python_%i'%i
conf.set_string('%s/schedules'%(self.sched_base_path), alias, use_command)
conf.save()
开发者ID:Vilse1202,项目名称:nscp,代码行数:56,代码来源:test_stress.py
示例13: install_test
def install_test(arguments):
log('-+---==(TEST INSTALLER)==---------------------------------------------------+-')
log(' | Setup nessecary configuration for running test |')
log(' | This includes: Loading the PythonScript module at startup |')
log(' | To use this please run nsclient++ in "test mode" like so: |')
log(' | nscp --test |')
log(' | Then start the pytest_test command by typing it and press enter like so: |')
log(' | pytest_test |')
log(' | Lastly exit by typing exit like so: |')
log(' | exit |')
log('-+--------------------------------------------------------==(DAS ENDE!)==---+-')
conf = Settings.get()
conf.set_string('/modules', 'pytest', 'PythonScript')
conf.set_string('/settings/pytest/scripts', 'pytest', 'test.py')
conf.save()
开发者ID:0000-bigtree,项目名称:nscp,代码行数:15,代码来源:sample.py
示例14: install
def install(self, arguments):
conf = Settings.get()
conf.set_string('/modules', 'test_nscp_server', 'NSCPServer')
conf.set_string('/modules', 'test_nscp_client', 'NSCPClient')
conf.set_string('/modules', 'pytest', 'PythonScript')
conf.set_string('/settings/pytest/scripts', 'test_nscp', 'test_nscp.py')
conf.set_string('/settings/nscp/test_nscp_server', 'port', '15668')
conf.set_string('/settings/nscp/test_nscp_server', 'inbox', 'nscp_test_inbox')
conf.set_string('/settings/nscp/test_nscp_client/targets', 'nscp_test_local', 'nscp://127.0.0.1:15668')
conf.set_string('/settings/nscp/test_nscp_client', 'channel', 'nscp_test_outbox')
conf.save()
开发者ID:0000-bigtree,项目名称:nscp,代码行数:15,代码来源:test_nscp.py
示例15: install
def install(self, arguments):
conf = Settings.get()
conf.set_string('/modules', 'test_nrpe_server', 'NRPEServer')
conf.set_string('/modules', 'test_nrpe_client', 'NRPEClient')
conf.set_string('/modules', 'pytest', 'PythonScript')
conf.set_string('/settings/pytest/scripts', 'test_nrpe', 'test_nrpe.py')
conf.set_string('/settings/NRPE/test_nrpe_server', 'port', '15666')
conf.set_string('/settings/NRPE/test_nrpe_server', 'inbox', 'nrpe_test_inbox')
conf.set_string('/settings/NRPE/test_nrpe_server', 'encryption', '1')
conf.set_string('/settings/NRPE/test_nrpe_client/targets', 'nrpe_test_local', 'nrpe://127.0.0.1:15666')
conf.set_string('/settings/NRPE/test_nrpe_client', 'channel', 'nrpe_test_outbox')
conf.save()
开发者ID:jkells,项目名称:nscp,代码行数:16,代码来源:test_nrpe.py
示例16: install
def install(self, arguments):
conf = Settings.get()
conf.set_string("/modules", "pytest", "PythonScript")
fn = os.path.basename(self.__source__)
(sn, ext) = os.path.splitext(fn)
conf.register_key(
"/settings/pytest/scripts",
sn,
"string",
"UNIT TEST SCRIPT: %s" % self.title(),
"A script for running unittests for: %s" % self.desc(),
fn,
)
conf.set_string("/settings/pytest/scripts", sn, fn)
conf.save()
开发者ID:jkells,项目名称:nscp,代码行数:16,代码来源:test_helper.py
示例17: install
def install(self, arguments):
conf = Settings.get()
conf.set_string('/modules', 'pytest_eventlog', 'CheckEventLog')
conf.set_string('/modules', 'pytest', 'PythonScript')
conf.set_string('/settings/pytest/scripts', 'test_eventlog', 'test_eventlog.py')
conf.set_string('/settings/pytest_eventlog/real-time', 'enabled', 'true')
conf.set_string('/settings/pytest_eventlog/real-time', 'filter', 'id = 1000 and category = 0')
conf.set_string('/settings/pytest_eventlog/real-time/filters', 'test', 'id = 1000 and category = 1')
conf.set_string('/settings/pytest_eventlog/real-time', 'maximum age', '5s')
conf.set_string('/settings/pytest_eventlog/real-time', 'destination', 'pytest_evlog')
conf.set_string('/settings/pytest_eventlog/real-time', 'language', 'english')
conf.set_string('/settings/pytest_eventlog/real-time', 'debug', 'true')
conf.set_string('/settings/pytest_eventlog/real-time', 'enable active', 'true')
conf.save()
开发者ID:jkells,项目名称:nscp,代码行数:17,代码来源:test_eventlog.py
示例18: 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
示例19: install
def install(self, arguments):
conf = Settings.get()
conf.set_string('/modules', 'test_scheduler', 'Scheduler')
conf.set_string('/modules', 'pytest', 'PythonScript')
conf.set_string('/settings/pytest/scripts', 'test_python', 'test_python.py')
base_path = '/settings/test_scheduler'
conf.set_string(base_path, 'threads', '0')
default_path = '%s/schedules/default'%base_path
conf.set_string(default_path, 'channel', 'py_stress_test')
conf.set_string(default_path, 'alias', 'stress')
conf.set_string(default_path, 'command', 'py_stress_noop')
conf.set_string(default_path, 'interval', '5s')
for i in range(1, install_checks):
alias = 'stress_python_%i'%i
conf.set_string('%s/schedules'%(base_path), alias, 'py_stress_noop')
conf.save()
开发者ID:jkells,项目名称:nscp,代码行数:20,代码来源:test_python.py
示例20: install
def install(self, arguments):
conf = Settings.get()
conf.set_string('/modules', 'pytest_eventlog', 'CheckEventLog')
conf.set_string('/modules', 'pytest', 'PythonScript')
conf.set_string('/settings/pytest/scripts', 'test_eventlog', 'test_eventlog.py')
conf.set_string('/settings/pytest_eventlog/real-time', 'enabled', 'true')
self.install_filter(conf, '/settings/pytest_eventlog/real-time/filters/default', 'pytest_evlog_01', 'id = 1000 and category = 0', '%type% %source%: %message%','OK')
self.install_filter(conf, '/settings/pytest_eventlog/real-time/filters/py_test_001', 'pytest_evlog_01', 'id = 1000 and category = 1', 'X1 %type% %source%: %message%', 'WARNING')
self.install_filter(conf, '/settings/pytest_eventlog/real-time/filters/py_test_002', 'pytest_evlog_02', 'id = 1000 and category = 2', 'X2 %type% %source%: %message%', 'CRITICAL')
self.install_filter(conf, '/settings/pytest_eventlog/real-time/filters/py_test_003', None, 'id = 1000 and category = 3', 'X3 %type% %source%: %message%', 'UNKNOWN')
self.install_filter(conf, '/settings/pytest_eventlog/real-time/filters/py_test_004', None, None , 'X4 %type% %source%: %message%', None)
conf.set_string('/settings/pytest_eventlog/real-time', 'maximum age', '5s')
conf.set_string('/settings/pytest_eventlog/real-time', 'debug', 'true')
conf.set_string('/settings/pytest_eventlog/real-time', 'enable active', 'true')
conf.save()
开发者ID:Vilse1202,项目名称:nscp,代码行数:21,代码来源:test_eventlog.py
注:本文中的NSCP.Settings类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论