我正在尝试使用 Splunk 的 python SDK ( http://docs.splunk.com/Documentation/PythonSDK ) 连接到我的 Splunk 服务器,但我收到了 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
因此,返回到 connect() 的任何页面都没有预期的“./sessionKey”文本。我见过的所有示例都使用“localhost”作为主机,所以我不确定这个外部主机是否存在问题。我希望我能拿到返回的页面。
该主机在我的公司网络上,所以应该没有访问问题。
有东西被退回;我通过省略端口对此进行了测试,这让我:
错误:[Errno 60] 操作超时
那么,我在这里做错了什么?