Wrong used memory in SLES12
Hi.
I have wrong used memory in my SLES12SP4 server.
Jul 3 13:37:01 2019 version 6.01-0:|::::mem:::1056788356:1033513692:2327466431266936:1002246756:
in_use_work is 31G, but HTOP show
I find info (https://stackoverflow.com/questions/41224738/how-to-calculate-system-memory-usage-from-proc-meminfo-like-htop) and want correct algorithm memory calculate. I do this, but not see result.
Please, ask in wich strings in /opt/lpar2rrd-agent/lpar2rrd-agent.pl i can make changes?
I make changes in section ###Linux memory###, but cant see result, as ignored it.
P.S. you use $buffers (in $in_use_clnt) before define his value. In this secton (###Linux memory###).
I have wrong used memory in my SLES12SP4 server.
Jul 3 13:37:01 2019 version 6.01-0:|::::mem:::1056788356:1033513692:2327466431266936:1002246756:
in_use_work is 31G, but HTOP show
I find info (https://stackoverflow.com/questions/41224738/how-to-calculate-system-memory-usage-from-proc-meminfo-like-htop) and want correct algorithm memory calculate. I do this, but not see result.
Please, ask in wich strings in /opt/lpar2rrd-agent/lpar2rrd-agent.pl i can make changes?
I make changes in section ###Linux memory###, but cant see result, as ignored it.
[root@stor2rrd new]# cat lpar2rrd-agent.pl | grep -A 10 "#A#"
#A#
my $sreclaim = 0;
--
#A# add $sreclaim section
if ( $line =~ m/^SReclaimable/ ) {
( undef, $sreclaim ) = split( / +/, $line );
}
if ( $line =~ m/^Cached:/ ) {
#A#
##( undef, $in_use_clnt ) = split( / +/, $line );
##$in_use_clnt = $in_use_clnt + $buffers;
### Buffers must be added to Cached
( undef, $in_use_clnt ) = split( / +/, $line );
$in_use_clnt = $in_use_clnt + $sreclaim - $shared;
}
--
#A#
##$inuse = $size - $free - $in_use_clnt;
##$in_use_work = $inuse; # used mem without the FS cache - FS cache is not here!
##$inuse = $inuse + $in_use_clnt;
$inuse = $size - $free;
$in_use_work = $inuse - $in_use_clnt; # FS cache is here
P.S. you use $buffers (in $in_use_clnt) before define his value. In this secton (###Linux memory###).
Comments
-
Please, one a moment. I see, you scan output /proc/meminfo string by sting.
I need time to make algorinthm with this specific. -
OK, i make this changes and see result as HTOP (maked changes above section ###Linux memory###):testdb:/opt/lpar2rrd-agent # cat lpar2rrd-agent.pl | grep -A 10 "#A#"#A# add 2 varsmy $pcached = 0;my $sreclaim = 0;--#A# add if{}if ( $line =~ m/^SReclaimable:/ ) {( undef, $sreclaim ) = split( / +/, $line );}if ( $line =~ m/^Cached:/ ) {#A###( undef, $in_use_clnt ) = split( / +/, $line );##$in_use_clnt = $in_use_clnt + $buffers;### Buffers must be added to Cached( undef, $pcached ) = split( / +/, $line );}--#A###$inuse = $size - $free - $in_use_clnt;##$in_use_work = $inuse; # used mem without the FS cache - FS cache is not here!##$inuse = $inuse + $in_use_clnt;$inuse = $size - $free;$in_use_clnt = $pcached + $sreclaim - $shared;$in_use_work = $inuse - $in_use_clnt; # buffers is here
-
Why i need do this? In my server 1TiB RAM and many Oracle instances, and his can't use only 31GiB memory <span></span>
I compare output
# cat /proc/meminfo; free
and read article (link at top).
Can you make changes in Agent Lapr2RRD in future verions? -
P.S.
Need correct code:if ( $line =~ m/^Shmem/ ) {( undef, $shared ) = split( / +/, $line );
TOif ( $line =~ m/^Shmem:/ ) {( undef, $shared ) = split( / +/, $line );
Because in /proc/meminfo has:
ShmemShmemHugePagesShmemPmdMapped
Our need only "Shmem:" -
Hi,your right, fixed, do you want to get a rpm with that fix?Thanks!
-
Hi, Pavel
Yes, if it posible, i want RPM with fix.
For easy update, i have many Linux servers.
Thanks! -
Pavel, not for a long time of you, see this articles:
http://calimeroteknik.free.fr/blag/?article20/really-used-memory-on-gnu-linux
http://http//nopipi.hatenablog.com/entry/2015/09/13/181026 (translate to you lang)
Unfortunately, NMON have small of data about memory, and i need modify to $in_use_work value "active". (In my case Oracle RDBMS used Shmem) -
I do not understand
-
Hi, Pavel.
This topic i made when see, what LPAR Agent incorrect display used memory on my server.
On my server used Oracle RDBMS without HugePages, is used SharedMemory.
But current algorithm LPAR Agent do not use Shmem in calculation. Why? I search some articles, and find, what any programm calc used memory by any methods.
More simply it in pictures in articles, what i write links above.
For Linux, around string "###Linux memory###" LPAR Agent calc:
UsedMemory = MemTotal - MemFree - Cached - Buffers.
In articles you can see calc:
UsedMemory = MemTotal - MemFree - Cached - Buffers - SReclaimable + Shmem.
Can you analise this, and if it`s good, make changes in LPAR Agent script?
-
P.S. about NMon part script of LPAR Agent.
If my application on the server (SLES12) use SharedMemory, NMon too incorect display used memory. And NMon have very small parameters to right calculate UsedMemory.
In my case, i need use Active parameter, as UsedMemory:
( undef, undef, $size, undef, undef, undef, $free, undef, undef, undef, undef, $in_use_clnt, $nactive ) = split( /,/, $mem );
...$inuse = $size - $free;$in_use_work = $nactive * 1024;$in_use_clnt = $inuse - $in_use_work;
How make right calculating UsedMemory by NMon data (if used Shared Memory), i dont know now. -
I update Linux agent to version 6.15 and make changes to calc SharedMemory as Used (like algorithm in Htop program, actual for Oracle RDBMS)[root@stor2rrd 1]# diff /1/lpar2rrd-agent.pl /2/lpar2rrd-agent.pl126c126< my $version = "6.15-0";---> my $version = "6.15-0a";1497a1498,1500> ##add 2 vars> my $pcached = 0;> my $sreclaim = 0;1637a1641,1644> ##add IF> if ( $line =~ m/^SReclaimable:/ ) {> ( undef, $sreclaim ) = split( / +/, $line );> }1639,1641c1646,1649< ( undef, $in_use_clnt ) = split( / +/, $line );< $in_use_clnt = $in_use_clnt + $buffers;< # Buffers must be added to Cached---> #( undef, $in_use_clnt ) = split( / +/, $line );> #$in_use_clnt = $in_use_clnt + $buffers;> ## Buffers must be added to Cached> ( undef, $pcached ) = split( / +/, $line );1650,1652c1658,1663< $inuse = $size - $free - $in_use_clnt;< $in_use_work = $inuse; # used mem without the FS cache - FS cache is not here!< $inuse = $inuse + $in_use_clnt;---> #$inuse = $size - $free - $in_use_clnt;> #$in_use_work = $inuse; # used mem without the FS cache - FS cache is not here!> #$inuse = $inuse + $in_use_clnt;> $inuse = $size - $free;> $in_use_clnt = $pcached + $sreclaim - $shared;> $in_use_work = $inuse - $in_use_clnt; # buffers is here
-
Hi,can you show some example what was wrong and what is a solution? graph, command line etc.
-
testdb3:~ # freetotal used free shared buffers cachedMem: 528313444 211444856 316868588 158341632 1588816 185538936-/+ buffers/cache: 24317104 503996340Swap: 12585980 0 12585980
-
This changes based by article:
https://stackoverflow.com/questions/41224738/how-to-calculate-system-memory-usage-from-proc-meminfo-like-htop
-
shared is already part of used as per me, look below, then you are wrong as per me# free
total used free shared buffers cached
Mem: 528313444 211444856 316868588 158341632 1588816 185538936
-/+ buffers/cache: 24317104 503996340
Swap: 12585980 0 12585980
used+free+buffers ~= total
211444856+316868588+1588816=529902260 =~ 528313444
-
Hi, Pavel.Ok, but some correction, you use out not "free", but "cat /proc/meminfo" as:testdb3:~ # freetotal used free shared buffers cachedMem: 528313444 519418200 8895244 168357348 1491496 494083384-/+ buffers/cache: 23843320 504470124Swap: 12585980 0 12585980testdb3:~ # cat /proc/meminfoMemTotal: 528313444 kBMemFree: 8833812 kBMemAvailable: 331718428 kBBuffers: 1491512 kBCached: 480176436 kBSwapCached: 0 kBActive: 146629136 kBInactive: 350354912 kBActive(anon): 132600260 kBInactive(anon): 51080076 kBActive(file): 14028876 kBInactive(file): 299274836 kBUnevictable: 40540 kBMlocked: 40540 kBSwapTotal: 12585980 kBSwapFree: 12585980 kBDirty: 200 kBWriteback: 0 kBAnonPages: 15355576 kBMapped: 102649480 kBShmem: 168357480 kBSlab: 14865832 kBSReclaimable: 13907736 kBSUnreclaim: 958096 kBKernelStack: 78448 kBPageTables: 6734328 kBNFS_Unstable: 0 kBBounce: 0 kBWritebackTmp: 0 kBCommitLimit: 488068076 kBCommitted_AS: 292903228 kBVmallocTotal: 34359738367 kBVmallocUsed: 0 kBVmallocChunk: 0 kBHardwareCorrupted: 0 kBAnonHugePages: 0 kBShmemHugePages: 0 kBShmemPmdMapped: 0 kBHugePages_Total: 0HugePages_Free: 0HugePages_Rsvd: 0HugePages_Surp: 0Hugepagesize: 2048 kBDirectMap4k: 6617004 kBDirectMap2M: 294266880 kBDirectMap1G: 238026752 kBand define values:MemTotal: as $sizeMemFree: as $freeShmem: as $sharedCached:+$buffers(at monet as 0) $in_use_clnt+$buffersMemAvailable: as $availableBuffers: as $buffersfinal calc:$inuse = $size - $free - $in_use_clnt; (MemTotal - MemFree - Cached)$in_use_work = $inse; (MemTotal - MemFree - Cached)$inuse = $inuse + $in_use_clnt; (MemTotal - MemFree - Cached) + Cached = (MemTotal - MemFree)*) you DO NOT USE in calc: $shared, $buffers and $available. WHY?So, in numbers:MemTotal = 528 313 444MemFree = 8 833 812$in_use_work = 528313444 - 8833812 - 480176436 = 39 303 196$inuse = 528313444 - 8833812 = 519 479 632In your draw "FS cache" is ($inuse - $in_use_work) - is Cached - is 480176436.Command HTOP say: "Mem:504G used:184G buffers:1.42G cache:311G"Why HTOP used:184G but lpar2rrd in_use_work:39G ?Because, HTOP see "Shmem" and "SReclaimable".Total used memory = MemTotal - MemFreeNon cache/buffer memory (green) = Total used memory - (Buffers + Cached memory)Buffers (blue) = BuffersCached memory (yellow) = Cached + SReclaimable - ShmemSwap = SwapTotal - SwapFreeSo, HTOP calc "FS cache" = Buffers + (Cached + SReclaimable - Shmem).Calculate usage memory it not simple. I find article, online translate it, and see pictures (http://nopipi.hatenablog.com/entry/2015/09/13/181026)I think, calc used memory as HTOP more right. And my Oracle RDBMS let my see it.
Howdy, Stranger!
Categories
- 1.6K All Categories
- 41 XORMON NG
- 25 XORMON
- 150 LPAR2RRD
- 13 VMware
- 16 IBM i
- 2 oVirt / RHV
- 4 MS Windows and Hyper-V
- Solaris / OracleVM
- XenServer / Citrix
- Nutanix
- 6 Database
- 2 Cloud
- 10 Kubernetes / OpenShift / Docker
- 122 STOR2RRD
- 19 SAN
- 7 LAN
- 17 IBM
- 3 EMC
- 12 Hitachi
- 5 NetApp
- 15 HPE
- Lenovo
- 1 Huawei
- 1 Dell
- Fujitsu
- 2 DataCore
- INFINIDAT
- 3 Pure Storage
- Oracle