<?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 Modular input that need additional python modules in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187316#M2494</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;So I am trying to make a modular input which ingests the journal in newer LInux distributions which no longer log to a file.&lt;/P&gt;

&lt;P&gt;I have this test Python script which works from the command line.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import select
import systemd
from systemd import journal

j = systemd.journal.Reader()
#j.log_level(journal.LOG_DEBUG)

# j.add_match(_SYSTEMD_UNIT="systemd-udevd.service")
j.seek_tail()

# need to get previous event as seek_tail went right to the very end of the journal
j.get_previous()

p = select.poll()
p.register(j, j.get_events())

while p.poll():
    if j.process() != journal.APPEND:
        continue

    for entry in j:
        event = str(entry['__REALTIME_TIMESTAMP'])
        for key, value in entry.iteritems():
            event = event + ',' + str(key) + '="' + str(value).replace('"','\\"') + '"' 

        print event
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now the issue I have is when I try to add it to a modular input script. Splunk's Python obviously doesn't have the library for systemd and I get this error&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[root@phoenix bin]# /opt/splunk/bin/splunk cmd /opt/splunk/bin/python /opt/splunk/etc/apps/journal_input/bin/journal_input.py
Traceback (most recent call last):
  File "/opt/splunk/etc/apps/journal_input/bin/journal_input.py", line 20, in &amp;lt;module&amp;gt;
    from systemd import journal
ImportError: No module named systemd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Everything I have read says to leave Splunk's python alone and not to try to install custom modules.&lt;/P&gt;

&lt;P&gt;Does anyone have any suggestions how I can get this into a modular input or to get systemd accessible to Splunk's Python binary without having support freak out?&lt;/P&gt;</description>
    <pubDate>Tue, 17 Mar 2015 03:58:52 GMT</pubDate>
    <dc:creator>phoenixdigital</dc:creator>
    <dc:date>2015-03-17T03:58:52Z</dc:date>
    <item>
      <title>Modular input that need additional python modules</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187316#M2494</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;So I am trying to make a modular input which ingests the journal in newer LInux distributions which no longer log to a file.&lt;/P&gt;

&lt;P&gt;I have this test Python script which works from the command line.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import select
import systemd
from systemd import journal

j = systemd.journal.Reader()
#j.log_level(journal.LOG_DEBUG)

# j.add_match(_SYSTEMD_UNIT="systemd-udevd.service")
j.seek_tail()

# need to get previous event as seek_tail went right to the very end of the journal
j.get_previous()

p = select.poll()
p.register(j, j.get_events())

while p.poll():
    if j.process() != journal.APPEND:
        continue

    for entry in j:
        event = str(entry['__REALTIME_TIMESTAMP'])
        for key, value in entry.iteritems():
            event = event + ',' + str(key) + '="' + str(value).replace('"','\\"') + '"' 

        print event
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now the issue I have is when I try to add it to a modular input script. Splunk's Python obviously doesn't have the library for systemd and I get this error&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[root@phoenix bin]# /opt/splunk/bin/splunk cmd /opt/splunk/bin/python /opt/splunk/etc/apps/journal_input/bin/journal_input.py
Traceback (most recent call last):
  File "/opt/splunk/etc/apps/journal_input/bin/journal_input.py", line 20, in &amp;lt;module&amp;gt;
    from systemd import journal
ImportError: No module named systemd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Everything I have read says to leave Splunk's python alone and not to try to install custom modules.&lt;/P&gt;

&lt;P&gt;Does anyone have any suggestions how I can get this into a modular input or to get systemd accessible to Splunk's Python binary without having support freak out?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2015 03:58:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187316#M2494</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2015-03-17T03:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Modular input that need additional python modules</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187317#M2495</link>
      <description>&lt;P&gt;Hi, have a look on my comment on this topic: &lt;A href="http://answers.splunk.com/answers/109009/splunk6-django-app-importing-sqlite.html"&gt;http://answers.splunk.com/answers/109009/splunk6-django-app-importing-sqlite.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I basically download the source of same version of Python used by Splunk and compiled modules outsite... after that I moved the compiled modules to the Splunk/lib/python dir.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2015 04:32:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187317#M2495</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2015-03-17T04:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: Modular input that need additional python modules</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187318#M2496</link>
      <description>&lt;P&gt;Thanks this has definitely stopped the importing of the library issue.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;cp -r /usr/lib64/python2.7/site-packages/systemd /opt/splunk/lib/python2.7/site-packages/
chown -R splunk:users /opt/splunk/lib/python2.7/site-packages/
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I did want to try to avoid this however as I know Splunk officially does not recommend this.&lt;/P&gt;

&lt;P&gt;I note in your thread Splunk were looking into resolving the need for this in 2003. It seems they moved onto more important issues since.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2015 23:38:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187318#M2496</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2015-03-17T23:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Modular input that need additional python modules</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187319#M2497</link>
      <description>&lt;P&gt;There will be always the need to additional packages if you developed custom search/lookup scripts. I would prefer Splunk to ship the Python source/dev packages + virtualenv so would be easier to just run &lt;CODE&gt;pip install PKG_NAME&lt;/CODE&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Mar 2015 23:58:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187319#M2497</guid>
      <dc:creator>musskopf</dc:creator>
      <dc:date>2015-03-17T23:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Modular input that need additional python modules</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187320#M2498</link>
      <description>&lt;P&gt;Agreed it would make things a hell of a lot easier. I am guessing they don't want to support tweaking the Python libraries and in a way I can see why. &lt;/P&gt;

&lt;P&gt;Sadly it really limits the power of what we can achieve with modular and scripted inputs though.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2015 01:01:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Modular-input-that-need-additional-python-modules/m-p/187320#M2498</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2015-03-18T01:01:31Z</dc:date>
    </item>
  </channel>
</rss>

