<?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 fix cpu by process search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/fix-cpu-by-process-search/m-p/54231#M13243</link>
    <description>&lt;P&gt;The *nix app has a cpu by process search that doesn't work under certain conditions:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index="os" sourcetype="ps" host="$host$" | multikv fields pctCPU, COMMAND | timechart avg(pctCPU) by COMMAND&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The problem is that if there are multiple processes running with the same command name in a single event, this will average them.  So 5 x foo processes, each consuming 3% cpu returns foo=3% when it's actually 15%.&lt;/P&gt;

&lt;P&gt;I fixed this by combining COMMAND with PID making it unique:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index="os" sourcetype="ps" host=$host$| multikv fields pctCPU, COMMAND, PID| strcat COMMAND "_" PID cmd | where pctCPU&amp;gt;0 | timechart avg(pctCPU) by cmd limit=0&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;but this is messy for systems with 50+ processes with the same COMMAND name and firefox doesn't seem to like &lt;CODE&gt;limit=0&lt;/CODE&gt;.  &lt;/P&gt;

&lt;P&gt;Ideally I could sum pctCPU within the event for all COMMANDS of the same name.  This would result in a single line on the chart for foo that shows 15% instead of 5 x lines that show foo_$pid at 3%.  Is this possible?&lt;/P&gt;</description>
    <pubDate>Sat, 05 Mar 2011 03:29:46 GMT</pubDate>
    <dc:creator>dinisco</dc:creator>
    <dc:date>2011-03-05T03:29:46Z</dc:date>
    <item>
      <title>fix cpu by process search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/fix-cpu-by-process-search/m-p/54231#M13243</link>
      <description>&lt;P&gt;The *nix app has a cpu by process search that doesn't work under certain conditions:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index="os" sourcetype="ps" host="$host$" | multikv fields pctCPU, COMMAND | timechart avg(pctCPU) by COMMAND&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The problem is that if there are multiple processes running with the same command name in a single event, this will average them.  So 5 x foo processes, each consuming 3% cpu returns foo=3% when it's actually 15%.&lt;/P&gt;

&lt;P&gt;I fixed this by combining COMMAND with PID making it unique:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index="os" sourcetype="ps" host=$host$| multikv fields pctCPU, COMMAND, PID| strcat COMMAND "_" PID cmd | where pctCPU&amp;gt;0 | timechart avg(pctCPU) by cmd limit=0&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;but this is messy for systems with 50+ processes with the same COMMAND name and firefox doesn't seem to like &lt;CODE&gt;limit=0&lt;/CODE&gt;.  &lt;/P&gt;

&lt;P&gt;Ideally I could sum pctCPU within the event for all COMMANDS of the same name.  This would result in a single line on the chart for foo that shows 15% instead of 5 x lines that show foo_$pid at 3%.  Is this possible?&lt;/P&gt;</description>
      <pubDate>Sat, 05 Mar 2011 03:29:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/fix-cpu-by-process-search/m-p/54231#M13243</guid>
      <dc:creator>dinisco</dc:creator>
      <dc:date>2011-03-05T03:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: fix cpu by process search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/fix-cpu-by-process-search/m-p/54232#M13244</link>
      <description>&lt;P&gt;You're right. This might do it:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="os" sourcetype="ps" host="$host$" | multikv fields pctCPU, COMMAND | stats sum(pctCPU) as pctCPU by _time,COMMAND | timechart avg(pctCPU) by COMMAND
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;i.e., sum the CPU up for each command at each measurement (i.e. that share the same _time) before you bucket and average.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Mar 2011 07:28:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/fix-cpu-by-process-search/m-p/54232#M13244</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2011-03-05T07:28:29Z</dc:date>
    </item>
    <item>
      <title>Re: fix cpu by process search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/fix-cpu-by-process-search/m-p/54233#M13245</link>
      <description>&lt;P&gt;that did it, so simple.  Thank you kindly, much appreciated.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Mar 2011 07:34:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/fix-cpu-by-process-search/m-p/54233#M13245</guid>
      <dc:creator>dinisco</dc:creator>
      <dc:date>2011-03-10T07:34:11Z</dc:date>
    </item>
  </channel>
</rss>

