Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents


Occasionally you will come across a device or a situation where collecting a single SNMP variable is insufficient, for example when two or more SNMP properties need to be combined to provide a meaningful measurement.

...

  • The expression must be a valid perl statement and return exactly one value.
  • The tokens $r, and CVAR0 to CVAR9 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 understands CVAR0 to CVAR9 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 of CVAR1 in an expression. The variable "$r" represents the SNMP variable that the calculate expression is attached to.

Please note that

  • the $CVARn 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 $CVARn access refers to the raw value of the named property, ie. the data before any replace or calculate expressions for the named property were evaluated.

How to keep temporary CVAR data out of the RRD databases

...

Please note that setting nosave disables alerts for the given object.

Using Placeholders

Sometimes there is a need to create calculated data using data gathered from several sources and calculated into a single table.  Situations such as this might call for use of a plugin (NMIS 9 Collect and Update Plugins).  The problem comes in when the model tries to interpret the sections in the model when there is lack of data to do so.  This causes errors in the model.  To solve this, there is a keyword. 'placeholder' which can be used in the 'sys' section of the model definition to tell the model that the 'headers', labels, and 'titles' only exist to create the necessary infrastructure for the data, and the some other method will be used to create the values. There really isn't much to this, just the keyword 'placeholder', and the value will be printed in the log to say that the <value> will be used to fill in the data as shown in the example below.

Code Block
      'ciscoNormalizedCPUMem' => {
        'headers' => 'TotalCPUs,MemoryUsedMax,MemoryUsed,MemoryFreeMax,MemoryFree',
        'placeholder' => 'plugin',
        'graphtype' => 'health',
        'indexed' => 'true',
        'snmp' => {
          'TotalCPUs' => {
            'title' => 'Number of CPUs'
          },
          'MemoryUsedMax' => {
            'title' => 'Maximum Memory Used'
          },
          'MemoryUsed' => {
            'title' => 'Current Memory Used'
          },
          'MemoryFreeMax' => {
            'title' => 'Maximum Memory Free'
          },
          'MemoryFree' => {
            'title' => 'Current Memory Free'
          },
        },
      },