<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using alternate Python for script data inputs in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Using-alternate-Python-for-script-data-inputs/m-p/370249#M67187</link>
    <description>&lt;P&gt;We are trying to do some snmp queries using Python and input the output key-value pairs into Splunk.&lt;BR /&gt;
We want to use pysnmp to do this.&lt;BR /&gt;
Pysnmp (or its dependencies) do not come standard with the Splunk python libraries.&lt;/P&gt;

&lt;P&gt;I have attempted putting "#!/root/anaconda2/python" in the first line of our script.  But it does not read from the Anaconda Python version we want it to.  I am concerned if it does, even, are there specific Splunk-related libraries that Splunk needs to handle the output of these scripts that won't be located in the Anaconda python version.&lt;/P&gt;

&lt;P&gt;From another similar question, I tried using: &lt;/P&gt;

&lt;P&gt;import sys&lt;BR /&gt;
sys.path.append('root/anaconda2/bin/python')&lt;BR /&gt;
sys.path.append('/root/anaconda2/lib/python2.7/site-packages')&lt;/P&gt;

&lt;P&gt;This sorta seems to work but now I'm getting an issue seen below:&lt;BR /&gt;
ERROR:root:code for hash md5 was not found.&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/hashlib.py", line 147, in &lt;BR /&gt;
    globals()[&lt;STRONG&gt;func_name] = __get_hash(&lt;/STRONG&gt;func_name)&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/hashlib.py", line 97, in &lt;STRONG&gt;get_builtin_constructor&lt;BR /&gt;
    raise ValueError('unsupported hash type ' + name)&lt;BR /&gt;
ValueError: unsupported hash type md5&lt;BR /&gt;
ERROR:root:code for hash sha1 was not found.&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/hashlib.py", line 147, in &lt;BR /&gt;
    globals()[&lt;/STRONG&gt;func_name] = &lt;STRONG&gt;get_hash(&lt;/STRONG&gt;func_name)&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/hashlib.py", line 97, in &lt;STRONG&gt;get_builtin_constructor&lt;BR /&gt;
    raise ValueError('unsupported hash type ' + name)&lt;BR /&gt;
ValueError: unsupported hash type sha1&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "get_aqx_intersite_bw.py", line 40, in &lt;BR /&gt;
    from pysnmp.entity.rfc3413.oneliner import cmdgen&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 10, in &lt;BR /&gt;
    from pysnmp.hlapi.asyncore import *&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/hlapi/&lt;/STRONG&gt;init_&lt;EM&gt;.py", line 3, in &lt;BR /&gt;
    from pysnmp.hlapi.auth import *&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/hlapi/auth.py", line 7, in &lt;BR /&gt;
    from pysnmp.entity import config&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/entity/config.py", line 9, in &lt;BR /&gt;
    from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha, noauth&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/proto/secmod/rfc3414/&lt;/EM&gt;&lt;EM&gt;init&lt;/EM&gt;_.py", line 1, in &lt;BR /&gt;
    from pysnmp.proto.secmod.rfc3414 import service&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/proto/secmod/rfc3414/service.py", line 9, in &lt;BR /&gt;
    from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha, noauth&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py", line 10, in &lt;BR /&gt;
    import md5&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/md5.py", line 10, in &lt;BR /&gt;
    from hashlib import md5&lt;BR /&gt;
ImportError: cannot import name md5&lt;/P&gt;

&lt;P&gt;Please, can someone help me figure out how to use the pysnmp (and its dependencies) with a python script in Splunk? Thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 16:47:35 GMT</pubDate>
    <dc:creator>EricLloyd79</dc:creator>
    <dc:date>2020-09-29T16:47:35Z</dc:date>
    <item>
      <title>Using alternate Python for script data inputs</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Using-alternate-Python-for-script-data-inputs/m-p/370249#M67187</link>
      <description>&lt;P&gt;We are trying to do some snmp queries using Python and input the output key-value pairs into Splunk.&lt;BR /&gt;
We want to use pysnmp to do this.&lt;BR /&gt;
Pysnmp (or its dependencies) do not come standard with the Splunk python libraries.&lt;/P&gt;

&lt;P&gt;I have attempted putting "#!/root/anaconda2/python" in the first line of our script.  But it does not read from the Anaconda Python version we want it to.  I am concerned if it does, even, are there specific Splunk-related libraries that Splunk needs to handle the output of these scripts that won't be located in the Anaconda python version.&lt;/P&gt;

&lt;P&gt;From another similar question, I tried using: &lt;/P&gt;

&lt;P&gt;import sys&lt;BR /&gt;
sys.path.append('root/anaconda2/bin/python')&lt;BR /&gt;
sys.path.append('/root/anaconda2/lib/python2.7/site-packages')&lt;/P&gt;

&lt;P&gt;This sorta seems to work but now I'm getting an issue seen below:&lt;BR /&gt;
ERROR:root:code for hash md5 was not found.&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/hashlib.py", line 147, in &lt;BR /&gt;
    globals()[&lt;STRONG&gt;func_name] = __get_hash(&lt;/STRONG&gt;func_name)&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/hashlib.py", line 97, in &lt;STRONG&gt;get_builtin_constructor&lt;BR /&gt;
    raise ValueError('unsupported hash type ' + name)&lt;BR /&gt;
ValueError: unsupported hash type md5&lt;BR /&gt;
ERROR:root:code for hash sha1 was not found.&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/hashlib.py", line 147, in &lt;BR /&gt;
    globals()[&lt;/STRONG&gt;func_name] = &lt;STRONG&gt;get_hash(&lt;/STRONG&gt;func_name)&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/hashlib.py", line 97, in &lt;STRONG&gt;get_builtin_constructor&lt;BR /&gt;
    raise ValueError('unsupported hash type ' + name)&lt;BR /&gt;
ValueError: unsupported hash type sha1&lt;BR /&gt;
Traceback (most recent call last):&lt;BR /&gt;
  File "get_aqx_intersite_bw.py", line 40, in &lt;BR /&gt;
    from pysnmp.entity.rfc3413.oneliner import cmdgen&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 10, in &lt;BR /&gt;
    from pysnmp.hlapi.asyncore import *&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/hlapi/&lt;/STRONG&gt;init_&lt;EM&gt;.py", line 3, in &lt;BR /&gt;
    from pysnmp.hlapi.auth import *&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/hlapi/auth.py", line 7, in &lt;BR /&gt;
    from pysnmp.entity import config&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/entity/config.py", line 9, in &lt;BR /&gt;
    from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha, noauth&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/proto/secmod/rfc3414/&lt;/EM&gt;&lt;EM&gt;init&lt;/EM&gt;_.py", line 1, in &lt;BR /&gt;
    from pysnmp.proto.secmod.rfc3414 import service&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/proto/secmod/rfc3414/service.py", line 9, in &lt;BR /&gt;
    from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha, noauth&lt;BR /&gt;
  File "/root/anaconda2/lib/python2.7/site-packages/pysnmp/proto/secmod/rfc3414/auth/hmacmd5.py", line 10, in &lt;BR /&gt;
    import md5&lt;BR /&gt;
  File "/opt/splunk/lib/python2.7/md5.py", line 10, in &lt;BR /&gt;
    from hashlib import md5&lt;BR /&gt;
ImportError: cannot import name md5&lt;/P&gt;

&lt;P&gt;Please, can someone help me figure out how to use the pysnmp (and its dependencies) with a python script in Splunk? Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Using-alternate-Python-for-script-data-inputs/m-p/370249#M67187</guid>
      <dc:creator>EricLloyd79</dc:creator>
      <dc:date>2020-09-29T16:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using alternate Python for script data inputs</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Using-alternate-Python-for-script-data-inputs/m-p/370250#M67188</link>
      <description>&lt;P&gt;Any reason you would not use &lt;A href="https://splunkbase.splunk.com/app/1537/"&gt;https://splunkbase.splunk.com/app/1537/&lt;/A&gt;&lt;BR /&gt;
Uses pysnmp and has been downloaded something like 15K+ times&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 21:10:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Using-alternate-Python-for-script-data-inputs/m-p/370250#M67188</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2017-11-14T21:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using alternate Python for script data inputs</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Using-alternate-Python-for-script-data-inputs/m-p/370251#M67189</link>
      <description>&lt;P&gt;Well that looks nice.  Im doing what I was told to do and how it was done previously in PHP now in Python.&lt;BR /&gt;
A deterministic factor is that we have to retrieve the SNMP MIBs based on their ifDesc rather than their index.  I don't know if this has that capability.  I will have to confirm I have permission to download this app to our indexers and see if its capable.&lt;BR /&gt;
In the meantime, if there was a solution to use an alternate Python library for Python scripts in Splunk that'd be nice since I've got the scripts created and ready to ingest.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Nov 2017 21:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Using-alternate-Python-for-script-data-inputs/m-p/370251#M67189</guid>
      <dc:creator>EricLloyd79</dc:creator>
      <dc:date>2017-11-14T21:22:37Z</dc:date>
    </item>
  </channel>
</rss>

