Score:1

How to measure CPU usage per site in a nginx + apache + php-fpm setup

ma flag

If I have a server with nginx as reverse proxy and Apache + php-fpm as server. I also have a ton of websites on this server, say 200+. I want to write a script which can tell me how much CPU is used by each site at any given time.

This is important because I want to delete/disable sites overusing my server resources.

Note: every process is run by a different user.

eg flag
Are your php-fpm processes splitted by different users? If yes you can do some nice things like monitoring their CPU %. Maybe this information can be added in the question.
Vikas Singhal avatar
ma flag
@ValerioBozzolan yes, every process is run by a different user. Can you give me a command for that?
Score:0
eg flag

If every process is executed by a different user, well done! You've made your life easier!

Your question now is: how to monitor CPU usage by user?

Some starting points:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.