Mysql – How to get the maxium number of concurrent connections to MySQL over a specific time interval

monitoringMySQL

I have a monitoring app that checks MySQL's Threads_connected and Max_used_connections variables every X seconds.

Neither of these variables tells me what I want to know: The highest number of concurrent connections since the last check (X seconds ago).

In the past, I've used FLUSH STATUS to reset Max_used_connections some time after the critical level is reached, but this method isn't ideal for a number of reasons, and according to the docs:

This is something you should use only when debugging a query.

Before I head down the path of a complicated analysis of the query log, is there anything I'm overlooking?

Best Answer

The only thing I can think of is finding some what (maybe through a cron job) to record the 'Threads_connected' values every minute, and then calculate the max of these values.

I'm not sure if you can do exactly what you are asking for without resetting the 'Max_used_connections' before your monitoring period.