External search command 'acblblockcmd' returned error code 1. "RuntimeError at search_command.py line 865 Failed to parse transport header: splunkVersion:7.2.0
Hi There,
I got the below exception when I run my python command:
External search command 'acblblockcmd' returned error code 1. Script output = "chunked 1.0,219,0 {"inspector":{"messages":[["ERROR","RuntimeError at "/opt/splunk/etc/apps/botcop/bin/splunklib/searchcommands/search_command.py", line 865 : Failed to parse transport header: splunkVersion:7.2.0\n"]]},"finished":true}"
-- The commands.conf
[acblblockcmd] filename = acblblockcmd.py type = python chunked = false
-- And the command definition as follows: import sys from splunklib.searchcommands import dispatch, EventingCommand, Configuration @Configuration() class ExEventsCommand(EventingCommand): def transform(self, records): l = list(records) l.sort(key=lambda r: r['_raw']) return l if name == "main": dispatch(ExEventsCommand, sys.argv, sys.stdin, sys.stdout, name)
Anybody seen this error and how did you fix it?
Thanks in advance.
Are you intending to use SCPv1? (Splunk will use the legacy protocol when you set chunked = false in commands.conf)
If you change that setting to true you'll be using SCPv2, and that should address this specific issue
Hi Mohamed, I tried both chunked= true and false, in both cases the error is same. Thanks,
Looks like you're on Splunk Enterprise 7.2.0, which versions of Python SDK are you using?
Python 2.7.5
The Splunk Software Development Kit for Python Version 1.6.6
Do you get the same error with v1.6.5?
I've not tried 1.6.5
Just now I tried 1.6.5, there also it is giving same error.
External search command 'acblblockcmd' returned error code 1. Script output = "chunked 1.0,219,0 {"finished":true,"inspector":{"messages":[["ERROR","RuntimeError at "/opt/splunk/etc/apps/botcop/bin/splunklib/searchcommands/search_command.py", line 866 : Failed to parse transport header: splunkVersion:7.2.0\n"]]}}"
Also have this issue.
have tried chunked=false|true and requires_srinfo=true|false and passauth=true
Same results.
RuntimeError at "C:\Program Files\Splunk\etc\...\bin\splunklib\searchcommands\search_command.py", line 865 : Failed to parse transport header:
Traceback:
File "C:\Program Files\Splunk\..\bin\splunklib\searchcommands\search_command.py", line 658, in _process_protocol_v2
metadata, body = self._read_chunk(ifile)
File "C:\Program Files\Splunk\...\bin\splunklib\searchcommands\search_command.py", line 865, in _read_chunk
raise RuntimeError('Failed to parse transport header: {}'.format(header))
chunked 1.0,234,0
{"inspector":{"messages":[["ERROR","RuntimeError at \"C:\\Program Files\\Splunk\\etc\\apps\\...\\bin\\splunklib\\searchcommands\\search_command.py\", line 865 : Failed to parse transport header: \n"]]},"finished":true}
@christofferTP which version of Splunk Enterprise are you running?
It's 7.3.. Seems to relate to access rights to .conf files, at least for Windows installs.
Den tis 30 juli 2019 22:39Shakeel Mohamed <[email protected]mailto:[email protected]> skrev:
@christofferTPhttps://github.com/christofferTP which version of Splunk Enterprise are you running?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/splunk/splunk-sdk-python/issues/242?email_source=notifications&email_token=ABVTCHN6LZZPLH4V2LAC25DQCCRIDA5CNFSM4GUZOSR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3FHZOQ#issuecomment-516586682, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABVTCHOZRWPBFNAMIGJNW6TQCCRIDANCNFSM4GUZOSRQ.
Hi folks, I'm executing a custom search command with commands.conf configured as below and I get the same error. My environment is Splunk 8.0.1 in Windows Server 2019. However, the exact same command and configuration run smoothly in CentOS 7.6.
[mycustomsearchcommand]
filename = mycustomsearchcommand.py
enableheader = true
outputheader = true
requires_srinfo = true
stderr_dest = message
supports_getinfo = false
Solution (at least for me)
Replace commands.conf content with the following (tested in both Windows and CentOS environments).
[mycustomsearchcommand]
filename = mycustomsearchcommand.py
chunked = true
Hope this helps.
Hi @bbobbadi , I'm able to run search commands successfully after a few changes to commands.conf and acblblockcmd.py files. Please try with below mentioned code and check if it is working for you or not. If you are still facing this issue then please do let us know.
commands.conf file:
[acblblockcmd]
filename = acblblockcmd.py
type = python
chunked = true
acblblockcmd.py file:
import os, sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.searchcommands import dispatch, EventingCommand, Configuration
@Configuration()
class ExEventsCommand(EventingCommand):
def transform(self, records):
l = list(records)
l.sort(key=lambda r: r['_raw'])
return l
if __name__ == "__main__":
dispatch(ExEventsCommand, sys.argv, sys.stdin, sys.stdout, __name__)
Hi @bbobbadi Closing this issue due to no response on it. Please reopen if this is still an issue.