Просмотр текущих запросов к Apache

Откройте для редактирования файл /etc/httpd/conf/httpd.conf, раскомментируйте сроки:

LoadModule status_module modules/mod_status.so

и

ExtendedStatus On

Ограничение доступа по IP посетителя

Далее раскомментируйте нижеследующую секцию и укажите в ней Ваш IP-адрес вместо xxx.xxx.xxx.xxx:

<Location /server-status>
       SetHandler server-status
       Order deny,allow
       Deny from all
       Allow from xxx.xxx.xxx.xxx
</Location>

Узнать свой IP-адрес можно на сайте 2ip.ru

Ограничение доступа через пароль

Также вы можете реализовать HTTP-авторизацию для просмотра статистики, для этого разместите сгенерированный файл с логином и паролем по пути /etc/httpd/server-status/.htpasswd и воспользуйтесь шаблоном:

<Location /server-status>
       SetHandler server-status
       AuthType        basic
       AuthName        "server-status"
       AuthUserFile    /etc/httpd/server-status/.htpasswd
       require         valid-user
</Location>

Перезапустите Apache:

# service httpd restart

Просмотреть текущие запросы к Apache и используемые им ресурсы можно по ссылке http://site.ru/server-status, вместо site.ru подставьте свой домен.

nginx + Apache

При использовании связки nginx+Apache необходимо выполнить дополнительное конфигурирование, блок <Location /server-status> обернуть в VirtualHost с указанием того порта, который у вас слушает Apache на backend, чаще всего это 8080 или 8081:

<VirtualHost 127.0.0.1:8080>
    ServerName yy.yy.yy.yy
    <Location /server-status>
        ...
    </Location>
</VirtualHost>

и сконфигурировать nginx, создадим файл /etc/nginx/conf.d/server-status.conf, вместо yy.yy.yy.yy укажите IP сервера, по которому будете обращаться, также укажите порт 8080 или другой используемый:

server {
    server_name yy.yy.yy.yy;
    charset off;
   
    listen yy.yy.yy.yy:80;
    location /server-status {
        proxy_pass http://127.0.0.1:8080;
        proxy_redirect http://127.0.0.1:8080 /;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Port $server_port;
        access_log off;
    }
}

# service httpd restart

# service nginx restart

Пример вывода текущих запросов к Apache

В скобках даны переводы к параметрам.

Apache Server Status for www.site.ru

Server Version: Apache/2.0.54 (Fedora)
Server Built: Oct 17 2005 08:59:28

Current Time: Monday, 23-Mar-2009 13:02:05 MSK
Restart Time: Sunday, 22-Mar-2009 12:54:39 MSK
Parent Server Generation: 0
Server uptime: 1 day 7 minutes 25 seconds
Total accesses: 1350366 — Total Traffic: 252.2 MB
CPU Usage: u43.52 s15.97 cu.04 cs0 —. 0685% CPU load
15.5 requests/sec — 3044 B/second — 195 B/request
10 requests currently being processed, 6 idle workers
WWW_RWW_WWW___W… ….. _… … ….. 

Scoreboard Key:
«_» Waiting for Connection, «S» Starting up, «R» Reading Request,
«W» Sending Reply, «K» Keepalive (read), «D» DNS Lookup,
«C» Closing connection, «L» Logging, «G» Gracefully finishing,
«I» Idle cleanup of worker, «.» Open slot with no current process

Srv PID Acc M CPU SS Req Conn Child Slot Client VHost Request
0-0 9655 0/65/107800 W 6.95 0 0 0.0 0.00 24.21 xxx.xxx.xxx.xxx site1.ru GET /path/ HTTP/1.0
1-0 13446 0/18/104447 W 1.46 8 0 0.0 0.00 13.27 xxx.xxx.xxx.xxx site1.ru GET /path/ HTTP/1.0
2-0 11880 0/67/101839 W 1.78 0 0 0.0 0.00 21.16 xxx.xxx.xxx.xxx site.ru GET /server-status HTTP/1.1
3-0 13948 0/7/98997 _ 0.41 0 1531 0.0 0.01 23.07 xxx.xxx.xxx.xxx site3.ru GET /path/ HTTP/1.0
4-0 13979 0/14/95703 R 0.28 0 0 0.0 0.00 17.21 ? ? ..reading..
5-0 11881 0/55/91056 W 2.44 0 0 0.0 0.00 13.91 xxx.xxx.xxx.xxx site1.ru GET /path/ HTTP/1.0
6-0 13981 0/7/87673 W 0.09 3 0 0.0 0.00 13.13 xxx.xxx.xxx.xxx site1.ru GET /path/
7-0 14048 0/12/84933 _ 0.13 0 0 0.0 0.00 13.20 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
8-0 7438 0/91/77753 W 2.23 9 0 0.0 0.01 20.51 xxx.xxx.xxx.xxx site1.ru GET /path/ HTTP/1.0
9-0 14049 0/0/71638 W 2.81 5 0 0.0 0.00 18.47 xxx.xxx.xxx.xxx site1.ru GET /path/ HTTP/1.0
10-0 9868 0/51/66047 W 4.31 8 0 0.0 0.00 9.64 xxx.xxx.xxx.xxx site1.ru GET /path/ HTTP/1.0
11-0 14050 0/7/60035 _ 0.19 0 466 0.0 0.00 16.34 xxx.xxx.xxx.xxx site1.ru GET /path/ HTTP/1.0
12-0 11940 0/53/51889 _ 1.57 0 0 0.0 0.00 7.11 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
13-0 14051 0/6/47054 _ 0.21 0 0 0.0 0.00 6.59 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
14-0 7479 0/76/38104 W 6.88 1 0 0.0 0.00 5.23 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
15-0 - 0/0/31718 . 1.53 21 2 0.0 0.00 4.29 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
16-0 - 0/0/25673 . 0.00 23 0 0.0 0.00 4.59 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
17-0 - 0/0/20957 . 0.14 19 0 0.0 0.00 3.10 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
18-0 - 0/0/16866 . 0.31 35 0 0.0 0.00 2.05 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
19-0 - 0/0/14109 . 0.31 37 0 0.0 0.00 2.28 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
20-0 - 0/0/11945 . 1.60 41 0 0.0 0.00 1.79 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
21-0 - 0/0/10077 . 0.00 39 0 0.0 0.00 2.84 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
22-0 - 0/0/7963 . 0.98 38 0 0.0 0.00 1.54 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
23-0 10010 0/51/6206 _ 5.00 0 0 0.0 0.00 1.56 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
24-0 - 0/0/4672 . 1.21 14 0 0.0 0.00 1.36 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
25-0 - 0/0/4109 . 0.00 44 1 0.0 0.00 0.96 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
26-0 - 0/0/2849 . 0.14 40 0 0.0 0.00 0.94 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
27-0 - 0/0/2051 . 0.00 42 0 0.0 0.00 0.28 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
28-0 - 0/0/1621 . 4.23 226 0 0.0 0.00 0.39 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
29-0 - 0/0/917 . 1.69 240 0 0.0 0.00 0.18 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
30-0 - 0/0/894 . 0.00 263 4 0.0 0.00 0.31 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
31-0 - 0/0/688 . 0.18 258 0 0.0 0.00 0.06 xxx.xxx.xxx.xxx site.ru GET /path/ HTTP/1.0
32-0 - 0/0/1185 . 6.09 205 223 0.0 0.00 0.25 xxx.xxx.xxx.xxx site4.ru GET /path/ HTTP/1.0
33-0 - 0/0/377 . 0.09 594 0 0.0 0.00 0.33 xxx.xxx.xxx.xxx site2.ru GET /path/ HTTP/1.0
34-0 - 0/0/521 . 4.30 3970 9295 0.0 0.00 0.06 xxx.xxx.xxx.xxx site1.ru GET /path/ HTTP/1.0

Srv Child Server number — generation
PID OS process ID
Acc Number of accesses this connection / this child / this slot
M Mode of operation (текущее состояние процесса)
CPU CPU usage, number of seconds (использование процессора, в процентах)
SS Seconds since beginning of most recent request (время работы процесса, в секундах)
Req Milliseconds required to process most recent request (обрабатываемый запрос на VHost)
Conn Kilobytes transferred this connection
Child Megabytes transferred this child (IP-адрес инициатора запроса)
Slot Total megabytes transferred this slot

SSL/TLS Session Cache Status:
cache type: SHMCB, shared memory: 512000 bytes, current sessions: 0
sub-caches: 32, indexes per sub-cache: 133
index usage: 0%, cache usage: 0%
total sessions stored since starting: 0
total sessions expired since starting: 0
total (pre-expiry) sessions scrolled out of the cache: 0
total retrieves since starting: 0 hit, 0 miss
total removes since starting: 0 hit, 0 miss

Apache/2.0.54 (Fedora) Server at www.site.ru Port 8081

Автоматическое обновление страницы

Для автоматического обновления страницы с полной информацией добавляется параметр http://site.ru:8081/server-status?refresh=10, где 10 — период обновления в секундах.

Для автоматического обновления страницы с краткой информацией добавляется параметр http://site.ru:8081/server-status?auto&refresh=10, где 10 — период обновления в секундах.

Не нашли ответ на свой вопрос в документации? Направьте обращение в службу поддержки или онлайн чат.