0

I want to know is there anyway to get CPU usage per user in MySQL? for example I have 3 different users 'user1', 'user2' and 'user3'. I want to get the average/real time memory usage and CPU usage of these users.I googled a lot but I did not find any suitable tool. Maybe I can get these data from MySQL queries, but I don't know where are they stored.

  • I am not sure if we can do that, since mysql is parent process and mysql user comes underneath, Alternative is restrict(pin it) mysql process to particular CPU, by that way no other process can use that core and you can calculate the process cpu usage(not user), To restrict the number of users you can write the triggers which can prevent user addition after particular number of user exceed. – asktyagi May 11 '19 at 8:35
0

Why do you want it? If it is to see who is using the CPU more, then use the slowlog and some digest such as pt-query-digest.

In a well-tuned production system the CPU is not heavily used. So it should not matter who is using the CPU.

See also: https://dba.stackexchange.com/questions/237969/how-to-get-cpu-usage-in-mysql-per-user

  • No I don't want to find the user who uses more CPU. It can easily be find out from mysql process list and slow queries. I want to calculate and display the overall CPU usage of a user to tell him/her to pay for the resources. I want to create a pay as you go service. So I need to know the CPU usage of MySQL too. – Sinai May 10 '19 at 10:22
  • @Sinai - OK. I don't think such exists. Charging for disk space is probably easy. – Rick James May 10 '19 at 16:02
  • What about audit? Is there any audit rule to do such thing for me? Calculating Disk space is easy but not enough :D – Sinai May 11 '19 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.