Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   pmie    ( 1 )

механизм вывода для показателей производительности (inference engine for performance metrics)

EXPRESSION SYNTAX

This description is terse and informal. For a more comprehensive description see the Performance Co-Pilot User's and Administrator's Guide.

A pmie specification is a sequence of semicolon terminated expressions.

Basic operators are modeled on the arithmetic, relational and Boolean operators of the C programming language. Precedence rules are as expected, although the use of parentheses is encouraged to enhance readability and remove ambiguity.

Operands are performance metric names (see PMNS(5)) and the normal literal constants.

Operands involving performance metrics may produce sets of values, as a result of enumeration in the dimensions of hosts, instances and time. Special qualifiers may appear after a performance metric name to define the enumeration in each dimension. For example,

kernel.percpu.cpu.user :foo :bar #cpu0 @0..2

defines 6 values corresponding to the time spent executing in user mode on CPU 0 on the hosts ``foo'' and ``bar'' over the last 3 consecutive samples. The default interpretation in the absence of : (host), # (instance) and @ (time) qualifiers is all instances at the most recent sample time for the default source of PCP performance metrics.

Host and instance names that do not follow the rules for variables in programming languages, ie. alphabetic optionally followed by alphanumerics, should be enclosed in single quotes.

Expression evaluation follows the law of ``least surprises''. Where performance metrics have the semantics of a counter, pmie will automatically convert to a rate based upon consecutive samples and the time interval between these samples. All numeric expressions are evaluated in double precision, and where appropriate, automatically scaled into canonical units of ``bytes'', ``seconds'' and ``counts''.

A rule is a special form of expression that specifies a condition or logical expression, a special operator (->) and actions to be performed when the condition is found to be true.

The following table summarizes the basic pmie operators:

┌────────────────┬────────────────────────────────────────────────┐ │ Operators │ Explanation │ ├────────────────┼────────────────────────────────────────────────┤ │+ - * / │ Arithmetic │ │< <= == >= > != │ Relational (value comparison) │ │! && || │ Boolean │ │-> │ Rule │ │rising │ Boolean, false to true transition │ │falling │ Boolean, true to false transition │ │rate │ Explicit rate conversion (rarely required) │ │instant │ No automatic rate conversion (rarely required) │ └────────────────┴────────────────────────────────────────────────┘ All operators are supported for numeric-valued operands and expressions. For string-valued operands, namely literal string constants enclosed in double quotes or metrics with a data type of string (PM_TYPE_STRING), only the operators == and != are supported.

The rate and instant operators are the logical inverse of one another, so an arithmetic expression expr is equal to rate instant expr. The more useful cases involve using rate with a metric that is not a counter to determine the rate of change over time or instant with a metric that is a counter to determine if the current value is above or below some threshold.

Aggregate operators may be used to aggregate or summarize along one dimension of a set-valued expression. The following aggregate operators map from a logical expression to a logical expression of lower dimension.

┌─────────────────────────┬─────────────┬──────────────────────────┐ │ Operators │ Type │ Explanation │ ├─────────────────────────┼─────────────┼──────────────────────────┤ │some_inst │ Existential │ True if at least one set │ │some_host │ │ member is true in the │ │some_sample │ │ associated dimension │ ├─────────────────────────┼─────────────┼──────────────────────────┤ │all_inst │ Universal │ True if all set members │ │all_host │ │ are true in the │ │all_sample │ │ associated dimension │ ├─────────────────────────┼─────────────┼──────────────────────────┤ │N%_inst │ Percentile │ True if at least N │ │N%_host │ │ percent of set members │ │N%_sample │ │ are true in the │ │ │ │ associated dimension │ └─────────────────────────┴─────────────┴──────────────────────────┘ The following instantial operators may be used to filter or limit a set-valued logical expression, based on regular expression matching of instance names. The logical expression must be a set involving the dimension of instances, and the regular expression is of the form used by egrep(1) or the Extended Regular Expressions of regcomp(3).

┌─────────────┬──────────────────────────────────────────┐ │ Operators │ Explanation │ ├─────────────┼──────────────────────────────────────────┤ │match_inst │ For each value of the logical expression │ │ │ that is ``true'', the result is ``true'' │ │ │ if the associated instance name matches │ │ │ the regular expression. Otherwise the │ │ │ result is ``false''. │ ├─────────────┼──────────────────────────────────────────┤ │nomatch_inst │ For each value of the logical expression │ │ │ that is ``true'', the result is ``true'' │ │ │ if the associated instance name does not │ │ │ match the regular expression. Otherwise │ │ │ the result is ``false''. │ └─────────────┴──────────────────────────────────────────┘ For example, the expression below will be ``true'' for disks attached to controllers 2 or 3 performing more than 20 operations per second: match_inst "^dks[23]d" disk.dev.total > 20;

The following aggregate operators map from an arithmetic expression to an arithmetic expression of lower dimension.

┌─────────────────────────┬───────────┬──────────────────────────┐ │ Operators │ Type │ Explanation │ ├─────────────────────────┼───────────┼──────────────────────────┤ │min_inst │ Extrema │ Minimum value across all │ │min_host │ │ set members in the │ │min_sample │ │ associated dimension │ ├─────────────────────────┼───────────┼──────────────────────────┤ │max_inst │ Extrema │ Maximum value across all │ │max_host │ │ set members in the │ │max_sample │ │ associated dimension │ ├─────────────────────────┼───────────┼──────────────────────────┤ │sum_inst │ Aggregate │ Sum of values across all │ │sum_host │ │ set members in the │ │sum_sample │ │ associated dimension │ ├─────────────────────────┼───────────┼──────────────────────────┤ │avg_inst │ Aggregate │ Average value across all │ │avg_host │ │ set members in the │ │avg_sample │ │ associated dimension │ └─────────────────────────┴───────────┴──────────────────────────┘ The aggregate operators count_inst, count_host and count_sample map from a logical expression to an arithmetic expression of lower dimension by counting the number of set members for which the expression is true in the associated dimension.

For action rules, the following actions are defined:

┌──────────┬────────────────────────────────────────┐ │Operators │ Explanation │ ├──────────┼────────────────────────────────────────┤ │alarm │ Raise a visible alarm with xconfirm(1) │ │print │ Display on standard output │ │shell │ Execute with sh(1) │ │stomp │ Send a STOMP message to a JMS server │ │syslog │ Append a message to system log file │ └──────────┴────────────────────────────────────────┘ Multiple actions may be separated by the & and | operators to specify respectively sequential execution (both actions are executed) and alternate execution (the second action will only be executed if the execution of the first action returns a non-zero error status.

Arguments to actions are an optional suppression time, and then one or more expressions (a string is an expression in this context). Strings appearing as arguments to an action may include the following special selectors that will be replaced at the time the action is executed.

%h Host name(s) that make the left-most top-level expression in the condition true.

%c Connection specification string(s) or files for a PCP tool to reach the hosts or archives that make the left-most top-level expression in the condition true.

%i Instance(s) that make the left-most top-level expression in the condition true.

%v One value from the left-most top-level expression in the condition for each host and instance pair that makes the condition true.

Note that expansion of the special selectors is done by repeating the whole argument once for each unique binding to any of the qualifying special selectors. For example if a rule were true for the host mumble with instances grunt and snort, and for host fumble the instance puff makes the rule true, then the action ... -> shell myscript "Warning: %h:%i busy "; will execute myscript with the argument string "Warning: mumble:grunt busy Warning: mumble:snort busy Warning: fumble:puff busy".

By comparison, if the action ... -> shell myscript "Warning! busy:" " %h:%i"; were executed under the same circumstances, then myscript would be executed with the argument string "Warning! busy: mumble:grunt mumble:snort fumble:puff".

The semantics of the expansion of the special selectors leads to a common usage pattern in an action, where one argument is a constant (contains no special selectors) the second argument contains the desired special selectors with minimal separator characters, and an optional third argument provides a constant postscript (e.g. to terminate any argument quoting from the first argument). If necessary post-processing (eg. in myscript) can provide the necessary enumeration over each unique expansion of the string containing just the special selectors.

For complex conditions, the bindings to these selectors is not obvious. It is strongly recommended that pmie be used in the debugging mode (specify the -W command line option in particular) during rule development.