The State tracker plugin can be used to look for a particular sequence of keywords or entries in a log file. Therefore if your batch job writes out to a consistent log, and you can identify selected entries are being particular stages in the batch job then you can track progress in the batch job. On its own however this will not provide the timings for the batch job. To do this it is suggested you use some compute engine functionality to populate the time.
Some additional headlines and cells can be added to the statetracker dataview. To populate those, three rules can be used (one for each cell to track the current state and copy the time). Once the job is complete, the third rule will then compute for the duration of the start and the end time. Please refer to the code blocks below:
The following code block contains rules_jobduration.xml
<rules> <rule name="start time"> <targets> <target>/geneos/gateway[(@name="gateway_test")]/directory/probe[(@name="NewTest")]/managedEntity[(@name="Job Duration")]/sampler[(@name="statetracker-duration")][(@type="")]/dataview[(@name="Batch Run")]/headlines/cell[(@name="Last Job Started")]</target> </targets> <priority>1</priority> <pathAliases> <pathAlias name="state">ancestor-or-self::dataview[(@name="Batch Run")]/rows/row[(@name="Current Jobs")]/cell[(@column="state")]</pathAlias> <pathAlias name="time">ancestor-or-self::dataview[(@name="Batch Run")]/rows/row[(@name="Current Jobs")]/cell[(@column="time")]</pathAlias> </pathAliases> <block> <if> <like> <dataItem> <pathAlias ref="state"></pathAlias> <property>@value</property> </dataItem> <string>Job Running</string> </like> <transaction> <update> <property>@value</property> <dataItem> <pathAlias ref="time"></pathAlias> <property>@value</property> </dataItem> </update> </transaction> </if> </block> </rule> <rule name="end time"> <targets> <target>/geneos/gateway[(@name="gateway_test")]/directory/probe[(@name="NewTest")]/managedEntity[(@name="Job Duration")]/sampler[(@name="statetracker-duration")][(@type="")]/dataview[(@name="Batch Run")]/headlines/cell[(@name="Last Job Ended")]</target> </targets> <priority>1</priority> <pathAliases> <pathAlias name="state">ancestor-or-self::dataview[(@name="Batch Run")]/rows/row[(@name="Current Jobs")]/cell[(@column="state")]</pathAlias> <pathAlias name="time">ancestor-or-self::dataview[(@name="Batch Run")]/rows/row[(@name="Current Jobs")]/cell[(@column="time")]</pathAlias> </pathAliases> <block> <if> <like> <dataItem> <pathAlias ref="state"></pathAlias> <property>@value</property> </dataItem> <string>Job Completed</string> </like> <transaction> <update> <property>@value</property> <dataItem> <pathAlias ref="time"></pathAlias> <property>@value</property> </dataItem> </update> </transaction> </if> </block> </rule> <rule name="Duration"> <targets> <target>/geneos/gateway[(@name="gateway_test")]/directory/probe[(@name="NewTest")]/managedEntity[(@name="Job Duration")]/sampler[(@name="statetracker-duration")][(@type="")]/dataview[(@name="Batch Run")]/rows/row[(@name="Current Jobs")]/cell[(@column="Duration")]</target> </targets> <priority>10</priority> <pathAliases> <pathAlias name="state">../cell[(@column="state")]</pathAlias> <pathAlias name="start">ancestor-or-self::dataview[(@name="Batch Run")]/headlines/cell[(@name="Last Job Started")]</pathAlias> <pathAlias name="end">ancestor-or-self::dataview[(@name="Batch Run")]/headlines/cell[(@name="Last Job Ended")]</pathAlias> </pathAliases> <block> <set> <var ref="started"></var> <parseDate> <string>%Y-%m-%d %H:%M:%S</string> <dataItem> <pathAlias ref="start"></pathAlias> <property>@value</property> </dataItem> </parseDate> </set> <set> <var ref="ended"></var> <parseDate> <string>%Y-%m-%d %H:%M:%S</string> <dataItem> <pathAlias ref="end"></pathAlias> <property>@value</property> </dataItem> </parseDate> </set> <if> <like> <dataItem> <pathAlias ref="state"></pathAlias> <property>@value</property> </dataItem> <string>Job Completed</string> </like> <transaction> <update> <property>@value</property> <divide> <subtract> <var ref="ended"></var> <var ref="started"></var> </subtract> <integer>60</integer> </divide> </update> </transaction> <transaction> <update> <property>@value</property> <string></string> </update> </transaction> </if> </block> </rule> </rules>
The following code block contains sampler_jobduration.xml
<sampler name="statetracker-duration"> <sampleInterval> <data>5</data> </sampleInterval> <plugin> <stateTracker> <behavioural> <fileTruncateResetsTrackers> <data>true</data> </fileTruncateResetsTrackers> </behavioural> <trackerGroup name="Batch Run"> <trackers> <tracker name="Current Jobs"> <filename> <data>/tmp/batchrun.log</data> </filename> <rewind> <data>true</data> </rewind> <states> <defaultState name="Initializing"> <allowTransitionToStates> <states> <state ref="Job Running"></state> </states> </allowTransitionToStates> </defaultState> <state name="Job Running"> <keys> <key> <data>^START</data> </key> </keys> <allowTransitionToStates> <states> <state ref="Job Completed"></state> </states> </allowTransitionToStates> </state> <state name="Job Completed"> <keys> <key> <data>^COMPLETE</data> </key> </keys> </state> </states> </tracker> </trackers> </trackerGroup> </stateTracker> </plugin> <dataviews> <dataview name="Batch Run"> <additions> <headlines> <headline>Last Job Started</headline> <headline>Last Job Ended</headline> </headlines> <columns> <column>Duration</column> </columns> </additions> </dataview> </dataviews> </sampler>
Refer to the image below of the dataview to have a grasp of the concept:

Attachments:
|
Comments
0 comments
Please sign in to leave a comment.