I am following the Splunk SDK example using version 1.6.3 with Python 3, on Splunk 6.6.4:
import splunklib.client as client
HOST = "localhost"
PORT = 8000
USERNAME = "admin"
PASSWORD = "changeme"
service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD)
for app in service.apps:
print app.name
I have changed the hard-coded credentials to match valid login info, however I am receiving the following response:
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2862, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 6, in
password=PASSWORD
File "/opt/anaconda3/lib/python3.6/site-packages/splunk_sdk-1.6.3-py3.6.egg/splunklib/client.py", line 322, in connect
s.login()
File "/opt/anaconda3/lib/python3.6/site-packages/splunk_sdk-1.6.3-py3.6.egg/splunklib/binding.py", line 862, in login
session = XML(body).findtext("./sessionKey")
File "/opt/anaconda3/lib/python3.6/xml/etree/ElementTree.py", line 1314, in XML
parser.feed(text)
File "", line unknown
ParseError: syntax error: line 1, column 0
Try running this command before execute the python script to bypass the cert
export PYTHONHTTPSVERIFY=0
How did you fix this issue?
I also got same issue.
I use port 8000, as it is the port I connect to using web browser.
When I use port 8000, I got the same error msg as you.
I also tried port 8089 or 443, both will lead to different error messages:
ConnectionRefusedError,
which implies the port could be wrong
Check indentation in code. Also , port should be 8089 or (your splunk management port) not 8000.
Yes port is his issue
Ah, yes, makes sense. thanks!
I have the same issue. But, I used port 8089. But, I am still not able to connect. The error I get is:
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:579)
The code is below for the connection I use. Please guide me here.
import splunklib.client as client
HOST = "localhost"
PORT = 8089
USERNAME = "admin"
PASSWORD = "Qwerty@1993"
service = client.connect(
host=HOST,
port=PORT,
username=USERNAME,
password=PASSWORD)
for app in service.apps:
print app.name
I got it never mind.
How did you fix this issue?
I also got same issue.
I use port 8000, as it is the port I connect to using web browser.
When I use port 8000, I got the same error msg as you.
I also tried port 8089 or 443, both will lead to different error messages:
ConnectionRefusedError,
which implies the port could be wrong
I by passed the SSL cert
run this command before execute the python script
export PYTHONHTTPSVERIFY=0