<?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: Why is Splunk for Unix VMStat.sh Script Calculating Incorrectly in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-Splunk-for-Unix-VMStat-sh-Script-Calculating-Incorrectly/m-p/218054#M23766</link>
    <description>&lt;P&gt;It's actually quite simple: &lt;A href="http://www.linuxatemyram.com/"&gt;http://www.linuxatemyram.com/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In short, the applications on your host are not actually using 97% of your ram, they're only actually using about 26%. &lt;/P&gt;

&lt;P&gt;See the Buffers and Cached columns on your free statement? Your linux kernel is using the available RAM to make your disk accesses faster. If you had an application that needed RAM, a part of this cache will be freed up and made available to the application. &lt;/P&gt;

&lt;P&gt;Your second line output to free probably looks like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;              total       used       free     shared    buffers     cached
 Mem:        128950     127061       1889          0       1157      92060
-/+ buffers/cache:       33844      95106
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This second line is where your free/used numbers because that's what is used by / available to applications&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jan 2017 23:17:28 GMT</pubDate>
    <dc:creator>acharlieh</dc:creator>
    <dc:date>2017-01-04T23:17:28Z</dc:date>
    <item>
      <title>Why is Splunk for Unix VMStat.sh Script Calculating Incorrectly</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-Splunk-for-Unix-VMStat-sh-Script-Calculating-Incorrectly/m-p/218053#M23765</link>
      <description>&lt;P&gt;VMStat is either interpreting incorrectly OR is calculating incorrectly&lt;/P&gt;

&lt;P&gt;the script is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;. `dirname $0`/common.sh

HEADER='memTotalMB   memFreeMB   memUsedMB  memFreePct  memUsedPct   pgPageOut  swapUsedPct   pgSwapOut   cSwitches  interrupts       forks   processes     threads  loadAvg1mi'
HEADERIZE="BEGIN {print \"$HEADER\"}"
PRINTF='END {printf "%10d  %10d  %10d  %10.1f  %10.1f  %10s   %10.1f  %10s  %10s  %10s  %10s  %10s  %10s  %10.2f\n", memTotalMB, memFreeMB, memUsedMB, memFreePct, memUsedPct, pgPageOut, swapUsedPct, pgSwapOut, cSwitches, interrupts, forks, processes, threads, loadAvg1mi}'
DERIVE='END {memUsedMB=memTotalMB-memFreeMB; memUsedPct=(100.0*memUsedMB)/memTotalMB; memFreePct=100.0-memUsedPct; swapUsedPct=swapUsed ? (100.0*swapUsed)/(swapUsed+swapFree) : 0}'

    if [ "x$KERNEL" = "xLinux" ] ; then
            assertHaveCommand uptime
            assertHaveCommand ps
            assertHaveCommand vmstat
            CMD='eval uptime ; ps -e | wc -l ; ps -eT | wc -l ; vmstat -s'
            PARSE_0='NR==1 {loadAvg1mi=0+$(NF-2)} NR==2 {processes=$1} NR==3 {threads=$1}'
            PARSE_1='/total memory$/ {memTotalMB=$1/1024} /free memory$/ {memFreeMB+=$1/1024} /buffer memory$/ {memFreeMB+=$1/1024} /swap cache$/ {memFreeMB+=$1/1024}'
            PARSE_2='/pages paged out$/ {pgPageOut=$1} /used swap$/ {swapUsed=$1} /free swap$/ {swapFree=$1} /pages swapped out$/ {pgSwapOut=$1}'
            PARSE_3='/interrupts$/ {interrupts=$1} /CPU context switches$/ {cSwitches=$1} /forks$/ {forks=$1}'
            MASSAGE="$PARSE_0 $PARSE_1 $PARSE_2 $PARSE_3 $DERIVE"

    $CMD | tee $TEE_DEST | $AWK "$HEADERIZE $MASSAGE $FILL_BLANKS $PRINTF"  header="$HEADER"
    echo "Cmd = [$CMD];  | $AWK '$HEADERIZE $MASSAGE $FILL_BLANKS $PRINTF' header=\"$HEADER\"" &amp;gt;&amp;gt; $TEE_DEST
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which results in:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/opt/splunkforwarder/etc/apps/TA-stubhub-all-lin-uf-SplunkforUnix/bin/vmstat.sh
memTotalMB   memFreeMB   memUsedMB  memFreePct  memUsedPct   pgPageOut  swapUsedPct   pgSwapOut   cSwitches  interrupts       forks   processes     threads  loadAvg1mi
    128950       95092       33858        73.7        26.3  8266537986          2.7      156773  1430358599  1540011497   566455287         769        1182        0.38
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;BUT &lt;/P&gt;

&lt;P&gt;when I go to the host, I can run the command from above  and see these numbers are incorrect &lt;/P&gt;

&lt;P&gt;eval uptime ; ps -e | wc -l ; ps -eT | wc -l ; vmstat -s&lt;BR /&gt;
 20:26:10 up 332 days, 21:21,  1 user,  load average: 0.77, 0.70, 0.75&lt;BR /&gt;
761&lt;BR /&gt;
1199&lt;BR /&gt;
    132045632  total memory&lt;BR /&gt;
    130138512  used memory&lt;BR /&gt;
    109152400  active memory&lt;BR /&gt;
     10666064  inactive memory&lt;BR /&gt;
      1907120  free memory&lt;BR /&gt;
      1185436  buffer memory&lt;BR /&gt;
     94279704  swap cache&lt;BR /&gt;
      8388604  total swap&lt;BR /&gt;
       224172  used swap&lt;BR /&gt;
      8164432  free swap&lt;BR /&gt;
   1506464540 non-nice user cpu ticks&lt;BR /&gt;
         5413 nice user cpu ticks&lt;BR /&gt;
    183450991 system cpu ticks&lt;BR /&gt;
 136289253029 idle cpu ticks&lt;BR /&gt;
      1112025 IO-wait cpu ticks&lt;BR /&gt;
        15060 IRQ cpu ticks&lt;BR /&gt;
      6827407 softirq cpu ticks&lt;BR /&gt;
            0 stolen cpu ticks&lt;BR /&gt;
    153941247 pages paged in&lt;BR /&gt;
   8265286006 pages paged out&lt;BR /&gt;
        83885 pages swapped in&lt;BR /&gt;
       156773 pages swapped out&lt;BR /&gt;
   1534356594 interrupts&lt;BR /&gt;
   1419375615 CPU context switches&lt;BR /&gt;
   1454713450 boot time&lt;BR /&gt;
    566387546 forks&lt;/P&gt;

&lt;P&gt;This host is roughly 97% used and 3% free&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;free -m
             total       used       free     shared    buffers     cached
Mem:        128950     127061       1889          0       1157      92060
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Jan 2017 21:24:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-Splunk-for-Unix-VMStat-sh-Script-Calculating-Incorrectly/m-p/218053#M23765</guid>
      <dc:creator>tkwaller</dc:creator>
      <dc:date>2017-01-03T21:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Why is Splunk for Unix VMStat.sh Script Calculating Incorrectly</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-Splunk-for-Unix-VMStat-sh-Script-Calculating-Incorrectly/m-p/218054#M23766</link>
      <description>&lt;P&gt;It's actually quite simple: &lt;A href="http://www.linuxatemyram.com/"&gt;http://www.linuxatemyram.com/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;In short, the applications on your host are not actually using 97% of your ram, they're only actually using about 26%. &lt;/P&gt;

&lt;P&gt;See the Buffers and Cached columns on your free statement? Your linux kernel is using the available RAM to make your disk accesses faster. If you had an application that needed RAM, a part of this cache will be freed up and made available to the application. &lt;/P&gt;

&lt;P&gt;Your second line output to free probably looks like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;              total       used       free     shared    buffers     cached
 Mem:        128950     127061       1889          0       1157      92060
-/+ buffers/cache:       33844      95106
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This second line is where your free/used numbers because that's what is used by / available to applications&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2017 23:17:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Why-is-Splunk-for-Unix-VMStat-sh-Script-Calculating-Incorrectly/m-p/218054#M23766</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2017-01-04T23:17:28Z</dc:date>
    </item>
  </channel>
</rss>

