<?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: parse ps command in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/parse-ps-command/m-p/667958#M229173</link>
    <description>&lt;P&gt;Thanks all. I ended up using a modified version of&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229056"&gt;@FelixLeh&lt;/a&gt;&amp;nbsp;....it works well!&lt;/P&gt;</description>
    <pubDate>Wed, 08 Nov 2023 18:52:34 GMT</pubDate>
    <dc:creator>lorinj62</dc:creator>
    <dc:date>2023-11-08T18:52:34Z</dc:date>
    <item>
      <title>parse ps command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parse-ps-command/m-p/667601#M229031</link>
      <description>&lt;P&gt;I have events like this :&lt;/P&gt;&lt;P&gt;11/06/2023 12:34:56 ip 1.2.3.4 This is record 1 of 5&lt;BR /&gt;USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND&lt;BR /&gt;user 1 1.0 0.0 2492 604 ? Ss 12:27 0:00 proc01&lt;BR /&gt;user 6 0.5 0.0 2608 548 ? S 12:27 0:00 proc02&lt;BR /&gt;user 19 0.0 0.0 12168 7088 ? S 12:27 0:00 proc03&lt;BR /&gt;user 223 0.0 0.1 852056 39300 ? Ssl 12:27 0:00 proc04&lt;BR /&gt;user 470 0.0 0.0 7844 6016 pts/0 Ss 12:27 0:00 proc05&lt;BR /&gt;user 683 0.0 0.0 7872 3380 pts/0 R+ 12:37 0:00 proc06&lt;/P&gt;&lt;P&gt;11/06/2023 12:34:56 ip: 1.2.3.4 This is record 2 of 5&lt;BR /&gt;USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND&lt;BR /&gt;user 1 0.0 0.0 2492 604 ? Ss 12:27 0:00 proc07&lt;BR /&gt;user 6 9.0 0.0 2608 548 ? S 12:27 0:00 proc08&lt;BR /&gt;user 19 6.0 0.0 12168 7088 ? S 12:27 0:00 proc09&lt;BR /&gt;user 223 0.0 0.1 852056 39300 ? Ssl 12:27 0:00 proc10&lt;BR /&gt;user 470 0.0 0.0 7844 6016 pts/0 Ss 12:27 0:00 proc11&lt;BR /&gt;user 683 0.0 0.0 7872 3380 pts/0 R+ 12:37 0:00 proc12&lt;/P&gt;&lt;P&gt;and repeating with different data, but the same structure: record 1 of 18...record 2 of 18...etc.&lt;/P&gt;&lt;P&gt;The dates and times are the same for each "subsection" of the ps command.&lt;/P&gt;&lt;P&gt;I want to be able to make a graph of each "proc" to show their cpu and memory usage over time. The processes will be in a random order. I have the time line parsed with fields extracted (like the ip), and want the header of the ps command to be field names for the ps data.&lt;/P&gt;&lt;P&gt;I'm struggling with this! I tried mvepand and/or max_match=0 but failed.&lt;/P&gt;&lt;P&gt;Thanks for any help.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 17:47:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parse-ps-command/m-p/667601#M229031</guid>
      <dc:creator>lorinj62</dc:creator>
      <dc:date>2023-11-06T17:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: parse ps command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parse-ps-command/m-p/667658#M229047</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=_raw "(?&amp;lt;header&amp;gt;[^\n]+)"
| eval temp = split(_raw,"
")
| mvexpand temp
| regex temp="proc\d+"
| rex field=temp "(?&amp;lt;USER&amp;gt;[^\s]+)\s(?&amp;lt;PID&amp;gt;[^\s]+)\s(?&amp;lt;CPU&amp;gt;[^\s]+)\s(?&amp;lt;MEM&amp;gt;[^\s]+)\s(?&amp;lt;VSZ&amp;gt;[^\s]+)\s(?&amp;lt;RSS&amp;gt;[^\s]+)\s(?&amp;lt;TTY&amp;gt;[^\s]+)\s(?&amp;lt;STAT&amp;gt;[^\s]+)\s(?&amp;lt;START&amp;gt;[^\s]+)\s(?&amp;lt;TIME&amp;gt;[^\s]+)\s(?&amp;lt;COMMAND&amp;gt;[^\s]+)"
| rename CPU as "%CPU" MEM as "%MEM"
| fields - temp&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can then use transforming commands with the COMMAND field (procs).&lt;BR /&gt;Also be careful to keep the new line in the query in the split command to split correctly. If that doesnt work try "\n" instead.&lt;/P&gt;&lt;P&gt;EDIT: The Version from&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; with mvindex is simpler...&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 10:56:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parse-ps-command/m-p/667658#M229047</guid>
      <dc:creator>FelixLeh</dc:creator>
      <dc:date>2023-11-07T10:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: parse ps command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parse-ps-command/m-p/667670#M229050</link>
      <description>&lt;P&gt;Assuming each event contains the timestamp line, followed by a header line, then lines for each process, you could try something like this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval process=mvindex(split(_raw,"
"),2,-1)
| mvexpand process
| rex field=process "(?&amp;lt;USER&amp;gt;[^\s]+)\s+(?&amp;lt;PID&amp;gt;[^\s]+)\s+(?&amp;lt;CPU&amp;gt;[^\s]+)\s+(?&amp;lt;MEM&amp;gt;[^\s]+)\s+(?&amp;lt;VSZ&amp;gt;[^\s]+)\s+(?&amp;lt;RSS&amp;gt;[^\s]+)\s+(?&amp;lt;TTY&amp;gt;[^\s]+)\s+(?&amp;lt;STAT&amp;gt;[^\s]+)\s+(?&amp;lt;START&amp;gt;[^\s]+)\s+(?&amp;lt;TIME&amp;gt;[^\s]+)\s+(?&amp;lt;COMMAND&amp;gt;.*)"
| chart max(CPU) max(MEM) by _time PID&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2023 13:02:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parse-ps-command/m-p/667670#M229050</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-11-07T13:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: parse ps command</title>
      <link>https://community.splunk.com/t5/Splunk-Search/parse-ps-command/m-p/667958#M229173</link>
      <description>&lt;P&gt;Thanks all. I ended up using a modified version of&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/229056"&gt;@FelixLeh&lt;/a&gt;&amp;nbsp;....it works well!&lt;/P&gt;</description>
      <pubDate>Wed, 08 Nov 2023 18:52:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/parse-ps-command/m-p/667958#M229173</guid>
      <dc:creator>lorinj62</dc:creator>
      <dc:date>2023-11-08T18:52:34Z</dc:date>
    </item>
  </channel>
</rss>

