# RPN expressions in Torrus

In Torrus framework, RPN expressions are the superset of those in RRDtool version 1.0. See the `rrdtool graph` manual at <http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html>.

## New functions added

- NE

  Pops two arguments from stack, and pushes 0 if the arguments are equal, and 1 otherwise.

- AND, OR

  These functions pop two arguments from stack, and push back the result of logical operation. Unlike C operators,

- NOT

  Pops one value from stack and pushes 0 if the argument is nonzero, otherwise 1.

- ABS

  Pops one value from stack and pushes the absolute value of it.

- NOW

  Pushes the current time, in seconds since Epoch.

- TOD

  Pushes the time-of-day value: the number of seconds since midnight in th ecurrent time zone.

- WDAY

  Pushes the day of the week number (0=Sunday).

- MOFRI

  Pushes 1 if today is Monday to Friday, or 0 otherwise.

- MOD

  Equivalent of `%`, the modulo operator. In Torrus parameter value, percent sign is reserved for parameter substitution.

- NUM

  Returns zero if the argument is undefined, and the argument's numeric value otherwise

- INF, NEGINF

  Returns the positive or negative infinity.

## Data access

In certain context, the values of the datasources can be evaluated into RPN expression.

The general format for data access is following:

    {FUNC@PATH(-OFFSET)}

`FUNC@` specifies a special function to be performed on the data being accessed.

For monitor expressions, `T@` returns the timestamp of the data source.

For `rrd-cdef` leaf types and for `rrd-multigraph` datasource types, the following functions affect the graph shape: `AVERAGE@`, `MIN@`, `MAX@`, and `LAST@`. They cause the corresponding Consolidation Function being used when creating a graph.

`PATH` specifies the relative name for the data source. If omitted, the current leaf value is taken. If starts with `/`, the path is considered as absolute. Path starting with letter denotes the child of the parent subtree. Double dot (`../`) in the beginning of the path is interpreted as current parent's parent subtree. If `PATH` starts with a string enclosed in double square brackets (`[[` and `]]`), the string is interpreted as a NodeID value for referring to the node in the datasource tree.

`(OFFSET)` determines the time reference, as described in `rrdtool fetch` manual. In addition, the word `LAST` refers to the latest data timestamp available.

`(OFFSET)` is currently supported in Monitor expressions only.

# Author

Copyright (c) 2002-2004 Stanislav Sinyagin <ssinyagin@k-open.com>