MySQL monitoring

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
zeguigui
Posts: 5
Joined: Mon Mar 15, 2004 10:51 am
Location: Montgeron, France
Contact:

MySQL monitoring

Post by zeguigui »

Here is a simple PHP script to monitor you MySQL servers.

It monitors questions and slow queries (classical) but also the 4.x Query Cache feature.

To use it simply create a script data input method with command line:

Code: Select all

php -f <path_cacti>/scripts/mysql_monitoring.php
Note: you need to modify the script to set your login, pass and host. You should create a user with only process privileges.

Output fields:

Code: Select all

Questions................ Questions
Slow_queries............. Slow Queries
Qcache_queries_in_cache.. Number of queries registered in the cache
Qcache_inserts........... Number of queries added to the cache
Qcache_hits.............. Number of cache hits
Qcache_not_cached........ Number of non-cached queries
Qcache_free_memory....... Amount of free memory for query cache
Qcache_total_blocks...... Total number of blocks in query cache
Qcache_free_blocks....... Number of free memory blocks in query cache
Qcache_lowmem_prunes..... Requests removed from cache
This script can be easily modified to monitor other STATUS variables like threads and others.

Hope this helps!
Guillaume
Attachments
mysql_monitoring.php.txt
Script to monitor MySQL
(1.18 KiB) Downloaded 3237 times
Guest

the graph is not working

Post by Guest »

Hi! Thanks for your script..
O have some problem with the graphs.. The script is working nice..
I need help with the graph template i think.. because i trying almos anything option there, but the graphs dont show any information.. :/

Can help me with the steps for the graphs?

Thanks!!!

Daniel
zeguigui
Posts: 5
Joined: Mon Mar 15, 2004 10:51 am
Location: Montgeron, France
Contact:

Post by zeguigui »

Here is an host template to go with this mysql monitoring.

Note: some of the items are in french... but it is easy to find the meaning from the datasource!

Template exported from cacti 0.8.6c
Attachments
cacti_host_template_mysql_monitoring.xml
Host template
(54.02 KiB) Downloaded 2240 times
markmaunder
Posts: 1
Joined: Mon Apr 04, 2005 6:54 pm

Got mysql problems? Read this.

Post by markmaunder »

Firstly both Cacti and this package rock. I'm just getting into the mysql pack, but looks very very good.

If you're having problems connecting, you may want to change this line in mysql_stats.php:
die("Error: MySQL connect failed. Check MySQL paramete.....

to read like so:

die("Error: MySQL connect failed. Check MySQL parameters (host/login/password)\n" . mysql_error());

That way you will be able to actually see what the mysql error is. In my case it was:

Client does not support authentication protocol requested by server. Consider upgrading MySQL client

And you fix it by running the following command from your mysql client on the host you are trying to connect to:

mysql> SET PASSWORD FOR 'some_user'@'some_host' = OLD_PASSWORD('mypass');

That way your older php mysql client will be able to connect to your server.

Hope that helps someone else. Thanks again for a great package.

Mark.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

how does this script differ from this one? http://forums.cacti.net/viewtopic.php?t=6108
User avatar
Wernicke
Cacti User
Posts: 61
Joined: Tue Jun 08, 2004 3:07 am
Location: Bodø, Norway
Contact:

Post by Wernicke »

Is Questions the amount of questions the last 5 minutes?
What is slow questions?

-Wernicke
User avatar
fmangeant
Cacti Guru User
Posts: 2345
Joined: Fri Sep 19, 2003 8:36 am
Location: Sophia-Antipolis, France
Contact:

Post by fmangeant »

Wernicke wrote:Is Questions the amount of questions the last 5 minutes?
What is slow questions?
Hi

the data source for "questions" is a COUNTER, so on the graph you see questions/s on a 5 minutes range. If you want to see total # of questions/5 min, add the CDEF "Make per 5 minute" to the graph.

From http://dev.mysql.com/doc/mysql/en/slow-query-log.html, slow queries are "SQL statements that took more than long_query_time seconds to execute", but I don't know anyhting more...
[size=84]
[color=green]HOWTOs[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15353]Install and configure the Net-SNMP agent for Unix[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=26151]Install and configure the Net-SNMP agent for Windows[/url]
[*][url=http://forums.cacti.net/viewtopic.php?t=28175]Graph multiple servers using an SNMP proxy[/url][/list]
[color=green]Templates[/color] :
[list][*][url=http://forums.cacti.net/viewtopic.php?t=15412]Multiple CPU usage for Linux[/url]
[*][url=http://forums.cacti.net/viewtopic.php?p=125152]Memory & swap usage for Unix[/url][/list][/size]
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests