link:

http://dev.splunk.com/view/python-sdk/SP-CAAAER5

download SDK & setup with python

code:

import splunklib.client as client import splunklib.results as results import time

start = time.time()

HOST = "hostname"

PORT = 8089

USERNAME = "username"

PASSWORD = "password"

service = client.connect(

host=HOST,

port=PORT,

username=USERNAME,

password=PASSWORD)

kwargs_oneshot = {"earliest_time": "2017-07-01T12:00:00.000",

"latest_time": "2017-07-09T12:00:00.000",

"exec_mode": "blocking"}      # ,'search_mode': 'normal'

searchquery_oneshot = "search index=networkname netlinename|table rowname"

search_results = service.jobs.create(searchquery_oneshot, **kwargs_oneshot)

# Get the results and display them using the ResultsReader

rr = search_results.results(**{'count': 0})

reader = results.ResultsReader(rr)

inbound = []

outbound = []

for item in reader:

_raw_list = str(item['_raw'])

# print _raw_list

  inbound.append(_raw_list.split(",")[3])

outbound.append(_raw_list.split(",")[4])

# print inbound

# print outbound

print "inLen", len(inbound)

print "outLen", len(outbound)

print str(int(time.time() - start))

最新文章

  1. 纪念逝去的岁月——C/C++字符串反转
  2. 1079. Total Sales of Supply Chain (25)
  3. 挑战树莓派:谁才是Geek最爱的开发板?
  4. ASP.NET- Repeater 嵌套
  5. socket本地模拟UDP 服务器+客户端(三)
  6. python进阶1--数据库支持
  7. Android中目的地Intent的使用
  8. Code Forces 448C Painting Fence 贪婪的递归
  9. AFNetworking3.0 POST请求
  10. windows上安装redis
  11. fiddler几种功能强大的用法
  12. oracle之在java中调用
  13. 关于java做题时需要注意的事项
  14. Linux pwn入门教程(6)——格式化字符串漏洞
  15. java string字符拼接符"+"的研究
  16. RelativeLayout 相对父级元素布局
  17. 快速切题 sgu104. Little shop of flowers DP 难度:0
  18. 系统可能不会保存你所做的修改 onbeforeunload
  19. The Gene of Bitizens
  20. amcharts的一些用法

热门文章

  1. 关于python语言使用redis时,连接是否需要关闭的问题
  2. hdu 2553(N皇后问题)
  3. bzoj 2815
  4. 【黑金教程笔记之001】veriloghdl 扫盲文—笔记&勘误
  5. div拖拽互换位置(vue)
  6. How to Compare Means (均值比较)
  7. Luogu P1073 最优贸易【最短路/建反图】 By cellur925
  8. 博弈 HDOJ 4371 Alice and Bob
  9. DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas
  10. orcl 11g 创建表空间