juliojsb/sarviewer

ram.png negative values ?

centminmod opened this issue · 2 comments

On a idle server using data_collector.sh to grab a set sample and interval of sar memory stats seems to produce ram.png that shows negative memory usage ?

example of idle

03:18:51 AM kbmemfree kbmemused  %memused kbbuffers  kbcached  kbcommit   %commit  kbactive   kbinact   kbdirty
03:18:52 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
03:18:53 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
03:18:54 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
03:18:55 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
03:18:56 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
03:18:57 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
03:18:58 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
03:18:59 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
03:19:00 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
03:19:01 AM  14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0
Average:     14085804  18822948     57.20    552972  14613692  12406532     35.44   6276896  10072964         0

chart ends up something like

ram

I am using a forked version with a few cosmetic changes in script https://github.com/centminmod/sarviewer

looks like formula is off on CentOS 7 for used memory https://github.com/centminmod/sarviewer/blob/master/plotters/ram.gplot

plot '../data/ram.dat' using 1:($2/1024+$5/1024+$6/1024) title 'Free' with l ls 1, \
'' using 1:($5/1024) title 'Buffers' with l ls 2, \
'' using 1:($6/1024) title 'Cached' with l ls 3, \
'' using 1:($3/1024-$6/1024-$5/1024-$2/1024) title 'Used' with l ls 4

3rd column minus 6th minus 2nd

cat data/ram.dat 
03:16:29     14082768  18825984     57.21    552952  14614432  12413540     35.46   6279684  10073504        48
03:16:31     14082768  18825984     57.21    552952  14614432  12413540     35.46   6279760  10073504        48
03:16:33     14082768  18825984     57.21    552960  14614432  12413540     35.46   6279820  10073504        84
03:16:35     14082644  18826108     57.21    552960  14614432  12413540     35.46   6279820  10073512        84
03:16:37     14082644  18826108     57.21    552960  14614432  12413540     35.46   6279820  10073512        76
03:16:39     14082644  18826108     57.21    552960  14614432  12413540     35.46   6279820  10073512        52
03:16:41     14082644  18826108     57.21    552960  14614432  12413540     35.46   6279820  10073512        52
03:16:43     14082636  18826116     57.21    552960  14614432  12413540     35.46   6279820  10073512         0
03:16:45     14082636  18826116     57.21    552960  14614432  12413540     35.46   6279820  10073512         0
03:16:47     14083220  18825532     57.21    552960  14614432  12409348     35.45   6279820  10073512         0

change plotters/ram.gplot to

plot '../data/ram.dat' using 1:($2/1024+$5/1024+$6/1024) title 'Free' with l ls 1, \
'' using 1:($5/1024) title 'Buffers' with l ls 2, \
'' using 1:($6/1024) title 'Cached' with l ls 3, \
'' using 1:($3/1024) title 'Used' with l ls 4

seems to fix it

ram

Hi centminmod,

Thanks for checking and reporting this issue. I have been able to reproduce the error in Debian 8 Jessie and CentOS 7:

ram

Having in mind the following data sample:

21:20:42      8038840   8324832     50.87   1780656   3139748   6558300     12.98   2710332   3843708        68
21:20:47      8050712   8312960     50.80   1780768   3139428   6546288     12.95   2697788   3842928        68
21:20:52      8051908   8311764     50.79   1780784   3139432   6518876     12.90   2698484   3842932        96
21:20:57      8052992   8310680     50.79   1780784   3139432   6518816     12.90   2697912   3842928        96
21:21:02      8051872   8311800     50.79   1780792   3139432   6518360     12.90   2699532   3842932       692
21:21:07      8034112   8329560     50.90   1780792   3139432   6504604     12.87   2718252   3842920       368
21:21:12      8034780   8328892     50.90   1780808   3139396   6526308     12.91   2716180   3842920       336
21:21:17      8047320   8316352     50.82   1780816   3139396   6520980     12.90   2703268   3842920       276
21:21:22      8048152   8315520     50.82   1780816   3139396   6534688     12.93   2703600   3842920       872
21:21:27      8050720   8312952     50.80   1780816   3139396   6522080     12.90   2699660   3842916       316
21:21:32      8049008   8314664     50.81   1780816   3139396   6522320     12.91   2700252   3842916      1168
21:21:37      8050840   8312832     50.80   1780816   3139396   6495800     12.85   2699832   3842912        40
21:21:42      8037624   8326048     50.88   1780820   3139396   6517924     12.90   2713360   3842912        40
21:21:47      8034616   8329056     50.90   1780820   3139396   6512396     12.89   2715204   3842912        40
21:21:52      8024040   8339632     50.96   1780844   3139524   6551120     12.96   2728168   3842748       392
21:21:57      7959912   8403760     51.36   1780868   3139876   6567760     12.99   2791476   3842636      1088
21:22:02      7984440   8379232     51.21   1780888   3140088   6583168     13.03   2766176   3842768      1876
21:22:07      7969552   8394120     51.30   1780920   3139608   6590244     13.04   2780864   3842932      1376
21:22:12      7970660   8393012     51.29   1781040   3139904   6593488     13.05   2782444   3843244      1308
21:22:17      7984096   8379576     51.21   1781056   3140628   6594020     13.05   2766436   3843784      1448

And that:

  • Second column --> Free memory
  • Third column --> Used memory
  • Fifth column --> Buffers
  • Sixth column --> Cached

My idea was to get the used and free memory with the following formula:

  • Free memory = Free + buffers + cached
  • Used memory = Used - buffers - cached

So I just changed in plotters/ram.gplot the problematic line:

'' using 1:($3/1024-$6/1024-$5/1024-$2/1024) title 'Used' with l ls 4

To this:

'' using 1:($3/1024-$5/1024-$6/1024) title 'Used' with l ls 4

Getting now the following graph:

ram

Regards,
Julio

Thanks @juliojsb 👍