...
NMIS version 8.4.8G and later support modelling such scenarios using custom variables, or CVAR
s. With this mechanism you can temporarily capture up to 10 separate SNMP properties as a CVAR
and define an arbitrarily complex expression (in perl) that transforms these CVAR
s into the one measurement that you want to collect and/or display.
...
In both cases the syntax is very straight-forward:
- 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.- "
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.