Is a global timestamp expression possible ?
-
I’ve looked and can’t find the answer which concerns me that the answer is obvious and thats why I can't find the answer to this.
I’m new to MSR and this is my first post, so please bare with me
What I’m trying to do is have a global expression that contains the current time so I can use it in Global reactions as well as Rulesets as part of my syslog messages.
Example of what I’m experiencing:
In Expressions, create a global expression: gMyTOD = strftime("%T %D”)
In Rulesets, in a rule, create a local expression: MyTOD = strftime("%T %D”)In that same rule create a Notify type of Syslog.
Set syslog message to: gMyTOD time is ${{gMyTOD}} and MyTOD time is ${{MyTOD}}
Trigger the rule.The result is that the local expression (MyTOD) contains the correct time but the global expression (gMyTOD) does not update and reflects the wrong time in the final syslog message.
Is there a different approach I should be using?
Thank you in advance for any insight.
-bh
-
I’ve looked and can’t find the answer which concerns me that the answer is obvious and thats why I can't find the answer to this.
I’m new to MSR and this is my first post, so please bare with me
What I’m trying to do is have a global expression that contains the current time so I can use it in Global reactions as well as Rulesets as part of my syslog messages.
Example of what I’m experiencing:
In Expressions, create a global expression: gMyTOD = strftime("%T %D”)
In Rulesets, in a rule, create a local expression: MyTOD = strftime("%T %D”)In that same rule create a Notify type of Syslog.
Set syslog message to: gMyTOD time is ${{gMyTOD}} and MyTOD time is ${{MyTOD}}
Trigger the rule.The result is that the local expression (MyTOD) contains the correct time but the global expression (gMyTOD) does not update and reflects the wrong time in the final syslog message.
Is there a different approach I should be using?
Thank you in advance for any insight.
-bh
@basai you are creating a variable that you are using in a substitution. Your example:
Set syslog message to:
gMyTOD time is ${{gMyTOD}} and MyTOD time is ${{MyTOD}}
Instead of that, use the expression directly in the message:
The time is ${{ strftime( "%T %D" ) }}
The substitution doesn't just put in a named variable, it evaluates an expression. It turns out, a variable name by itself is just a really simple expression, but the expression inside
${{ }}
can be as complex as you can tolerate. -
@basai you are creating a variable that you are using in a substitution. Your example:
Set syslog message to:
gMyTOD time is ${{gMyTOD}} and MyTOD time is ${{MyTOD}}
Instead of that, use the expression directly in the message:
The time is ${{ strftime( "%T %D" ) }}
The substitution doesn't just put in a named variable, it evaluates an expression. It turns out, a variable name by itself is just a really simple expression, but the expression inside
${{ }}
can be as complex as you can tolerate.@toggledbits Thank you for the reply and solution.
What confused me was that as an expression created within a Rule it worked fine, but now that I read your reply I see why, this was a "Doh!" on my part, I hadn't thought of it like that.
Thanks again!,
-b -
T toggledbits locked this topic on