...
- The expression must be a valid perl statement and return exactly one value.
- The tokens
$r
, andCVAR0
toCVAR9
are interpreted by NMIS; everything else is perl. - Defining and using local variables with
my
is ok, but don't attempt to change any global NMIS variables. "CVAR1=some_snmp_var
;" defines what SNMP object CVAR1 is supposed to hold. The parser understandsCVAR0
toCVAR9
for a total of 10 captures.- You can use functions that were defined elsewhere in NMIS in your
calculate
expression.
You will likely have to include the full module namespace in the function call, e.g.func::beautify_physaddress(...).
Only functions without side-effects should be used. - "
return $r/$CVAR1;
" accesses the value ofCVAR1
in an expression. The variable "$r
" represents the SNMP variable that thecalculate
expression is attached to.
Please note that
- the
$CVAR
n replacement in the expression is performed on a purely textual basis, before the expression is handed to the perl interpreter for evaluation :For string variables you have to provide quotes in your expression, e.g.
Code Block calculate => 'CVAR1=somestringthing; return 42 if ("$CVAR1" eq "online");'
- Numeric variables can be used straight without quotes.
- the
$CVAR
n access refers to the raw value of the named property, ie. the data before anyreplace
orcalculate
expressions for the named property were evaluated.
How to keep temporary CVAR data out of the RRD databases
...