xymon-mysql-counters is a perl script that you can use to monitor a bunch of status variable from a mysql installation and graph them into your BB/Hobbit/Xymon server.
xymon_mysql_counters.pl
connects to your mysql server and issues the following queries to get the needed data:
SELECT * FROM INFORMATION_SCHEMA.GLOBAL_STATUS
SELECT VARIABLE_NAME, VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES WHERE VARIABLE_NAME IN ('MAX_CONNECTIONS', 'QUERY_CACHE_SIZE', 'TABLE_OPEN_CACHE')
The values are then posted into the host's trends data channel.
Some HTML code is also posted as a status, in order to be able to see the graphs alone on one page (ugly but works). If you only want the graphs to appear in the trends page, you can remove the line that send the status and then set the TRENDS
variable in xymonserver.cfg
.
-
Copy
xymon_mysql_counters.pl
somewhere executable by your xymon client (typically$HOBBITCLIENTHOME/ext
or$XYMONCLIENTHOME/ext
). Set the permissions accordingly. -
Edit the script to provide your mysql credentials.
use constant DBI_URN => 'DBI:mysql:information_schema';
use constant DBI_USERNAME => 'xymon';
use constant DBI_PASSWORD => 'mysuperstrongpassword';
See DBD::mysql on CPAN for more information about the URN string.
- Makes xymon execute the script periodically.
In
hobbitlaunch.cfg
(Hobbit)
[mysql]
ENVFILE $HOBBITCLIENTHOME/etc/hobbitclient.cfg
CMD $HOBBITCLIENTHOME/ext/xymon_mysql_counters.pl
LOGFILE $HOBBITCLIENTHOME/logs/hobbit-mysql.log
INTERVAL 2m
or in clientlaunch.cfg
(Xymon)
[mysql]
ENVFILE $XYMONCLIENTHOME/etc/xymonclient.cfg
CMD $XYMONCLIENTHOME/ext/xymon_mysql_counters.pl
LOGFILE $XYMONCLIENTLOGS/xymon-mysql.log
INTERVAL 2m
-
Append or include the provided file to
graphs.cfg
. -
Restart xymon-client.
xymon-mysq-counters was written in October 2012 by: ZeWaren / Erwan Martin <[email protected]>.
It is licensed under the MIT License.
This code is strongly inspired from the Percona MySQL Monitoring Template for Cacti. The credits for the MySQL part should go to these guys.