So, I had a customer having some major MySQL woes, and I wanted to know whether the MySQL issues were query related, as in due to the frequency of queries alone, or the size of the database. VS it being caused by the number of visitors coming into apache, therefore causing more frequency of MySQL hits, and explaining the higher CPU usage.
The best way to achieve this is to inspect /var/log/httpd with ls -al,
First we take a sample of all of the requests coming into apache2, as in all of them.. provided the customer has used proper naming conventions this isn’t a nightmare. Apache is designed to make this easy for you by the way it is setup by default, hurrah!
[root@box-DB1 logparser]# time tail -f /var/log/httpd/*access_log > allhitsnow ^C real 0m44.560s user 0m0.006s sys 0m0.031s
Time command prefixed here, will tell you how long you ran it for.
[root@box-DB1 logparser]# cat allhitsnow | wc -l 1590
The above command shows you the number of lines in allhitsnow file, which was written to with all the new requests coming into sites from all the site log files. Simples! 1590 queries a minute is quite a lot.