Wrong memory read from Apache

Issue #42 on hold
Former user created an issue

When specifying the mpm workers to pre-allocate workers:

<IfModule mpm_prefork_module>
    ServerLimit         256
    StartServers         32
    MinSpareServers      16
    MaxSpareServers      32
#    MaxRequestWorkers   150
    MaxConnectionsPerChild 2500
</IfModule>

monit incorrectly specifies reads the amount of RAM used by the process. I currently have monit checking apache with the following:

check process apache with pidfile /usr/local/drupal/apache2/logs/httpd.pid
   start program = "/etc/init.d/apache start"
   stop  program = "/etc/init.d/apache stop"
   if total cpu is greater than 60% for 2 cycles then alert
   if total cpu > 80% for 5 cycles then alert
   if total memory > 3072 MB for 5 cycles then alert
   if children > 250 then alert
   if loadavg(5min) greater than 10 for 8 cycles then stop
   if failed host 127.0.0.1 port 80
       protocol HTTP request /monit/token then alert
   if 5 restarts within 5 cycles then timeout
   group apache

My systems only has 4G of RAM allocated to it:

free -m
              total       used       free     shared    buffers     cached
Mem:           4096       4069         26          0         24        930
-/+ buffers/cache:        3114        981
Swap:          2047

and monit is showing 12G used:

Process 'apache'
  status                            Resource limit matched
  monitoring status                 Monitored
  pid                               26524
  parent pid                        1
  uid                               0
  effective uid                     0
  gid                               0
  uptime                            1h 12m
  children                          64
  memory kilobytes                  20972
  memory kilobytes total            13315844
  memory percent                    0.5%
  memory percent total              317.4%
  cpu percent                       0.0%
  cpu percent total                 0.6%
  port response time                0.500s to 127.0.0.1:80/monit/token [HTTP via TCP]
  data collected                    Wed, 07 May 2014 10:33:22

An example of an app that gets the correct memory usage would be: smem

Comments (14)

  1. Tildeslash repo owner

    Monit adds the whole RSS of each child process when computing children total ... in the case of Apache, significant part of memory is shared, whereas we don't handle the shared memory intersection.

    We'll fix.

  2. Former user Account Deleted reporter

    Makes sense. Thanks :) Kind of a pain when I have it restarting the services because when a trigger is reached for memory, had to change it to alert.

  3. Tildeslash repo owner

    The cross-platform fix will require process' memory map integration ... we'll fix, but as we're refactoring the process related stuff in next major release, we'll do it as part of this project.

    Putting temporarily on hold.

  4. Log in to comment