PDA

View Full Version : UserParameter to monitor MySQL total size


cadbury
11-05-2005, 18:00
i saw several threads about the increase of the database size
so i wanted to see how it grows in my case

since scripts are not allowed to be executed on the server, i installed
an agent on the server, and set this parameter :

UserParameter=mysql[totalsize],mysqlshow -uroot --status zabbix | cut -d \| -f 7,9,10 -s --output-delimiter="" | awk '{total += $1+$2+$3} END {print total}'

it uses what MySQL tells you to have the size of the database zabbix

in a way, it is slightly different from the total size of the files in which are
stored the database, so you can also use :

UserParameter=mysql[totalsize],du /var/lib/mysql/zabbix -cb | grep total | cut -f1

this assuming the zabbix agent have read access to this directory (which is not the default)

hope this can help some of you :)

Clement

mehow
23-07-2009, 14:09
In my case above code resulted in "0" outcome.

Modified version below calculates correct sum:
mysqlshow -uzabbix -p --status zabbix | cut -d\| -f 8,10 -s --output-delimiter="|" | awk -F"|" '{ total = total+$1+$2 } END {print total}'

Cut extracts two columns "Data_length" and "Index_length" and passes them to awk which calculates total. Units are kilobytes but I'm not sure about that...

Cheers,