30.1.3 顾问创建概述

要创建新的顾问,请单击“顾问”页面上的“创建顾问”按钮。要基于现有的 Advisor 创建 Advisor,请从 Advisor 菜单中选择Copy Advisor菜单项。您可以在复制过程中编辑任何 Advisor 元素,这与编辑现有 Advisor 不同。要删除自定义顾问, 请从顾问菜单中 选择删除顾问。

重要的

与基于表达式的顾问程序不同,无法复制其中一个基于 GUI 的顾问程序以用作自定义顾问程序的基础。

您可以更改 Advisor 名称,更改 Advisor 所属的 Advisor 类别,设置您自己的版本号,以及更改 Advisor 的阈值和频率。

笔记

如果您没有为新 Advisor 指定版本号,则会自动添加 1.0 版。

您还可以编辑顾问的表达式。有关 Advisor 表达式的更多信息,请参阅第 18 章,Advisors。表达式可以像单个服务器参数一样简单,也可以很复杂,将多个参数与数学运算组合在一起。

表达式有两个主要特征:

  • 表达式测试是否违反了最佳实践。

  • 表达式的结果必须始终为 1 或 0(对应于 true 或 false)。

例如,如果启用二进制日志记录是生产服务器的最佳实践(如 Oracle 所建议的),那么如果log_bin是 ,则违反了该最佳实践OFF因此, “ Binary Logging Not Enabled顾问 的表达式 是%log_bin% == OFF。如果此计算结果为 1,则会引发事件,因为未遵循最佳实践。

表达式由一个或多个变量和零个或多个数学运算符组成。MySQL Enterprise Monitor 使用 Java Expression Parser。运算符和函数包括:

  • IN()操作员 。

  • MySQL 函数LEAST(), LOCATE(), ABS(), MOD(), NOW()(以秒为单位返回自 Unix 纪元 UTC 以来的时间), UNIX_TIMESTAMP(技术上是无操作)和 INTERVAL [n] SECOND, MINUTE, HOUR, WEEK, MONTH.

  • 此页面上列出的运算符函数: http ://www.singularsys.com/jep/doc/html/operators.html 。

  • 与代理以标准 MySQL 格式收集的 MySQL 时间戳和日期时间的比较。 'YYYY-MM-DD hh:mm:ss[.nanos]'

  • The IF function: IF (condition, true_expression, false_expression) returns either true_expression or false_expression, depending on whether condition is true or false. This function uses short-circuit evaluation, so only one of the return expressions is evaluated.

  • The LEFT(string, length) and RIGHT(string, length) functions.

  • The NUM(string) function.

    Note

    The CAST(expression as type) function is not implemented. Instead, use NUM(string) to use strings as numbers.

For a complete list of the built-in variables used to create Advisors, see Server Option, System Variable, and Status Variable Reference.

Creating an expression is dependent on variables defined in the Variable Assignment frame. This frame links variables used in the expression field with data gathered from the target MySQL server instance: server status variables, operating system status information, and table information. Variable names are associated with elements in the Data Item drop-down menu. To define more than one variable, click the add row button.

其余字段确定您在通知电子邮件或与每个顾问关联的信息弹出窗口中收到的信息。

笔记

保存新顾问时,请选择一个未被任何现有顾问使用的唯一名称。