How does the 'rate' function work in the Gateway Rules?
The “rate of change” function, given as rate(x), is calculated as the rate of change between the current value and the value seen in the previous sample.**
Rate is calculated as the rate of change between the current value and the value seen in the previous sample. i.e., rate(x) = (x - value of x at previous sample) / (time now - time at which gateway processed previous sample for x)**. See sample calculation below: time: 10:00:00 value: 100 time: 10.00:05 value: 200 –> rate = (200 - 100) / (10:00:05 - 10:00:00) = 100 / 5 = 20. time: 10.00:10 value: 350 –> rate = (350 - 200) / (10:00:05 - 10:00:00) = 150 / 5 = 30.
For examples on how to use the rate of change function in samplers and rules, see below: Sample sampler: <sampler name=``"CPU"``> <sampleInterval> <data>``60``</data> </sampleInterval> <plugin> <cpu></cpu> </plugin> <dataviews> <dataview name=``"CPU"``> <additions> <var-columns> <data> <column> <data>ComputedColumn</data> </column> <column> <data>RateOfSum</data> </column> </data> </var-columns> </additions> </dataview> </dataviews> </sampler>
Sample rule for sum: <rule name=``"CPU_Sum"``> <targets> <target>/geneos/gateway/directory/probe/managedEntity/sampler/dataview/rows/row/cell[(``@column``="ComputedColumn")]</target> </targets> <priority>``1``</priority> <pathAliases> <pathAlias name=``"column-b"``>../cell[(``@column``="percentUtilisation")]</pathAlias> <pathAlias name=``"column-c"``>parent::node()/cell[(``@column``="percentUserTime")]</pathAlias> <pathAlias name=``"column-a"``>parent::node()/cell[(``@column``="percentKernelTime")]</pathAlias> </pathAliases> <block> <transaction> <update> <property>``@value``</property> <add> <add> <dataItem> <pathAlias ref=``"column-a"``></pathAlias> <property>``@value``</property> </dataItem> <dataItem> <pathAlias ref=``"column-b"``></pathAlias> <property>``@value``</property> </dataItem> </add> <dataItem> <pathAlias ref=``"column-c"``></pathAlias> <property>``@value``</property> </dataItem> </add> </update> </transaction> </block> </rule>
Sample rule for rate of sum: <rule name=``"CPU_Rate_Sum"``> <targets> <target>/geneos/gateway/directory/probe/managedEntity/sampler/dataview/rows/row/cell[(``@column``="RateOfSum")]</target> </targets> <priority>``1``</priority> <pathAliases> <pathAlias name=``"column-sum"``>../cell[(``@column``="ComputedColumn")]</pathAlias> </pathAliases> <block> <transaction> <update> <property>``@value``</property> <rate> <dataItem> <pathAlias ref=``"column-sum"``></pathAlias> <property>``@value``</property> </dataItem> </rate> </update> </transaction> </block> </rule>
(lightbulb) Additional Use Case: Checking if a particular target value has been updating or not <rule name=``"lastUpdated"``> <targets> <target>/geneos/gateway/directory/probe/managedEntity/sampler/dataview/headlines/cell</target> </targets> <priority>``1``</priority> <block> <``if``> <equal> <rate> <dataItem> <property>``@value``</property> </dataItem> </rate> <integer>``0``</integer> </equal> <transaction> <delay>``600``</delay> <update> <property>state/``@severity``</property> <severity>critical</severity> </update> </transaction> <transaction> <update> <property>state/``@severity``</property> <severity>ok</severity> </update> </transaction> </``if``> </block> </rule>
Info This rule checks the value of the cell using the rate of change function ‘rate()’; if there are no changes (the rate of change will yield 0), it will then have a delay of 10 minutes (600 seconds) and thereafter, if the value still did not change, it will tag it as severity: Critical.
The rate function can also be used with the compute engine to calculate the last value of a cell