本文整理汇总了Python中splunk.Intersplunk.addErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:Python Intersplunk.addErrorMessage方法的具体用法?Python Intersplunk.addErrorMessage怎么用?Python Intersplunk.addErrorMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类splunk.Intersplunk
的用法示例。
在下文中一共展示了Intersplunk.addErrorMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: error
# 需要导入模块: from splunk import Intersplunk [as 别名]
# 或者: from splunk.Intersplunk import addErrorMessage [as 别名]
def error(msg):
# for some reason the old style generateErrorResults aren't making their way into the ui.
# si.generateErrorResults("Usage: searchtxn <transaction_type> <transaction_search>. Ex: searchtxn loginsessions user=bob")
messages = {}
si.addErrorMessage(messages, msg)
si.outputResults([], messages)
exit(0)
示例2: execute
# 需要导入模块: from splunk import Intersplunk [as 别名]
# 或者: from splunk.Intersplunk import addErrorMessage [as 别名]
def execute():
results = []
try:
results, dummyresults, settings = si.getOrganizedResults()
# default values
args = {"namespace": "search"}
# get commandline args
keywords, options = si.getKeywordsAndOptions()
# override default args with settings from search kernel
args.update(settings)
# override default args with commandline args
args.update(options)
sessionKey = args.get("sessionKey", None)
owner = args.get("owner", "admin")
namespace = args.get("namespace", None)
if namespace.lower() == "none":
namespace = None
messages = {}
if sessionKey == None:
# this shouldn't happen, but it's useful for testing.
try:
sessionKey = sa.getSessionKey("admin", "changeme")
si.addWarnMessage(
messages, "No session given to 'tune' command. Using default admin account and password."
)
except splunk.AuthenticationFailed, e:
si.addErrorMessage(messages, "No session given to 'tune' command.")
return
if len(keywords) != 1:
usage()
# e.g., '/data/inputs/monitor'
entity = keywords[0]
logger.info("Entity: %s Args: %s" % (entity, args))
results = [] # we don't care about incoming results
try:
entitys = en.getEntities(entity, sessionKey=sessionKey, owner=owner, namespace=namespace, count=-1)
for name, entity in entitys.items():
try:
myapp = entity["eai:acl"]["app"]
if namespace != None and myapp != namespace:
continue
except:
continue # if no eai:acl/app, filter out
result = entityToResult(name, entity)
results.append(result)
except splunk.ResourceNotFound, e2:
pass
示例3: len
# 需要导入模块: from splunk import Intersplunk [as 别名]
# 或者: from splunk.Intersplunk import addErrorMessage [as 别名]
output += " " #" AND "
output += AND
if len(ORS) > 1:
output += ")"
si.outputResults([{'search': output}], messages)
if __name__ == '__main__':
messages = {}
try:
(isgetinfo, sys.argv) = si.isGetInfo(sys.argv)
argtext = ' '.join(sys.argv[1:])
count, mapping = parseArgs(argtext)
if isgetinfo:
reqsop = True
preop = "head %s" % count
fields = [field for alias, field in mapping]
if len(fields) > 0:
preop += " | fields %s" % ', '.join(fields)
si.outputInfo(False, False, False, reqsop, preop) # calls sys.exit()
run(messages, count, mapping)
except Exception, e:
import traceback
stack = traceback.format_exc()
si.addErrorMessage(messages, "%s. Traceback: %s" % (e, stack.replace('\n','\\n')))
si.outputResults([], messages)