get data from splunk
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))
最新文章
- 纪念逝去的岁月——C/C++字符串反转
- 1079. Total Sales of Supply Chain (25)
- 挑战树莓派:谁才是Geek最爱的开发板?
- ASP.NET- Repeater 嵌套
- socket本地模拟UDP 服务器+客户端(三)
- python进阶1--数据库支持
- Android中目的地Intent的使用
- Code Forces 448C Painting Fence 贪婪的递归
- AFNetworking3.0 POST请求
- windows上安装redis
- fiddler几种功能强大的用法
- oracle之在java中调用
- 关于java做题时需要注意的事项
- Linux pwn入门教程(6)——格式化字符串漏洞
- java string字符拼接符"+"的研究
- RelativeLayout 相对父级元素布局
- 快速切题 sgu104. Little shop of flowers DP 难度:0
- 系统可能不会保存你所做的修改 onbeforeunload
- The Gene of Bitizens
- amcharts的一些用法
热门文章
- 关于python语言使用redis时,连接是否需要关闭的问题
- hdu 2553(N皇后问题)
- bzoj 2815
- 【黑金教程笔记之001】veriloghdl 扫盲文—笔记&;勘误
- div拖拽互换位置(vue)
- How to Compare Means (均值比较)
- Luogu P1073 最优贸易【最短路/建反图】 By cellur925
- 博弈 HDOJ 4371 Alice and Bob
- DFS Codeforces Round #299 (Div. 2) B. Tavas and SaDDas
- orcl 11g 创建表空间