This section documents the steps required to create a rule. Before attempting to create a rule, please review the preceding sections of this chapter.
This example creates a rule that checks the number of rows in a table. Having 50,000 rows in this table is deemed to warrant a critical alert. Lesser numbers are assigned to 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. Something such as "Excessive
number of records in table_name
table", may be appropriate.
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 6.4.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 you wish to monitor. Note that
the variable
%
has not yet been 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 F, 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. If you wish, use
Wiki markup for these text areas. See
Section 6.4.6, “Wiki Format” for more
information. Note that 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.
Once the rule is created it needs to be scheduled against the server that contains the database table you wish to monitor. For instructions on scheduling rules see Section 6.2, “Scheduling Rules”.