Munin variable overview

Available variables

When using Munin's built-in alert mechanisms, lots of variables are available. Generally, all directives recognized in the configuration protocol and in munin.conf are available as ${var:directive}.

Group or host related variables

The below table lists some of the variables. Variables in the first graph are directly available.

VariableContentConfig protocol reference
${var:group}GroupGroup definition as referenced in munin.conf.
${var:host}HostHost definition as referenced in munin.conf.
${var:graph_title}The plugin's titlegraph_title
${var:graph_category}The plugin's categorygraph_category

Fieldname related variables

The below table lists some variables related to the different fields in a plugin. To extract these, they must be iterated over, even if there is only one field. Iteration follows the syntax defined in the Perl module Text::Balanced (sample below the table).

VariableContentConfig protocol reference
${var:label}The fieldname's label{fieldname}.label
${var:value}The fieldname's value{fieldname}.value?
${var:extinfo}The fieldname's extended info, if defined{fieldname}.extinfo?
${var:wrange}Numeric range for warning alerts{fieldname}.warning
${var:crange}Numeric range for critical alerts{fieldname}.critical
${var:wfields}Space separated list of fieldnames with a value outside the warning range.N/A
${var:cfields}Space separated list of fieldnames with a value outside the critical range.N/A
${var:ufields}Space separated list of fieldnames with an unknown value.N/A

How variables are expanded

The ${var:value} variables get the correct values from munin-limits prior to expansion of the variable.

Then, the ${var:*range} variables are set from {fieldname}.warning and {fieldname}.critical.

Based on those, {fieldname}.label occurences where warning or critical levels are breached or unknown are summarized into the ${var:*fields} variables.

Example usage

Note that the sample command lines are wrapped for readability.

Example 1, iterating through warnings and criticals

contact.mail.command mail -s "[${var:group};${var:host}] -> ${var:graph_title} -> 
                              warnings: ${loop<,>:wfields  ${var:label}=${var:value}} / 
                              criticals: ${loop<,>:cfields  ${var:label}=${var:value}}" me@example.com

This stanza results in an e-mail with a subject like this:

[example.com;foo] -> HDD temperature -> warnings: sde=29.00,sda=26.00,sdc=25.00,sdd=26.00,sdb=26.05 / criticals:

(Note that there are no breaches of critical level temperatures, only of warning level temperatures.)

Example 2, reading ${var:wfields}, ${var:cfields} and ${var:ufields} directly

contact.mail.command mail -s "[${var:group};${var:host}] -> ${var:graph_title} ->
                              warnings: ${var:wfields} /
                              criticals: ${var:cfields} /
                              unknowns: ${var:ufields}" me@example.com

The result of this is the following:

[example.com;foo] -> HDD temperature -> warnings: sde sda sdc sdd sdb / criticals: / unknowns:

Iteration using Text::Balanced

The Text::Balanced iteration syntax used in munin-limits is as follows (extra spaces added for readability):

${ loop < join character > : list of words ${var:label} = ${var:value} }

Given a space separated list of words "a b c", and the join character "," (comma), the output from the above will equal

a.label = a.value,b.label = b.value,c.label = c.value

in which the label and value variables will be substituted by their Munin values.

Please consult the Text::Balanced documentation for more details.