我正在尝试使用Splunk的python (http://docs.splunk.com/Documentation/PythonSDK)连接到我的ParseError服务器,但是我得到了一个ParseError。
>>> pip install splunk-sdk
>>> import splunklib.binding as binding
>>> cargs = {}
>>> cargs['host'] = 'splunk.mydomain.com'
>>> cargs['scheme'] = 'https'
>>> cargs['port'] = 443
>>> cargs['username'] = 'my_username'
>>> cargs['password'] = 'my_password'
>>> c = binding.connect(**cargs)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/myframework/lib/python2.7/site-packages/splunklib/binding.py", line 867, in connect
c.login()
File "/myframework/lib/python2.7/site-packages/splunklib/binding.py", line 753, in login
session = XML(body).findtext("./sessionKey")
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1302, in XML
return parser.close()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1655, in close
self._raiseerror(v)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/etree/ElementTree.py", line 1507, in _raiseerror
raise err
xml.etree.ElementTree.ParseError: no element found: line 1, column 0因此,任何返回连接()的页面都没有预期的“./sessionKey”文本。我看到的所有示例都使用"localhost“作为主机,所以我不确定这个外部主机是否有问题。我希望我能把我的手放在回页上。
这个主机在我的公司网络上,所以不应该有访问问题。
有些东西被退回了;我在测试中忽略了端口,从而得到了以下结果:
错误: Errno 60操作超时
我在这里做错什么了?
发布于 2013-05-03 06:37:56
看起来你用错了端口。默认情况下,Splunk的管理端口是8089。除非您已经更改了,否则您应该使用的是8089而不是443。
确认URL和凭据的另一种方法是通过cURL从您正在尝试SDK的同一台计算机上的命令行测试它:
curl -k https://splunk.mydomain.com:8089/services/auth/login -d username=my_username -d password=my_passwordhttps://stackoverflow.com/questions/16349806
复制相似问题