获取Nginx + php-fpm的每个域的CPU /磁盘使用/流量统计信息

Good day to everyone!

I'm facing a problem like I never did before and half day of googling (and specially looking through StackOverflow, Nginx community etc too) found nothing useful.

I have a server with Nginx (1.4) + PHP-fpm (5.4) installed. There are something about 100+ servers (domains) in the Nginx config. In fact these domains "belong" to different people, and I need to know rough overall cpu, disk and traffic usage by Nginx and PHP for each of these domains. I can easily calculate traffic usage by analysing access logs, by I don't know how could I get CPU and disk usage separately for each domain :( The stats ain't required to be realtime - if I get per-day overall values, it's OK. The stats ain't required to be precise - +/-10% is absoultely OK. Still I don't see any useful solution.

Thanks in advance for any idea!

P.S. I know I can run a separate OpenVZ machine for each website and it'd allow me easily measure CPU and disk usage for each of them, but I don't like the solution. Please help me finding an alternate way!

As far, as I could find, nor Nginx neither PHP-FPM has built-in support for such metrix; so, there seems to be no way to measure per-site resources consumption inside of Nginx. But there is a trick to measure resources used by PHP (which are, almost always, at least 95% of all consumed resources, if DB is on a separate machine). To do this, we have to create a separate pool for each site in PHP-FPM config:

[site-A]
listen = /var/run/php5-fpm.A.sock
user = user-A
group = user-A
(...)

[site-B]
listen = /var/run/php5-fpm.B.sock
user = user-B
group = user-B
(...)

Then we need to set up Nginx so it passes request to FCGI using appropriate socket for each site. And voila, now we can measure resources consumption per-user using standard accounting utilities, and in fact it would mean per-site data. Still this data doesn't take into account resources consumed by Nginx itself; but, as far as I see, it is still much better than the 90% precision I wished. To make things even better, I can calculate traffic for static files using a separate log for each site, and this value would be obviously very close to amount of disk usage by Nginx itself. So, I wouldn't miss a site that is serving zounds of static files while resources consumption by PHP is moderate.