Section 15.6.4.7, “Creating a New Rule: An Example” shows how to create a custom rule and Data Collection Items shows the data items that can be used in rule creation. However, in some circumstances you may want to create a rule that uses a custom data collection item.
This section describes how to create a custom data collection item. The steps are as follows:
Create an XML file to define how the data is collected.
Point the agent configuration file to this XML file.
Restart the agent.
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 15.3.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
.
User Comments
Add your own comment.