<?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 Re: unarchive_cmd for decoding binary file with python script in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353852#M64751</link>
    <description>&lt;P&gt;Bingo! That was exactly the problem.&lt;/P&gt;

&lt;P&gt;I was just coming back to correct my post and answer my own question but you all beat me to it.&lt;/P&gt;

&lt;P&gt;I did read this a few days ago and was certain I read somewhere it was only valid on sourcetype and not source. &lt;/P&gt;</description>
    <pubDate>Wed, 14 Jun 2017 23:58:24 GMT</pubDate>
    <dc:creator>phoenixdigital</dc:creator>
    <dc:date>2017-06-14T23:58:24Z</dc:date>
    <item>
      <title>unarchive_cmd for decoding binary file with python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353848#M64747</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;So following this excellent blog post I thought I found a solution to ingesting a binary logfile with Splunk.&lt;BR /&gt;
&lt;A href="https://www.splunk.com/blog/2011/07/19/the-naughty-bits-how-to-splunk-binary-logfiles.html"&gt;https://www.splunk.com/blog/2011/07/19/the-naughty-bits-how-to-splunk-binary-logfiles.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Unfortunately nothing is making it into Splunk at all.&lt;BR /&gt;
&lt;STRONG&gt;inputs.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor://$SPLUNK_HOME/etc/apps/TA-myBinary/spool/*.evl]
disabled = 0
index = myBinary
sourcetype = myBinary:evl
followTail = 0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;props.conf&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[myBinary:evl]
NO_BINARY_CHECK = true
invalid_cause = archive
unarchive_cmd = /opt/splunk/etc/apps/TA-myBinary/bin/decode_evl.py
unarchive_sourcetype = myBinary:evl:unarchived
priority = 10

TIME_FORMAT = %Y-%m-%d %H:%M:%S
SHOULD_LINEMERGE = false
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Some of those additional props entries (unarchive_sourcetype, priority) I discovered as attempts to resolve the issue from searching answers high and low.&lt;/P&gt;

&lt;P&gt;Sadly nothing makes it into Splunk and there are no errors during processing.&lt;/P&gt;

&lt;P&gt;The script runs just fine and will extract the data manually.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;cat ../spool/20170529.evl | ./decode_evl.py &amp;gt; ../spool/20170529.evl.out
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Initially I thought it might be my script not writing to stdout so I made sure it did that.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/usr/bin/python

import os, sys, json, time
from datetime import datetime
from HTMLParser import HTMLParser
import logging
import pprint
import binascii

..... decoding components......

while 1: 
    splunkEvent = readEvent()
    if len(splunkEvent['splunkMessage']) == 0:
        break

    sys.stdout.write(splunkEvent['splunkMessage'] + '\n')

# Flush out any extra data
sys.stdout.flush()

sys.exit()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;splunkd.log&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;06-15-2017 09:06:23.165 +1000 INFO  ArchiveProcessor - Handling file=/opt/splunk/etc/apps/TA-myBinary/spool/20170529.evl
06-15-2017 09:06:23.165 +1000 INFO  ArchiveProcessor - reading path=/opt/splunk/etc/apps/TA-myBinary/spool/20170529.evl (seek=0 len=59936626)
06-15-2017 09:06:23.324 +1000 INFO  ArchiveProcessor - Finished processing file '/opt/splunk/etc/apps/TA-myBinary/spool/20170529.evl', removing from stats
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now that I look at the above timings. This particular file takes at least 1 minute to parse the binary file and the three log events above all happen within a second of each other.&lt;/P&gt;

&lt;P&gt;Anyone with any thoughts on what could be wrong here?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 23:24:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353848#M64747</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2017-06-14T23:24:27Z</dc:date>
    </item>
    <item>
      <title>Re: unarchive_cmd for decoding binary file with python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353849#M64748</link>
      <description>&lt;P&gt;According to the docs for &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.1/Admin/Propsconf"&gt;props.conf&lt;/A&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;unarchive_cmd = &amp;lt;string&amp;gt;
* Only called if invalid_cause is set to "archive".
* This field is only valid on [source::&amp;lt;source&amp;gt;] stanzas.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Perhaps you need to add the unarchive portion in a stanza like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::$SPLUNK_HOME/etc/apps/TA-myBinary/spool/*.evl]
unarchive_cmd = /opt/splunk/etc/apps/TA-myBinary/bin/decode_evl.py
unarchive_sourcetype = myBinary:evl:unarchived
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It does look tricky, as some of the configs need to be in source stanzas, and others in sourcetype stanzas.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 23:31:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353849#M64748</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2017-06-14T23:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: unarchive_cmd for decoding binary file with python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353850#M64749</link>
      <description>&lt;P&gt;Hi phoenixdigital,&lt;/P&gt;

&lt;P&gt;looks like the option &lt;CODE&gt;unarchive_cmd&lt;/CODE&gt; in &lt;CODE&gt;props.conf&lt;/CODE&gt; is only valid on &lt;CODE&gt;source&lt;/CODE&gt; and NOT &lt;CODE&gt;sourcetype&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;unarchive_cmd = &amp;lt;string&amp;gt;
* Only called if invalid_cause is set to "archive".
* This field is only valid on [source::&amp;lt;source&amp;gt;] stanzas.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Also this option must be applied at input time. &lt;/P&gt;

&lt;P&gt;After reading the docs and the blog I now wonder which one is wrong ???&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 23:37:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353850#M64749</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-06-14T23:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: unarchive_cmd for decoding binary file with python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353851#M64750</link>
      <description>&lt;P&gt;HeHe, again failed on slow typing &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; well done Sir!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 23:38:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353851#M64750</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-06-14T23:38:37Z</dc:date>
    </item>
    <item>
      <title>Re: unarchive_cmd for decoding binary file with python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353852#M64751</link>
      <description>&lt;P&gt;Bingo! That was exactly the problem.&lt;/P&gt;

&lt;P&gt;I was just coming back to correct my post and answer my own question but you all beat me to it.&lt;/P&gt;

&lt;P&gt;I did read this a few days ago and was certain I read somewhere it was only valid on sourcetype and not source. &lt;/P&gt;</description>
      <pubDate>Wed, 14 Jun 2017 23:58:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353852#M64751</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2017-06-14T23:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: unarchive_cmd for decoding binary file with python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353853#M64752</link>
      <description>&lt;P&gt;Thanks again that was exactly the problem. I'm sure I read somewhere a few days ago that unarchive_cmd  had to be applied to sourcetypes only but there it is in black an white.&lt;/P&gt;

&lt;P&gt;It is working perfectly now.&lt;/P&gt;

&lt;P&gt;Sorry MuS had to unaccept your answer and give it to micahkemp who beat you by 6 minutes.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 00:00:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353853#M64752</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2017-06-15T00:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: unarchive_cmd for decoding binary file with python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353854#M64753</link>
      <description>&lt;P&gt;no worries! that is only fair to accept the first correct answer &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 00:02:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353854#M64753</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-06-15T00:02:31Z</dc:date>
    </item>
    <item>
      <title>Re: unarchive_cmd for decoding binary file with python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353855#M64754</link>
      <description>&lt;P&gt;One thing that has puzzled me about this "cheat" for ingesting binary data.&lt;/P&gt;

&lt;P&gt;What happens if new data is written to the end of these files?&lt;/P&gt;

&lt;P&gt;Does it reingest it all over again when new data is appended? &lt;/P&gt;

&lt;P&gt;Do I need to keep track of where I left off in my script or will Splunk just send me the new section of data?&lt;/P&gt;

&lt;P&gt;I'll find out in a few hours after some more testing no doubt.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 00:16:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353855#M64754</guid>
      <dc:creator>phoenixdigital</dc:creator>
      <dc:date>2017-06-15T00:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: unarchive_cmd for decoding binary file with python script</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353856#M64755</link>
      <description>&lt;P&gt;My guess would be that Splunk will keep track of the position where it last was in the file like any other input monitor. Please provide some feedback on this topic. &lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 07:16:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/unarchive-cmd-for-decoding-binary-file-with-python-script/m-p/353856#M64755</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2017-06-15T07:16:17Z</dc:date>
    </item>
  </channel>
</rss>

