本文整理汇总了Python中NSCP.log_debug函数的典型用法代码示例。如果您正苦于以下问题:Python log_debug函数的具体用法?Python log_debug怎么用?Python log_debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_debug函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: log
def log(self, show_all = False, prefix = '', indent = 0):
if self.status:
if show_all:
log('%s%s%s'%(prefix, ''.rjust(indent, ' '), self))
log_debug('%s%s%s'%(prefix, ''.rjust(indent, ' '), self))
else:
log_error('%s%s%s'%(prefix, ''.rjust(indent, ' '), self))
开发者ID:mickem,项目名称:nscp,代码行数:7,代码来源:test_helper.py
示例2: log
def log(self, prefix = '', indent = 0):
start = '%s%s'%(prefix, ''.rjust(indent, ' '))
if self.status:
log_debug('%s%s'%(start, self))
else:
log_error('%s%s'%(start, self))
for c in self.children:
c.log(prefix, indent+1)
开发者ID:Fox-Alpha,项目名称:nscp,代码行数:8,代码来源:test_helper.py
示例3: serialize
def serialize(self, string, filename):
path = os.path.dirname(filename)
if not os.path.exists(path):
os.makedirs(path)
f = open(filename,"w")
f.write(string)
f.close()
log_debug('Writing file: %s'%filename)
开发者ID:borgified,项目名称:nscp,代码行数:8,代码来源:docs.py
示例4: log
def log(self, prefix="", indent=0):
start = "%s%s" % (prefix, "".rjust(indent, " "))
if self.status:
log_debug("%s%s" % (start, self))
else:
log_error("%s%s" % (start, self))
for c in self.children:
c.log(prefix, indent + 1)
开发者ID:jkells,项目名称:nscp,代码行数:8,代码来源:test_helper.py
示例5: return_nagios
def return_nagios(self):
(total, ok) = self.count()
log_debug(" | Test result log (only summary will be returned to query)")
self.log(" | ")
if total == ok:
return (status.OK, "OK: %d test(s) successfull" % (total))
else:
return (status.CRITICAL, "ERROR: %d/%d test(s) failed" % (total - ok, total))
开发者ID:jkells,项目名称:nscp,代码行数:8,代码来源:test_helper.py
示例6: generate_rst
def generate_rst(self, input_dir, output_dir):
root = self.get_info()
i = 0
env = Environment(extensions=["jinja2.ext.do",])
env.filters['firstline'] = first_line
env.filters['rst_link'] = make_rst_link
env.filters['rst_table'] = render_rst_table
env.filters['rst_csvtable'] = render_rst_csv_table
env.filters['rst_heading'] = render_rst_heading
env.filters['extract_value'] = extract_value
env.filters['block_pad'] = block_pad
env.filters['common_head'] = calculate_common_head
env.filters['as_text'] = as_text
for (module,minfo) in root.plugins.iteritems():
out_base_path = '%s/reference/'%output_dir
sample_base_path = '%s/samples/'%output_dir
if minfo.namespace:
out_base_path = '%s/reference/%s/'%(output_dir, minfo.namespace)
hash = root.get_hash()
minfo.key = module
minfo.queries = {}
for (c,cinfo) in sorted(root.commands.iteritems()):
if module in cinfo.info.plugin:
more_info = self.fetch_command(c,cinfo)
if more_info:
cinfo = more_info
sfile = '%s%s_%s_samples.inc'%(sample_base_path, module, c)
if os.path.exists(sfile):
cinfo.sample = os.path.basename(sfile)
#all_samples.append((module, command, sfile))
cinfo.key = c
minfo.queries[c] = cinfo
minfo.aliases = {}
for (c,cinfo) in sorted(root.aliases.iteritems()):
if module in cinfo.info.plugin:
cinfo.key = c
minfo.aliases[c] = cinfo
minfo.paths = {}
for (c,cinfo) in sorted(root.paths.iteritems()):
if module in cinfo.info.plugin:
cinfo.key = c
minfo.paths[c] = cinfo
hash['module'] = minfo
i=i+1
log_debug('Processing module: %d of %d [%s]'%(i, len(root.plugins), module))
template = env.from_string(module_template)
render_template(hash, template, '%s/%s.rst'%(out_base_path, module))
log_debug('%s/samples/index.rst'%output_dir)
hash = root.get_hash()
template = env.from_string(samples_template)
render_template(hash, template, '%s/samples/index.rst'%output_dir)
开发者ID:0000-bigtree,项目名称:nscp,代码行数:57,代码来源:docs.py
示例7: get_keys
def get_keys(self, path):
(code, data) = self.conf.query(self.build_inventory_request(path, False, True))
if code == 1:
message = plugin_pb2.SettingsResponseMessage()
message.ParseFromString(data)
for payload in message.payload:
if payload.inventory:
log_debug('Found %d keys for %s'%(len(payload.inventory), path))
return payload.inventory
return []
开发者ID:ossmon,项目名称:nscp,代码行数:10,代码来源:docs.py
示例8: get_paths
def get_paths(self):
(code, data) = self.conf.query(self.build_inventory_request())
if code == 1:
message = plugin_pb2.SettingsResponseMessage()
message.ParseFromString(data)
for payload in message.payload:
if payload.inventory:
log_debug('Found %d paths'%len(payload.inventory))
return payload.inventory
return []
开发者ID:ossmon,项目名称:nscp,代码行数:10,代码来源:docs.py
示例9: simple_inbox_handler_wrapped
def simple_inbox_handler_wrapped(self, channel, source, command, status, message, perf):
log_debug('Got message %s on %s'%(command, channel))
msg = NSCAMessage(command)
msg.source = source
msg.status = status
msg.message = message
msg.perfdata = perf
msg.got_simple_response = True
self.set_response(msg)
return True
开发者ID:0000-bigtree,项目名称:nscp,代码行数:10,代码来源:test_nsca.py
示例10: get_plugins
def get_plugins(self):
(code, data) = self.registry.query(self.build_command_request(4))
if code == 1:
message = plugin_pb2.RegistryResponseMessage()
message.ParseFromString(data)
for payload in message.payload:
if payload.inventory:
log_debug('Found %d plugins'%len(payload.inventory))
return payload.inventory
log_error('No plugins')
return []
开发者ID:borgified,项目名称:nscp,代码行数:11,代码来源:docs.py
示例11: setup
def setup(self, plugin_id, prefix):
t = datetime.datetime.fromtimestamp(time.mktime(time.localtime()))
t = t + datetime.timedelta(seconds=60)
tm = time.strftime("%H:%M", t.timetuple())
folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
log("Adding scheduled tasks")
for state in ['OK', 'WARN', 'CRIT', 'LONG']:
cmd = "schtasks.exe /Create /SC DAILY /TN NSCPSample_%s /TR \"%s\\check_test.bat %s\" /ST %s /F"%(state, folder, state, tm)
log_debug(cmd)
check_output(cmd)
log("Waiting 1 minute (for tasks to run)")
time.sleep(60)
开发者ID:mickem,项目名称:nscp,代码行数:12,代码来源:test_w32_schetask.py
示例12: get_query_aliases
def get_query_aliases(self):
log_debug('Fetching aliases...')
(code, data) = self.registry.query(self.build_command_request(5))
if code == 1:
message = plugin_pb2.RegistryResponseMessage()
message.ParseFromString(data)
for payload in message.payload:
if payload.inventory:
log_debug('Found %d aliases'%len(payload.inventory))
return payload.inventory
log_error('No aliases found')
return []
开发者ID:ossmon,项目名称:nscp,代码行数:12,代码来源:docs.py
示例13: inbox_handler_wrapped
def inbox_handler_wrapped(self, channel, request):
message = plugin_pb2.SubmitRequestMessage()
message.ParseFromString(request)
if len(message.payload) != 1:
log_error("Got invalid message on channel: %s"%channel)
return None
command = message.payload[0].command
log_debug('Got message %s on %s'%(command, channel))
msg = NSCAMessage(command)
msg.got_response = True
self.set_response(msg)
return None
开发者ID:0000-bigtree,项目名称:nscp,代码行数:13,代码来源:test_nsca.py
示例14: wait_and_validate
def wait_and_validate(self, uuid, result, msg, perf, tag):
found = False
for i in range(0,10):
if not self.has_response(uuid):
log_debug('Waiting for %s (%d/10)'%(uuid, i+1))
sleep(200)
else:
log_debug('Got response %s'%uuid)
found = True
break
if not found:
result.add_message(False, 'Failed to recieve message %s using %s'%(uuid, tag))
return False
for i in range(0,10):
rmsg = self.get_response(uuid)
if not rmsg.got_simple_response or not rmsg.got_response:
log_debug('Waiting for delayed response %s s/m: %s/%s - (%d/10)'%(uuid, rmsg.got_simple_response, rmsg.got_response, i+1))
sleep(500)
else:
log_debug('Got delayed response %s'%uuid)
break
result.add_message(rmsg.got_response, 'Testing to recieve message using %s'%tag)
result.add_message(rmsg.got_simple_response, 'Testing to recieve simple message using %s'%tag)
result.assert_equals(rmsg.command, uuid, 'Verify that command is sent through using %s'%tag)
result.assert_contains(rmsg.message, msg, 'Verify that message is sent through using %s'%tag)
#result.assert_equals(rmsg.last_source, source, 'Verify that source is sent through')
#result.assert_equals(rmsg.perfdata, perf, 'Verify that performance data is sent through using %s'%tag)
self.del_response(uuid)
return True
开发者ID:0000-bigtree,项目名称:nscp,代码行数:32,代码来源:test_nsca.py
示例15: check_ts_query
def check_ts_query(self, task, code):
result = TestResult('Checking task %s'%task)
for i in [0, 1, 2, 3, 4]:
# check_tasksched "filter=title = 'NSCPSample_CRIT'" "warn=exit_code != 3"
args = ["filter=title = 'NSCPSample_%s'"%task,
"warn=exit_code = %d"%i]
log_debug(', '.join(args))
(ret, msg, perf) = self.core.simple_query('check_tasksched', args)
if i == code:
result.assert_equals(ret, status.WARNING, 'Verify WARN result: %s'%msg)
else:
result.assert_equals(ret, status.OK, 'Verify OK result: %s'%msg)
return result
开发者ID:mickem,项目名称:nscp,代码行数:15,代码来源:test_w32_schetask.py
示例16: install
def install(self, arguments):
t = datetime.datetime.fromtimestamp(time.mktime(time.localtime()))
t = t + datetime.timedelta(seconds=60)
tm = time.strftime("%H:%M", t.timetuple())
folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
log("Adding scheduled tasks")
for state in ['OK', 'WARN', 'CRIT', 'LONG']:
cmd = "SchTasks /Create /SC DAILY /TN NSCPSample_%s /TR \"%s\\check_test.bat %s\" /ST %s /F"%(state, folder, state, tm)
log_debug(cmd)
check_output(cmd)
log("Waiting 1 minute (for tasks to run)")
time.sleep(60)
conf = self.conf
conf.set_string('/modules', 'test_tsch', 'CheckTaskSched')
conf.set_string('/modules', 'pytest', 'PythonScript')
conf.set_string('/settings/pytest/scripts', 'test_w32_tsch', __file__)
conf.save()
开发者ID:wyrover,项目名称:nscp,代码行数:18,代码来源:test_w32_schetask.py
示例17: render_template
def render_template(hash, template, filename):
data = template.render(hash).encode('utf8')
path = os.path.dirname(filename)
if not os.path.exists(path):
os.makedirs(path)
if os.path.exists(filename):
m1 = hashlib.sha256()
m1.update(data)
sha1 = m1.digest()
with open(filename) as f:
m2 = hashlib.sha256()
m2.update(f.read())
sha2 = m2.digest()
if sha1 == sha2:
log_debug("no changes detected in: %s"%filename)
return
log_debug('Writing file: %s'%filename)
f = open(filename,"wb")
f.write(data)
f.close()
开发者ID:ossmon,项目名称:nscp,代码行数:23,代码来源:docs.py
示例18: stress_handler
def stress_handler(channel, source, command, code, message, perf):
instance = PythonTest.getInstance()
instance.stress_count = instance.stress_count + 1
log_debug('Got message %d/%d on %s'%(instance.stress_count, instance.noop_count, channel))
开发者ID:Fox-Alpha,项目名称:nscp,代码行数:4,代码来源:test_python.py
示例19: teardown
def teardown(self):
for state in ['OK', 'WARN', 'CRIT', 'LONG']:
log_debug("schtasks.exe /Delete /TN NSCPSample_%s /F"%state)
check_output("schtasks.exe /Delete /TN NSCPSample_%s /F"%state)
开发者ID:mickem,项目名称:nscp,代码行数:4,代码来源:test_w32_schetask.py
示例20: install
def install(self, arguments):
global is_windows, route_via_python, route_via_nsca, use_threads
# Configure required modules
self.conf.set_string("/modules", "pytest", "PythonScript")
self.conf.set_string("/modules", self.sched_alias, "Scheduler")
if is_windows:
self.conf.set_string("/modules", "CheckSystem", "enabled")
self.conf.set_string("/modules", "CheckHelpers", "enabled")
if route_via_nsca:
self.conf.set_string("/modules", self.nsca_server_alias, "NSCAServer")
self.conf.set_string("/modules", self.nsca_client_alias, "NSCAClient")
# Configure NSCA Server
self.conf.set_string("/settings/NSCA/%s" % self.nsca_server_alias, "port", "%d" % self.nsca_port)
self.conf.set_string("/settings/NSCA/%s" % self.nsca_server_alias, "inbox", self.python_channel)
self.conf.set_string("/settings/NSCA/%s" % self.nsca_server_alias, "encryption", "xor")
self.conf.set_string("/settings/NSCA/%s" % self.nsca_server_alias, "password", "HelloWorld")
# Configure NSCA Client
self.conf.set_string(
"/settings/NSCA/%s/targets/default" % self.nsca_client_alias,
"address",
"nsca://127.0.0.1:%d" % self.nsca_port,
)
self.conf.set_string("/settings/NSCA/%s/targets/default" % self.nsca_client_alias, "encryption", "xor")
self.conf.set_string("/settings/NSCA/%s/targets/default" % self.nsca_client_alias, "password", "HelloWorld")
self.conf.set_string("/settings/NSCA/%s" % self.nsca_client_alias, "channel", self.nsca_channel)
if route_via_nrpe:
self.conf.set_string("/modules", self.nrpe_server_alias, "NRPEServer")
self.conf.set_string("/modules", self.nrpe_client_alias, "NRPEClient")
# Configure NRPE Server
self.conf.set_string("/settings/NRPE/%s" % self.nrpe_server_alias, "port", "%d" % self.nrpe_port)
self.conf.set_string("/settings/NRPE/%s" % self.nrpe_server_alias, "allow arguments", "true")
# Configure NRPE Client
self.conf.set_string(
"/settings/NRPE/%s/targets/default" % self.nsca_client_alias,
"address",
"nrpe://127.0.0.1:%d" % self.nrpe_port,
)
# Configure python
self.conf.set_string("/settings/pytest/scripts", "test_stress", "test_stress.py")
# Configure Scheduler
if route_via_python:
self.conf.set_string(self.sched_base_path, "threads", "0")
else:
self.conf.set_string(self.sched_base_path, "threads", "50")
default_path = "%s/schedules/default" % self.sched_base_path
if route_via_nsca:
self.conf.set_string(default_path, "channel", self.nsca_channel)
else:
self.conf.set_string(default_path, "channel", self.python_channel)
self.conf.set_string(default_path, "alias", "stress")
# self.conf.set_string(default_path, 'target', 'stress_001')
use_command = self.command
if not route_via_python:
if route_via_nrpe:
use_command = "nrpe_query host=127.0.0.1 port=%d command=CheckOK" % self.nrpe_port
else:
use_command = "CheckOK"
self.conf.set_string(default_path, "command", use_command)
self.conf.set_string(default_path, "interval", "5s")
log_debug("Adding %d checks" % int(check_per_second * 5))
for i in range(1, int(check_per_second * 5) + 1):
alias = "stress_python_%i" % i
self.conf.set_string("%s/schedules" % (self.sched_base_path), alias, use_command)
self.conf.save()
开发者ID:Fox-Alpha,项目名称:nscp,代码行数:79,代码来源:test_stress.py
注:本文中的NSCP.log_debug函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论