Icinga2 DateTime() function not working as expected

Dear experts,

Im using Icinga2.11 on RHEL os. Im using DateTime() function using macros in a service definition.

This function is not working as expected. I mean when i restarted/reload the icinga2 services then it is showing the correct date otherwise always it is showing the old date of when i had restarted/reloaded the services.

vars.daybefore = (DateTime() - (24 * 60 * 60)).format("%Y%m%d")

Can you please help in fixing this.

with Regards,
Krishna Rajapantula

Hi,

this will not really work. i think it should be (untestet)

vars.daybefore = {{ return "" + (DateTime() - (24 * 60 * 60)).format("%Y%m%d").to_string() + "" }}

Regards,
Carsten

Thanks Carsten…Let me test this and update you.

With Regards,
Krishna

1 Like

Thanks Carsten, it is working as expected.

2 Likes