How to monitor OS

No specific configuration required at this stage.

How to monitor Nginx

You have to enable "stub_status" in default vhost, which should be accessible from localhost.

knock@server:~$ cat /etc/nginx/sites-enabled/000-default
server {
  root /var/www/default;
  index index.html;
  server_name localhost;
  location / {
    try_files $uri $uri/ /index.html;
  }
  # Nginx status
  location /nginx_status {
    # Status on
    stub_status on;
    # No log
    access_log off;
    # From local only
    allow 127.0.0.1;
    deny all;
  }
}
                    

You can check it using curl.

knock@server:~$ curl http://127.0.0.1/nginx_status
Active connections: 2
server accepts handled requests
 330018 330018 815527
Reading: 0 Writing: 1 Waiting: 1

How to monitor Uwsgi

You only have to enable "stats" item in each of your enabled applications.

knock@server:~$ cat /etc/uwsgi/apps-enabled/myapp.ini | grep stats
; Enable stats
stats = /tmp/uwsgi-app-myapp.sock

You can check it using uwsgi command.

knock@server:~$ uwsgi --connect-and-read /tmp/uwsgi-app-myapp.sock
{
        "version":"2.0.7-debian",
        "listen_queue":0,
        "listen_queue_errors":0,
        "signal_queue":0,
        "load":0,
        "pid":65449,
        "uid":33,
        "gid":33,
        "cwd":"/var/www/myapp",
[Skipped end-of-buffer...]

How to monitor Apache

You have to enable status mod and configure default vhost.

knock@server:~# a2enmod status
Module status already enabled

knock@server:~# cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/apache2/default
        ErrorLog ${APACHE_LOG_DIR}/default_error.log
        CustomLog ${APACHE_LOG_DIR}/default_access.log combined

        # APACHE STATUS
        <Location /server-status>
            SetHandler server-status
        </Location>
[Skipped end-of-buffer...]

You can check it using curl.

knock@server:~# curl http://127.0.0.1:80/server-status?auto
Total Accesses: 13744
Total kBytes: 9416
CPULoad: .447026
Uptime: 446876
ReqPerSec: .0307557
BytesPerSec: 21.5764
BytesPerReq: 701.541
BusyWorkers: 1
IdleWorkers: 49
ConnsTotal: 0
ConnsAsyncWriting: 0
ConnsAsyncKeepAlive: 0
ConnsAsyncClosing: 0
Scoreboard: .................................................._________________________________________________W..................................................

How to monitor PhpFpm

Pre-requisit : Php should work through apache or nginx.

Step 1 : enable status_path in FPM pools.

knock@server:~# cat /etc/php5/fpm/pool.d/www.conf | grep status_path
pm.status_path = /status
knock@server:~# 

Step 2 : enable a handler in Apache toward FPM status. Apache 2.4 sample below.

knock@server:~# cat /etc/apache2/sites-enabled/000-default.conf
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/apache2/default
        ErrorLog ${APACHE_LOG_DIR}/default_error.log
        CustomLog ${APACHE_LOG_DIR}/default_access.log combined

        # ------------------
        # FPM (.php and /status)
        # ------------------

        <FilesMatch "\.php$|status$">
            SetHandler "proxy:unix:///var/run/php5-fpm.sock|fcgi://localhost"
        </FilesMatch>

Step 3 : check it using curl.

knock@server:~# curl http://127.0.0.1:80/status
pool:                 www
process manager:      dynamic
start time:           10/May/2016:09:55:53 +0000
start since:          628682
accepted conn:        216128
listen queue:         0
max listen queue:     0
listen queue len:     0
idle processes:       2
active processes:     1
total processes:      3
max active processes: 3
max children reached: 0
slow requests:        0
root@klchgui01:~# 

How to monitor Mysql

No specific configuration required at this stage.

We are using the debian-sys-maint user, connect to the mysql socket, and fire basic SQL statements, like show global status;.

How to monitor Redis

No specific configuration required at this stage (we are using redis library and INFO command)

How to monitor Varnish

No specific configuration required at this stage (we are using varnishstat -j)

How to monitor MemCached

No specific configuration required at this stage (we are using tcp localhost toward port defined in memcached.conf, "-p" parameter)

Note : Targetting unix domain socket (using "-s" parameter) is currently not supported.

Note : Multiple memcached instances is currently not supported.

How to monitor Mongodb

More to come soon about it.