1

I'm running Debian 8 with 8GB memory. Also running Zabbix and have added a custom item showing free memory:

vm.memory.size[free]

It has run for weeks have around 4GB free memory according to the Zabbix info. Suddenly, over 3 days it has dropped to around 200MB free memory, but still runs fine.

In terminal this is what free shows:

free -m
            total       used       free     shared    buffers     cached
Mem:          7998       7745        252         42        142       7284
-/+ buffers/cache:        319       7679
Swap:         2047          0       2046

Before men: free showed around 4GB free, now only 252MB. But the buffers/cache show a lot free.

I'm running PostgreSQL as the only application.

What should I do to get the best picture of what's going on in the machine? I would the real view on available/free memory so I know when to add more memory, and not be concerned - as I am now.

Screenshot of Zabbix graph: http://imgur.com/a/lgyMD

UPDATE:

Running gives top -o '%MEM':

24091 postgres  20   0  226720  65664  64216 S   1.7  0.8   0:03.19 postgres                                                                                                                                                                               
24100 postgres  20   0  227756  57148  54840 S   0.7  0.7   0:04.24 postgres                                                                                                                                                                               
24103 postgres  20   0  227736  56400  54072 S   0.7  0.7   0:03.76 postgres                                                                                                                                                                               
24095 postgres  20   0  227748  55960  53652 S   0.3  0.7   0:03.63 postgres                                                                                                                                                                               
24102 postgres  20   0  227736  55956  53628 S   1.7  0.7   0:03.69 postgres                                                                                                                                                                               
24104 postgres  20   0  227720  55576  53244 S   0.3  0.7   0:03.59 postgres                                                                                                                                                                               
24098 postgres  20   0  227748  55572  53264 S   0.3  0.7   0:03.86 postgres                                                                                                                                                                               
24099 postgres  20   0  227744  55284  52972 S   0.3  0.7   0:04.55 postgres                                                                                                                                                                               
24097 postgres  20   0  227720  55184  52860 S   0.3  0.7   0:03.98 postgres                                                                                                                                                                               
24101 postgres  20   0  227704  54924  52600 S   3.0  0.7   0:04.37 postgres                                                                                                                                                                               
24096 postgres  20   0  227724  54364  52048 S   0.3  0.7   0:03.09 postgres                                                                                                                                                                               
24090 postgres  20   0  226824  30460  28956 S   0.0  0.4   0:01.40 postgres                                                                                                                                                                               
24077 postgres  20   0  226720  21600  20204 S   0.0  0.3   0:00.07 postgres                                                                                                                                                                               
24092 postgres  20   0  226720   8744   7304 S   0.0  0.1   0:00.06 postgres                                                                                                                                                                               
24093 postgres  20   0  227144   7132   5456 S   0.0  0.1   0:00.14 postgres                                                                                                                                                                               
25860 root      20   0   82592   5956   5104 S   0.0  0.1   0:00.00 sshd                                                                                                                                                                                   
  520 root      20   0   55184   5324   4652 S   0.0  0.1   0:00.01 sshd                                                                                                                                                                                   
 1695 zabbix    20   0   83064   5076   3968 S   0.0  0.1   2:00.49 zabbix_agentd                                                                                                                                                                          
 1696 zabbix    20   0   83064   5076   3968 S   0.0  0.1   2:04.55 zabbix_agentd                                                                                                                                                                          
 1694 zabbix    20   0   83064   5072   3968 S   0.0  0.1   2:05.60 zabbix_agentd                                                                                                                                                                          
25864 johndoe   20   0   23152   4824   3132 S   0.0  0.1   0:00.04 bash                                                                                                                                                                                   
  176 root      20   0   32968   4524   4376 S   0.0  0.1   0:14.79 systemd-journal                                                                                                                                                                        
26157 root      20   0   18248   4396   3908 S   0.0  0.1   0:00.00 cdm                                                                                                                                                                                    
24094 postgres  20   0   82008   4212   2716 S   0.0  0.1   0:00.56 postgres                                                                                                                                                                               
  541 root      20   0   19008   4176   3688 S   0.3  0.1  39:54.46 controller                                                                                                                                                                             
    1 root      20   0   28600   4096   2604 S   0.0  0.1   0:08.97 systemd                                                                                                                                                                                
 1697 zabbix    20   0   83064   3876   2872 S   0.0  0.0  20:35.93 zabbix_agentd                                                                                                                                                                          
26345 root      20   0   15236   3684   3340 S   0.0  0.0   0:00.19 hdb                                                                                                                                                                                    
25878 root      20   0   21904   3668   3128 S   0.0  0.0   0:00.01 bash                                                                                                                                                                                   
25863 johndoe   20   0   82724   3608   2760 S   0.0  0.0   0:00.52 sshd                                                                                                                                                                                   
  587 root      20   0   20824   3592   2556 S   0.0  0.0   0:23.24 xe-daemon                                                                                                                                                                              
26274 root      20   0   12404   3516   3160 S   0.0  0.0   0:00.00 processes                                                                                                                                                                              
 1693 zabbix    20   0   83064   3348   2372 S   0.0  0.0  23:07.61 zabbix_agentd                                                                                                                                                                          
  178 root      20   0   41524   3340   2100 S   0.0  0.0   0:00.24 systemd-udevd                                                                                                                                                                          
26332 root      20   0   12124   3232   2948 S   0.0  0.0   0:00.00 spooler                                                                                                                                                                                
 1692 zabbix    20   0   83064   3184   2208 S   0.0  0.0   0:00.00 zabbix_agentd                                                                                                                                                                          
25877 root      20   0   46360   3016   2640 S   0.0  0.0   0:00.01 su                                                                                                                                                                                     
  531 message+  20   0   42124   2960   2572 S   0.0  0.0   0:00.01 dbus-daemon                                                                                                                                                                            
26405 root      20   0   23664   2940   2420 R   0.0  0.0   0:00.03 top                                                                                                                                                                                    
  551 root      20   0  258668   2848   2088 S   0.0  0.0   0:00.66 rsyslogd                                                                                                                                                                               
  504 statd     20   0   37280   2616   2028 S   0.0  0.0   0:00.00 rpc.statd                                                                                                                                                                              
  522 root      20   0   27476   2532   2284 S   0.0  0.0   0:12.44 cron                                                                                                                                                                                   
  495 root      20   0   37080   2464   2056 S   0.0  0.0   1:16.15 rpcbind                                                                                                                                                                                
 1029 Debian-+  20   0   51176   2420   1788 S   0.0  0.0   0:00.29 exim4                                                                                                                                                                                  
  525 root      20   0   19856   2336   2068 S   0.0  0.0   1:50.77 systemd-logind                                                                                                                                                                         
  567 root      20   0   14236   2088   1936 S   0.0  0.0   0:00.00 agetty                                                                                                                                                                                 
  566 root      20   0   14416   1872   1724 S   0.0  0.0   0:00.02 agetty                                                                                                                                                                                 
  523 daemon    20   0   19024   1788   1624 S   0.0  0.0   0:00.74 atd                                                                                                                                                                                    
  539 root      20   0    9948   1360   1228 S   0.0  0.0  10:58.89 nimbus                                                                                                                                                                                 
26401 root      20   0    4236    672    596 S   0.0  0.0   0:00.00 sleep                                                                                                                                                                                  
  518 root      20   0   23356    204      0 S   0.0  0.0   0:00.00 rpc.idmapd                                                                                                                                                                             
    2 root      20   0       0      0      0 S   0.0  0.0   0:00.00 kthreadd                                                                                                                                                                               
    3 root      20   0       0      0      0 S  21.0  0.0 411:38.80 ksoftirqd/0                                                                                                                                                                            

FINAL update

It is PostgreSQL reserving the memory it seems:

/proc/meminfo
MemTotal:        8190432 kB
MemFree:          123344 kB
MemAvailable:    7627732 kB
Buffers:           22156 kB
Cached:          7650496 kB
Michael Nielsen
  • 131
  • 2
  • 9

1 Answers1

2

There simply is more content on your server that Linux Kernel finds suitable for being cached.

As you can see from your free -m output, most of the memory is used for filesystem cache, which is the best use for "unused" memory. You might want to read http://linuxatemyram.com/ to see what is happening.

Tero Kilkanen
  • 34,499
  • 3
  • 38
  • 58
  • I did actually read that webpage, and came a bit more calm after reading that. I simply wonder why it suddenly after weeks of running (around 3-4 weeks) it changes it way of using the RAM? – Michael Nielsen Mar 08 '17 at 09:21
  • My guess is next: after some period in your case (3-4 weeks) Linux collects info about your system thus Linux knows how much memory can be used for disk caching without harming your applications. So, Linux is borrowing unused memory for disk caching. – Net Runner Mar 08 '17 at 09:39
  • But basically as long as -/+ buffers/cache: 319 7679 has a lot free memory I should not be worried? Just seems as if 300MB used memory is kind of low? – Michael Nielsen Mar 08 '17 at 09:58
  • Depending on the purpose of your server, 8GB might be quite high ;) – Neograph734 Mar 08 '17 at 10:48
  • Yes, you are right - it was just because the vm.memory.size[free] for 3-4 weeks said 1GB left on a 4GB server, so I increased to 8GB to be secure. And now it has dropped to only using 3-400MB according to cache/buffer. – Michael Nielsen Mar 08 '17 at 11:44
  • So I've just become confused when Debian suddenly moves memory around and shows values differently suddenly, than it used to. Without I did anything. – Michael Nielsen Mar 08 '17 at 11:45