Implementing MySQL performance monitoring via the MySQL v2 sensor.

  1. Create the SQL file to pull the statistics you would like.
    C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\sql\mysql\Queries_Threads_SlowQueries.sql
  2. Insert the following query:
    SELECT * from information_schema.GLOBAL_STATUS where VARIABLE_NAME='QUERIES' OR VARIABLE_NAME='THREADS_CONNECTED' OR VARIABLE_NAME='THREADS_RUNNING' OR VARIABLE_NAME='SLOW_QUERIES' ;
  3. Add MySQL v2 sensor and configure it like this:
OptionSetting Or Value
Sensor NameQUERIES THREADS_CONNECTED SLOW_QUERIES
Database<name of your mysql database>
Select Channel Value byKey Value Pair
Sensor Channel #1 NameQueries
Select Channel Value byKey value pair
Sensor Channel #1 NameQUERIES
Sensor Channel #1 KeyQUERIES
Sensor Channel #1 ModeDifference
Sensor Channel #1 UnitCount
Sensor Channel #2 NameTHREADS_CONNECTED
Sensor Channel #2 KeyTHREADS_CONNECTED
Sensor Channel #2 ModeAbsolute
Sensor Channel #2 UnitCount
Sensor Channel #3 NameTHREADS_RUNNING
Sensor Channel #3 KeyTHREADS_RUNNING
Sensor Channel #3 ModeAbsolute
Sensor Channel #3 UnitCount
Sensor Channel #4 NameSLOW_QUERIES
Sensor Channel #4 KeySLOW_QUERIES
Sensor Channel #4 ModeDifference
Sensor Channel #4 UnitCount

Article Comments

Sharing is caring, thanks! :)


Oct, 2016 - Permalink

Thanks for the formatting. I did not realize you supported wiki markup.

Per https://helpdesk.paessler.com/en/support/solutions/articles/76000063563-how-can-i-share-my-self-written-prtg-script-program-with-other-prtg-users

Can we please change the title to:

"How can I monitor MySQL performance via MySQLv2 sensor"


Oct, 2016 - Permalink

Done :)


Oct, 2016 - Permalink

Hello,

Your .sql file doesn't work

i got this "Can not log in using the specified credentials!"

The linux account is informed well about the equipment.

Any idea ?


Jun, 2018 - Permalink

Did you try this in the SQLv2.exe (in the sensor system directory)? Are Windows credentials configured for the device? If so, please remove them (or break inheritance). Otherwise, kerberos might be used in combination with the Linux credentials.


Kind regards,
Stephan Linke, Tech Support Team


Jun, 2018 - Permalink

Instead of using 'INFORMATION_SCHEMA.GLOBAL_STATUS' you should use 'performance_schema.global_status' when using MySQL 5.7.6 or newer. A deprecation warning is raised when selecting from the INFORMATION_SCHEMA tables using newer MySQL versions and in MySQL 8.0 it wont even work with compatibility options enabled.

SELECT * from performance_schema.global_status where VARIABLE_NAME='QUERIES' OR VARIABLE_NAME='THREADS_CONNECTED' OR VARIABLE_NAME='THREADS_RUNNING' OR VARIABLE_NAME='SLOW_QUERIES';

Jul, 2018 - Permalink