Ad Widget

Collapse

Creating trigger to compare timestamp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • maxxer
    Member
    • Oct 2010
    • 80

    #1

    Creating trigger to compare timestamp

    hi.
    I'm trying to create a trigger to check last backup freshness.
    This script return the timestamp of the last successful backup.

    I also created a discovery rule which returns the enabled backups and the max age of it. Returned data is something like this (of course I can change maxage to whatever needed):
    Code:
    {"data":[                                                               
            { "{#TYPE}":"hourly", "{#MAXAGE}":"1d" },                       
            { "{#TYPE}":"daily", "{#MAXAGE}":"1d" },                        
            { "{#TYPE}":"weekly", "{#MAXAGE}":"7d" },                       
            { "{#TYPE}":"monthly", "{#MAXAGE}":"1m" }                       
    ]}
    I managed to create the item, but how do I create the trigger? I had a look through the available expressions but didn't find one that could fit.
    The function should be
    Code:
    last()
    but how do I generate the NOW()-#MAXAGE value? I tried
    Code:
    {Template App rsnapshot:rsnapshot.check[{#TYPE}].last()}<now()
    but it's not accepted (also it's missing the time span...).

    Help appreciated.
    thanks!
  • maxxer
    Member
    • Oct 2010
    • 80

    #2
    solved with this trigger expression:
    Code:
    {Template App rsnapshot:rsnapshot.check[{#TYPE}].now()}-{Template App rsnapshot:rsnapshot.check[{#TYPE}].last()}>{#MAXAGE}
    and changing MAXAGE to be in seconds

    Comment

    Working...