<?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 Streaming with Python in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Modular-Input-Streaming-with-Python/m-p/158632#M32161</link>
    <description>&lt;P&gt;So I have been reading the documentation on how to create modular inputs using the Python SDK here&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAER3" target="_blank"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAER3&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;And I tested the random_number example from the SDK and it seems the random number is only generated when Splunk starts.&lt;/P&gt;

&lt;P&gt;So as a learning exercise I tried to add a new parameter called 'interval' which will cause the number to generate every x seconds.&lt;/P&gt;

&lt;P&gt;After a few failed attempts with indent errors in the script I finally got this to run without error&lt;BR /&gt;
/opt/splunk/bin/splunk cmd /opt/splunk/bin/python /opt/splunk/etc/apps/random_numbers/bin/random_numbers.py&lt;/P&gt;

&lt;P&gt;I restarted Splunk no data is coming in?&lt;/P&gt;

&lt;P&gt;My new module input script is here&lt;BR /&gt;
&lt;A href="http://pastebin.com/TwVbHiUp" target="_blank"&gt;http://pastebin.com/TwVbHiUp&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;and my input.spec.conf is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[random_numbers://&amp;lt;name&amp;gt;]
*Generates events containing a random floating point number.

min = &amp;lt;value&amp;gt;
max = &amp;lt;value&amp;gt;
interval = &amp;lt;value&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Am I going about this the wrong way?&lt;/P&gt;

&lt;P&gt;My final goal is to write something to listen to systemd journal. But I need to get past this hurdle of having something permanently running in the background either generating numbers in this case or listening to systemd down the track.&lt;BR /&gt;
&lt;A href="http://www.freedesktop.org/software/systemd/python-systemd/journal.html" target="_blank"&gt;http://www.freedesktop.org/software/systemd/python-systemd/journal.html&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 17:50:59 GMT</pubDate>
    <dc:creator>phoenixdigital</dc:creator>
    <dc:date>2020-09-28T17:50:59Z</dc:date>
    <item>
      <title>Modular Input Streaming with Python</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Modular-Input-Streaming-with-Python/m-p/158632#M32161</link>
      <description>&lt;P&gt;So I have been reading the documentation on how to create modular inputs using the Python SDK here&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/python-sdk/SP-CAAAER3" target="_blank"&gt;http://dev.splunk.com/view/python-sdk/SP-CAAAER3&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;And I tested the random_number example from the SDK and it seems the random number is only generated when Splunk starts.&lt;/P&gt;

&lt;P&gt;So as a learning exercise I tried to add a new parameter called 'interval' which will cause the number to generate every x seconds.&lt;/P&gt;

&lt;P&gt;After a few failed attempts with indent errors in the script I finally got this to run without error&lt;BR /&gt;
/opt/splunk/bin/splunk cmd /opt/splunk/bin/python /opt/splunk/etc/apps/random_numbers/bin/random_numbers.py&lt;/P&gt;

&lt;P&gt;I restarted Splunk no data is coming in?&lt;/P&gt;

&lt;P&gt;My new module input script is here&lt;BR /&gt;
&lt;A href="http://pastebin.com/TwVbHiUp" target="_blank"&gt;http://pastebin.com/TwVbHiUp&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;and my input.spec.conf is&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[random_numbers://&amp;lt;name&amp;gt;]
*Generates events containing a random floating point number.

min = &amp;lt;value&amp;gt;
max = &amp;lt;value&amp;gt;
interval = &amp;lt;value&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Am I going about this the wrong way?&lt;/P&gt;

&lt;P&gt;My final goal is to write something to listen to systemd journal. But I need to get past this hurdle of having something permanently running in the background either generating numbers in this case or listening to systemd down the track.&lt;BR /&gt;
&lt;A href="http://www.freedesktop.org/software/systemd/python-systemd/journal.html" target="_blank"&gt;http://www.freedesktop.org/software/systemd/python-systemd/journal.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 17:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Modular-Input-Streaming-with-Python/m-p/158632#M32161</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2020-09-28T17:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: Modular Input Streaming with Python</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Modular-Input-Streaming-with-Python/m-p/158633#M32162</link>
      <description>&lt;P&gt;Never mind resolved it with this change&lt;BR /&gt;
&lt;A href="http://pastebin.com/JfTNxQEv"&gt;http://pastebin.com/JfTNxQEv&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;My intervals were not defined when I was referencing them.&lt;/P&gt;

&lt;P&gt;Going to have to change this a fair bit to spin off separate thread for each input in the loop&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            for input_name, input_item in inputs.inputs.iteritems():
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Would the best way to achieve this to have stream_events definition loop through all inputs and fire off a thread for each which has a while 1: in it?&lt;/P&gt;

&lt;P&gt;What closes these threads when new inputs are added via the GUI?&lt;/P&gt;

&lt;P&gt;Because if stream_events is called again there will be a second set of threads started. Do I have to put the smarts in to ensure two threads for the same input dont exist?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Oct 2014 04:43:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Modular-Input-Streaming-with-Python/m-p/158633#M32162</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2014-10-10T04:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Modular Input Streaming with Python</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Modular-Input-Streaming-with-Python/m-p/158634#M32163</link>
      <description>&lt;P&gt;Adding threading doesnt seem to work.&lt;BR /&gt;
&lt;A href="http://pastebin.com/r5QyYb0T"&gt;http://pastebin.com/r5QyYb0T&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Is there a better way I should be going about this?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Oct 2014 05:03:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Modular-Input-Streaming-with-Python/m-p/158634#M32163</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2014-10-10T05:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Modular Input Streaming with Python</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Modular-Input-Streaming-with-Python/m-p/158635#M32164</link>
      <description>&lt;P&gt;Ok it appears that threading was the wrong track to go down. &lt;/P&gt;

&lt;P&gt;The SDK supports single or multiple instances meaning that &lt;/P&gt;

&lt;P&gt;single instance - one script handles all of the data inputs&lt;BR /&gt;
multi instance - each input fires off its own version of the script&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.1.4/AdvancedDev/ModInputsScripts#Single_or_multiple_instances_of_a_script"&gt;http://docs.splunk.com/Documentation/Splunk/6.1.4/AdvancedDev/ModInputsScripts#Single_or_multiple_instances_of_a_script&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I tested it out again with the random numbers example&lt;/P&gt;

&lt;P&gt;single instance - &lt;A href="http://pastebin.com/77MMLqPz"&gt;http://pastebin.com/77MMLqPz&lt;/A&gt;&lt;BR /&gt;
multi instance example - &lt;A href="http://pastebin.com/idDqG7XY"&gt;http://pastebin.com/idDqG7XY&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Now to build the systemd modular input based on this new found knowledge.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Oct 2014 01:07:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Modular-Input-Streaming-with-Python/m-p/158635#M32164</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2014-10-16T01:07:26Z</dc:date>
    </item>
  </channel>
</rss>

