0

I am trying to run an external python script "PyClient.py" on Splunk, and it requires the external gRPC module. I installed the gRPC module locally following the quickstart python guide from http://www.grpc.io/docs/quickstart/python.html . The logs generated in the splunkd file are as follows:

    06-16-2017 18:20:49.728 +0530 WARN  IntrospectionGenerator:resource_usage -   RU - Failure executing PDH query, skipping getting iostats data this collection cycle. Status code is -2147481643
    06-16-2017 18:20:56.501 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py"" Traceback (most recent call last):
    06-16-2017 18:20:56.501 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py""   File "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py", line 2, in <module>
    06-16-2017 18:20:56.501 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py""     import grpc
    06-16-2017 18:20:56.501 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py""   File "C:\Program Files\Splunk\etc\apps\Test\bin\grpc\__init__.py", line 37, in <module>
    06-16-2017 18:20:56.501 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py""     from grpc._cython import cygrpc as _cygrpc
    06-16-2017 18:20:56.501 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py"" ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
    06-16-2017 18:21:06.502 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py"" Traceback (most recent call last):
    06-16-2017 18:21:06.502 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py""   File "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py", line 2, in <module>
    06-16-2017 18:21:06.502 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py""     import grpc
    06-16-2017 18:21:06.502 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py""   File "C:\Program Files\Splunk\etc\apps\Test\bin\grpc\__init__.py", line 37, in <module>
    06-16-2017 18:21:06.502 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py""     from grpc._cython import cygrpc as _cygrpc
    06-16-2017 18:21:06.502 +0530 ERROR ExecProcessor - message from "python "C:\Program Files\Splunk\etc\apps\Test\bin\pyClient.py"" ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

Does anyone have any suggestions on how to clear this error? Or how to install the external gRPC module on Splunk?

Thanks in advance.

hridayns
  • 697
  • 8
  • 16
  • Can you share more about how you installed gRPC Python and are working with it? Are you using `pip`? Are you using a virtual environment? – Nathaniel Manista At Google Jun 16 '17 at 17:46
  • The command python -V tells me the Python version installed locally is 2.7.13. Following the quick start python guide (link in question), I used the following commands locally on my computer to install gRPC for python: `python -m pip install --upgrade pip` `python -m pip install grpcio` `python -m pip install grpcio-tools` So yes, I am using `pip`. But I need to install these python modules on my Splunk installation. So that I can run my python script there. Please ask me anything else you would like to know, so that you can help me. Thanks. – hridayns Jun 19 '17 at 03:38
  • I apologize but I know nothing about Splunk. Is it a thing that has a Python environment? Is that Python environment known to be compatible with compiled extension modules? gRPC Python is such a module; it is not purely Python code. – Nathaniel Manista At Google Jun 21 '17 at 02:38
  • Yes, the Splunk platform has its own Python installed (Python version 2.7.13 to be precise). I am not sure if it is compatible with compiled extension modules. But I'm hoping there is a way to use gRPC module on the Splunk platform, to execute one of my scripts that imports gRPC. – hridayns Jun 21 '17 at 03:40

2 Answers2

1

This looks like a 32/64 bit Windows incompatibility.

When installing gRPC, make sure you are explicitly using the Splunk distribution of of Python to pip install grpcio.

C:\Program Files\Splunk\<Python2.7 binary> -m pip install --upgrade pip

C:\Program Files\Splunk\<Python2.7 binary> -m pip install grpcio

kpayson64
  • 353
  • 1
  • 4
  • sorry @kpayson64, that was not the issue. But thanks for answering. I did not have any success with trying to use the Splunk environment Python to install modules. At that time, it said the requirement was already fulfilled in my local directories. But it was not using it to run my scripts. – hridayns Jun 28 '17 at 03:49
0

I already found the solution. I had to write a wrapper script for my python script which which unset or delete (del) "LD_LIBRARY_PATH" and "PYTHONPATH". For Linux based systems, I also had to unset or delete (del) the "PATH" environment variable. After following the above steps, Splunk used my local version of Python and the installed modules as well. And it worked. Hope this helps anyone who is trying to use external modules in Splunk but cannot seem to figure out why it does not work. :)

hridayns
  • 697
  • 8
  • 16