As an example, this section shows how to create a data item for monitoring the amount of free InnoDB tablespace. The format and content of the XML file that defines the data to be collected is as follows:
<?xml version="1.0" encoding="utf-8"?> <classes> <class> <namespace>mysql</namespace> <classname>innodb_min_free</classname> <query><![CDATA[SELECT MIN(substring_index(substring_index(table_comment," ",3)," ",-1)/1024/1024) as Free FROM INFORMATION_SCHEMA.TABLES WHERE engine = 'InnoDB']]></query> </class> </classes>
The above works in MySQL 5.1.23 and earlier. For MySQL 5.1.24
and later, the information is reported within the
data_Free
column, and would need to be
declared as:
<?xml version="1.0" encoding="utf-8"?> <classes> <class> <namespace>mysql</namespace> <classname>innodb_min_free</classname> <query><![CDATA[SELECT MIN(data_free/1024/1024) as Free FROM INFORMATION_SCHEMA.TABLES WHERE engine = 'InnoDB']]></query> </class> </classes>
Save this file as:
Windows – C:\Program
Files\MySQL\Enterprise\Agent\share\mysql-proxy\items\innodb_min_free.xml
Unix –
/opt/mysql/enterprise/agent/share/mysql-proxy/items/innodb_min_free.xml
Mac OS X –
/Applications/mysql/enterprise/agent/share/mysql-proxy/items/innodb_min_free.xml
After saving this file, you must point your
mysql-monitor-agent.ini
file to it. ( For
the location of this file on your operating system see
Section 2.3.6.1, “MySQL Enterprise Monitor Agent (mysql-monitor-agent.ini
)
Configuration”.) Find the
[mysql-proxy]
section and add the file name
innodb_min_free.xml
to the
item-files
parameter using a semi-colon as
a separator. For example:
[mysql-proxy] ... item-files = items-mysql-monitor.xml,innodb_min_free.xml ...
For this change to take effect you must restart the agent. To do this see:
Once the agent has restarted, you will find the new data item
in the Data Item
drop down list box on the
Rule Definition
page. Its fully qualified
name is mysql:table:innodb_min_free
.