A useful thing is to monitor the load on your MySQL database server. To check mysql queries per second you’ll need a simple helper script:
#!/bin/sh
#mysql password for root
mysql_password=''
#where mysql and mysqladmin is located
mysql_bin_dir=/usr/bin
info=`${mysql_bin_dir}/mysqladmin -u root -p${mysql_password} status |awk '{print $2 " " $6}'`
queries=`echo $info|awk '{print $2}'`
uptime=`echo $info|awk '{print $1}'`
uptime=`echo "select sec_to_time($uptime);"|${mysql_bin_dir}/mysql -p${mysql_password} --skip-column-names`
echo $queries
echo $queries
echo $uptime
Fill variables on top of this script with right data
Here is the mrtg.cfg entry for mysql statistics:
Target[mysql.queries]: `/etc/mrtg/mysql.sh`
Title[mysql.queries]: MySQL Queries
PageTop[mysql.queries]: <H1>MySQL Queries</H1>
MaxBytes[mysql.queries]: 10000
Options[mysql.queries]: nopercent
LegendI[mysql.queries]: Queries
LegendO[mysql.queries]:
ShortLegend[mysql.queries]: q/s
YLegend[mysql.queries]: q/s
