This section documents the steps to create a rule. Before creating a rule, review the preceding sections of this chapter.
This example creates a rule that checks the number of rows in a table. We decide that having 50,000 rows in this table triggers a critical alert. Lesser numbers produce informational and warning level alerts.
Begin by navigating to the Advisors tab and
clicking the manage rules link. Then choose
the create rule button.
Create your custom rule by following these steps:
Using the Rule Name text box, give the
rule an appropriate name, in this case something such as
"Excessive number of records in
table_name table".
From the Advisor drop down list box,
choose an advisor group for your rule. The
Administration group of rules might be
suitable but if you wish, create your own group of
advisors. For instructions on doing this, see
Section 4.1.1, “Creating Advisors”.
Enter the following expression in the
Expression text area:
'%table_name_num_rows% >
THRESHOLD'. Replace table_name
with the name of the table to monitor. Note that the
variable
% is not yet defined.
table_name_num_rows%
Set the Thresholds.
Set the Critical Alert level to
50000.
Set the Warning Alert level to
10000.
Set the Info Alert level to
5000.
Define your variable in the Variable
Assignment frame.
In the Variable text box, enter
'%,
the variable used in the table_name_num_rows%Expression
text box.
In the Data Item drop down list
box, find and select the
mysql:table:numrows entry. (For a
description of all the data items available, see
Appendix D, Data Collection Items.)
In the Instance text box, enter
database_name.table_name.
Add appropriate entries for the Problem
Description, the Advice, and
the Links text areas. Optionally, use
Wiki
markup for these text areas. You can also reference
the
'%
variable in these text areas. For example, you can display
the current number of rows with a message such as
'table_name_num_rows%table_name currently has
%table_name_num_rows% rows.'
Save the rule.
After you create the rule, schedule it against the server that contains the database table to monitor. For instructions on scheduling rules, see Section 2.3.2, “Scheduling Rules”.
