Logging in using autologin=True in python splunk-sdk and executing a query gives ResponseReader object as expected if the session is not terminated,
>>> import splunklib.client as splunkclient
>>> splunk_service = splunkclient.connect(host='searchhead.com', port=8089, username='admin', password='password', autologin=True)
>>> splunk_service.jobs.oneshot("search index=myindex", earliest_time='-1hour')
<splunklib.binding.ResponseReader object at 0xaa2a10>
To terminate the session restarted the splunk search head service in searchhead.com, it restarted splunkd, splunkweb, etc.. tried the following after splunk related services are started.
Cross checked ports are connected and ready. But the query execution fails with some internal error?
>>> splunk_service.jobs.oneshot("search index=myindex", earliest_time='-1hour')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/splunklib/client.py", line 2799, in oneshot
**params).body
File "/usr/lib/python2.6/site-packages/splunklib/client.py", line 743, in post
**query)
File "/usr/lib/python2.6/site-packages/splunklib/binding.py", line 248, in wrapper
return request_fun()
File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/lib/python2.6/site-packages/splunklib/binding.py", line 180, in _handle_auth_error
yield
File "/usr/lib/python2.6/site-packages/splunklib/binding.py", line 248, in wrapper
return request_fun()
File "/usr/lib/python2.6/site-packages/splunklib/binding.py", line 61, in new_f
val = f(*args, **kwargs)
TypeError: post() takes at least 2 arguments (0 given)
But trying again immediately succeeds, (able to reproduce, first try after restart of splunk service always fails and second succeeds):
>>> splunk_service.jobs.oneshot("search index=myindex", earliest_time='-1hour')
<splunklib.binding.ResponseReader object at 0xaa2e50>
Is it a known issue? quick googling doesn't help much. Any help towards resolving this issue much appreciated.
PS: Splunk 6, tried in both splunk-sdk 1.2.0 and 1.0.0
... View more