Ubuntu 16.04 memory usage incorrect.

Issue #474 resolved
Anonymous created an issue

After upgrading from Ubuntu 14.04 LTS to 16.04.01 LTS I have noticed that the memory usage reported is incorrect.

uname: uname -a
Linux zenhorst 4.4.0-38-generic #57-Ubuntu SMP Tue Sep 6 15:41:41 UTC 2016 i686 athlon i686 GNU/Linux

I'm using the monit version from the package manager: 5.16 which I cannot select below. It is possible to upgrade monit when requested since the latest and greatest is quite a bit newer. Would that be in a specific repository for Ubuntu or should I just download the installer from the website?

Memory usage is shown as: 100.0% [16.0 EB]
Logfile shows: mem usage of 100.0% matches resource limit [mem usage>80.0%] Unfortunately that is all that it shows, so no actual calculation information. Is there some debugging I can enable?

After consulting other memory issues reported here I found how memory is calculated: MemFree + Buffers + Cached + SReclaimable Ticket #385/#430/#464 show old "free" memory overview, so not sure if related since this is since 16.04 LTS.

So looking at /proc/meminfo:

cat /proc/meminfo
MemTotal:        3586928 kB
MemFree:          204660 kB
MemAvailable:    2380140 kB
Buffers:          178864 kB
Cached:          2297752 kB
SwapCached:        19700 kB
Active:          1064828 kB
Inactive:        2181128 kB
Active(anon):     384940 kB
Inactive(anon):   413360 kB
Active(file):     679888 kB
Inactive(file):  1767768 kB
Unevictable:        3424 kB
Mlocked:            3424 kB
HighTotal:       2723656 kB
HighFree:          48580 kB
LowTotal:         863272 kB
LowFree:          156080 kB
SwapTotal:      15624184 kB
SwapFree:       15501108 kB
Dirty:               476 kB
Writeback:             0 kB
AnonPages:        759128 kB
Mapped:            75496 kB
Shmem:             26524 kB
Slab:             100236 kB
SReclaimable:      84676 kB
SUnreclaim:        15560 kB
KernelStack:        3528 kB
PageTables:         5128 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    17417648 kB
Committed_AS:    2364796 kB
VmallocTotal:     122880 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
AnonHugePages:    595968 kB
CmaTotal:              0 kB
CmaFree:               0 kB
HugePages_Total:       0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:       2048 kB
DirectMap4k:       34808 kB
DirectMap2M:      878592 kB

So the calculation comes down to: 198704 kB + 194884 kB + 2334120 kB + 66616 kB = 2794324 total: 3586928 kB

So the usage is not 100%.

Note that in 16.04LTS the memory calculations have changed. For example, the free command no longer contains the buffers/cache line.

free
              total        used        free      shared  buff/cache   available
Mem:        3586928      778228      198328       26236     2610372     2406888
Swap:      15624184      123428    15500756

As you can see, the buff/cache is not released but seems to be retained like in Java. Top information:

KiB Mem :  3586928 total,   201108 free,   776076 used,  2609744 buff/cache
KiB Swap: 15624184 total, 15500336 free,   123848 used.  2408724 avail Mem

Detail: swappiness is set to 0, and still it swaps for some reason. This could indicate that Ubuntu 16.04LTS memory calculations are a bit off in the first place.

Comments (6)

  1. Harold Snel

    This issue seems to be back!

    On a 64bit LXC virtual container running Ubuntu 17.10 and monit 5.25.2 I get this:

    root@kwp-php5-02:~# monit status Monit 5.25.2 uptime: 1h 6m

    System 'localhost' status OK monitoring status Monitored monitoring mode active on reboot start load average [0.16] [0.13] [0.21] cpu 0.5%us 0.2%sy 0.0%wa memory usage 16 EB [115292151808.0%] swap usage 58.2 MB [1.4%] uptime 13d 14h 13m boot time Thu, 03 Jan 2019 21:38:50 data collected Thu, 17 Jan 2019 11:51:04

    === The machine has been give 16GB memory. So not 16 EB :-)

  2. Harold Snel

    nothing special. I removed (<removed>) our m/monit hostname:

    [CET Jan 17 14:08:28] debug : Shutting down Monit HTTP server [CET Jan 17 14:08:28] debug : Monit HTTP server stopped [CET Jan 17 14:08:28] info : M/Monit heartbeat stopped [CET Jan 17 14:08:28] info : Monit daemon with pid [3317] stopped [CET Jan 17 14:08:28] info : 'localhost' Monit 5.25.2 stopped [CET Jan 17 14:08:28] debug : M/Monit: event message sent to http://[<removed>]:8080/collector [CET Jan 17 14:08:28] debug : pidfile '/var/run/monit.pid' does not exist [CET Jan 17 14:08:28] info : Starting Monit 5.25.2 daemon with http interface at []:2812 [CET Jan 17 14:08:28] debug : Starting Monit HTTP server at []:2812 [CET Jan 17 14:08:28] debug : Monit HTTP server started [CET Jan 17 14:08:28] info : 'localhost' Monit 5.25.2 started [CET Jan 17 14:08:28] debug : M/Monit: event message sent to http://[<removed>]:8080/collector [CET Jan 17 14:08:28] info : M/Monit heartbeat started [CET Jan 17 14:08:28] debug : Processing postponed events queue [CET Jan 17 14:08:28] debug : 'localhost' swap usage check succeeded [current swap usage = 1.4%] [CET Jan 17 14:08:28] error : 'localhost' mem usage of 115292151808.0% matches resource limit [mem usage > 85.0%] [CET Jan 17 14:08:28] debug : M/Monit: status message sent to http://[<removed>]:8080/collector [CET Jan 17 14:08:28] debug : M/Monit: event message sent to http://[<removed>]:8080/collector

  3. Log in to comment