<?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: How to write a search to output a table showing open ports by host? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177331#M50994</link>
    <description>&lt;P&gt;Thanks! I added a minor tweak by renaming the fields as it was only working on the first event, then reverting back to showing all port states (open/closed/filtered). Great idea of using mvzip to stitch the fields together then using rex. Appreciate your help, thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 12 Aug 2014 16:58:08 GMT</pubDate>
    <dc:creator>darthsplunk</dc:creator>
    <dc:date>2014-08-12T16:58:08Z</dc:date>
    <item>
      <title>How to write a search to output a table showing open ports by host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177325#M50988</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I'm having problems using mvfilter to filter out NULL strings. This is my search:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
index=nmap* | eval state=mvfilter(match(dest_port_state, "open")) | eval state=mvfilter(state!=NULL) | table dest, dest_port, transport, state, app&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;I've looked at examples that others are using to achieve the same thing and they appear to be the same as the search I am using, however Splunk is returning the following error:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
"Error in 'eval' command: The arguments to the 'mvfilter' function are invalid. "&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;When I enter a string in quotes such as&lt;CODE&gt; state!="test" &lt;/CODE&gt;or values such as &lt;CODE&gt;state!=123&lt;/CODE&gt; I get no error... Splunk isn't recognising &lt;CODE&gt;NULL&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Any thoughts?&lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;

&lt;P&gt;** Update **&lt;/P&gt;

&lt;P&gt;So it seems that my approach is wrong, as taking out the NULL eval shows the open port as port 7, however looking at the RAW event, the open port is in fact 23 (telnet). &lt;/P&gt;

&lt;P&gt;I have the following event:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&lt;BR /&gt;
Nmap scan report for 10.10.10.10&lt;BR /&gt;
Host is up (0.0024s latency).&lt;BR /&gt;
Scanned at 2014-07-10 17:08:07 BST for 42s&lt;BR /&gt;
PORT      STATE  SERVICE&lt;BR /&gt;
7/tcp     closed echo&lt;BR /&gt;
9/tcp     closed discard&lt;BR /&gt;
13/tcp    closed daytime&lt;BR /&gt;
21/tcp    closed ftp&lt;BR /&gt;
22/tcp    closed ssh&lt;BR /&gt;
23/tcp    open   telnet&lt;BR /&gt;
&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;After stripping my incorrect eval statements I'm back to:&lt;/P&gt;

&lt;P&gt;&lt;BR /&gt;
index=nmap* dest_port_state="open" | table dest, dest_port, transport, dest_port_state, app&lt;BR /&gt;
&lt;/P&gt;

&lt;P&gt;I want to write a search that will output a table showing open ports by host. I'm having problems filtering this correctly though. Any help would be appreciated!&lt;/P&gt;

&lt;P&gt;Thanks Again.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Aug 2014 23:06:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177325#M50988</guid>
      <dc:creator>darthsplunk</dc:creator>
      <dc:date>2014-08-10T23:06:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to output a table showing open ports by host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177326#M50989</link>
      <description>&lt;P&gt;Try using null() instead of NULL.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2014 14:42:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177326#M50989</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-08-11T14:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to output a table showing open ports by host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177327#M50990</link>
      <description>&lt;P&gt;Thanks for the response. Doesn't work I'm afriad. Hmm.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Aug 2014 16:23:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177327#M50990</guid>
      <dc:creator>darthsplunk</dc:creator>
      <dc:date>2014-08-11T16:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to output a table showing open ports by host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177328#M50991</link>
      <description>&lt;P&gt;This syntax works for me.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| eval state=mvfilter(state!="")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Have a look at this runanywhere query. (there is one null value in both Name and Age field)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|gentimes start=-1 | eval to="A:30 B:40 C: D:45 :50" | table to | makemv  to | mvexpand to | rex field=to "(?&amp;lt;Name&amp;gt;.*):(?&amp;lt;age&amp;gt;.*)"  | stats list(Name) as Name list(age) as Age | eval cName=mvcount(Name) | eval cAge=mvcount(Age) | eval Name1=mvfilter(Name!="")| eval Age1=mvfilter(Age!="") | eval cName1=mvcount(Name1) | eval cAge1=mvcount(Age1) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;There are 4 multivalued field and the filter is being applied on only one, hence the output is not correct. Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=nmap* dest_port_state="open" | table dest, dest_port, transport, dest_port_state, app | eval temp=mvzip(mvzip(mvzip(dest_port,transport,"#"),dest_port_state,"#"),app,"#") | eval temp=mvfilter(match(temp,"#open#")) | rex field=temp "(?&amp;lt;dest_port&amp;gt;.*)#(?&amp;lt;transport&amp;gt;.*)#(?&amp;lt;dest_port_state&amp;gt;.*)#(?&amp;lt;app&amp;gt;.*)" | fields - temp
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Aug 2014 19:20:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177328#M50991</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-08-11T19:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to output a table showing open ports by host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177329#M50992</link>
      <description>&lt;P&gt;Hi, thanks again for the response.&lt;/P&gt;

&lt;P&gt;Although this does not return an eval error, it does not produce the desired output. The data returned looks like:&lt;BR /&gt;
&lt;CODE&gt;&lt;BR /&gt;
dest          dest_port   transport   state   app&lt;BR /&gt;
10.10.10.10   7           tcp         open    echo&lt;BR /&gt;
              9           tcp                 discard&lt;BR /&gt;
              13          tcp                 daytime&lt;BR /&gt;
              21          tcp                 ftp&lt;BR /&gt;
              22          tcp                 ssh&lt;BR /&gt;
              23          tcp                 telnet&lt;BR /&gt;
&lt;/CODE&gt;&lt;BR /&gt;
The raw log indicates all ports are closed apart from telnet (port 23).&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2014 11:06:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177329#M50992</guid>
      <dc:creator>darthsplunk</dc:creator>
      <dc:date>2014-08-12T11:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to output a table showing open ports by host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177330#M50993</link>
      <description>&lt;P&gt;Try the updated answer.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2014 13:10:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177330#M50993</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-08-12T13:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to output a table showing open ports by host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177331#M50994</link>
      <description>&lt;P&gt;Thanks! I added a minor tweak by renaming the fields as it was only working on the first event, then reverting back to showing all port states (open/closed/filtered). Great idea of using mvzip to stitch the fields together then using rex. Appreciate your help, thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 12 Aug 2014 16:58:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177331#M50994</guid>
      <dc:creator>darthsplunk</dc:creator>
      <dc:date>2014-08-12T16:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to write a search to output a table showing open ports by host?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177332#M50995</link>
      <description>&lt;P&gt;The &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchReference/CommonEvalFunctions"&gt;documentation&lt;/A&gt; for &lt;CODE&gt;mvfilter&lt;/CODE&gt; seems to be incorrrect. I get the same error message as the original poster:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error in 'eval' command: The arguments to the 'mvfilter' function are invalid.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;when I use &lt;CODE&gt;mvfilter&lt;/CODE&gt; like this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval SessionEndTime = mvfilter (SessionEndTime != NULL)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Using &lt;CODE&gt;null()&lt;/CODE&gt; instead of &lt;CODE&gt;NULL&lt;/CODE&gt; does not work either; it gives me the error:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error in 'eval' command: Typechecking failed. The '!=' operator received different types.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;What &lt;EM&gt;does&lt;/EM&gt; seem to work is putting &lt;CODE&gt;NULL&lt;/CODE&gt; in quotes like this:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| eval SessionEndTime = mvfilter (SessionEndTime != "NULL")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2015 15:23:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-a-search-to-output-a-table-showing-open-ports-by/m-p/177332#M50995</guid>
      <dc:creator>helge</dc:creator>
      <dc:date>2015-04-07T15:23:39Z</dc:date>
    </item>
  </channel>
</rss>

