AnsweredAssumed Answered

Built-in AE epoch time function?

Question asked by eric.felker on Sep 17, 2015
Latest reply on May 3, 2016 by BenCroffut603954
Hi all,

We are looking for a built-in epoch time function, which would make our lives so much easier. 

Brief usecase:
Job runs once a minute to check numerous host's health. If health is not good, it should perform some reactive processing to restore health which includes many host reboots.

BUT:
  • reactive processing should never occur more than once in 15 minute period
  • reactive processing should never occur more than twice in 60 minute period
For this reason, we need to track the last time reactive processing has taken place, and compare to current time if we are about to try reactive processing again. epoch would make this a very simple numeric comparison. e.g.:
current_epoch - last_epoch < 900 = ABORT
The above doesn't care about hour/day barriers, which is why it rocks.

With the time and date functions we see documented, calculating the difference in time becomes a much larger task. Are we just missing the function that takes two timestamps (that includes date & time) and can output the difference in minutes?

With what we see, we could capture time and date separately, then make use of the two DIFF* functions, but then we're forced to considering these pieces of time information individually, which is bad. What happens when we cross day/time barriers? Like if the last execution occurred at 23:55, and it's now 00:05 on the next day. We need to make sense of what the last and current date is, and make sense of the last and current times, and eventually arrive at it being only a 10 minute difference. That would take numerous IFs and well thought out logic. The more we looked at it, the more pitfalls we found that needed consideration. So we're thinking there must be a better way, right?

So firstly, we're not overlooking an epoch function, right? If that doesn't exist, has anyone here had to build time logic like this? Is this sort of time dependency built in somewhere else?

One alternative we're looking at is building a separate agent-reliant JOBS to run an epoch command, output, PREP_PROCESS_REPORT, capture in a VARA, etc... but shouldn't this just be natively available in the application? We also found PREP_PROCESS which is really cool but still reliant on an agent to get a simple epoch timestamp which isn't ideal. The JOBS route at least supports a HOSTG so that is covered, but takes quite a bit of work just to get one CLI line output into a variable in AE script. PREP_PROCESS maybe shines here, but does not accept a HOSTG, so we should really do a PREP_PROCESS_AGENTGROUP first to cover our bases and to make sure we're selecting a host that is not offline/being rebooted (see usecase statement above).

BTW, wasn't it possible in Application Manager to build little modules that would run against the core host's OS at job runtime?  Of course these modules would need to be tightly controlled, but something like this would be really cool:
:SET &EPOCH# = USER_DEFINED_GET_EPOCH_TIME_MODULE()
We are on Automation Engine v9 sp8.

Outcomes