Page 2 of 4

Re: ES 6.0: Rules engine for notifications

Posted: Thu Sep 10, 2020 11:18 pm
by asker
Magic919 wrote: Thu Sep 10, 2020 7:58 am This alert got muted, but it shouldn't have.

I presume this is the second part of the json that mutes 3-6 am. I'll have a go at removing that, but I'm not a json expert.

Would prefer 24 hour clock if that's an option :-)
It is an option. Just change the time format specification. Google for "strftime format" and use any format you want. For 24 hrs, it would be "%H:%M" and change the from and to fields to 24 hr format. As far as the other rule is concerned, just delete it.

Re: ES 6.0: Rules engine for notifications

Posted: Fri Sep 11, 2020 10:39 am
by Magic919
Thanks for the reply.

I've amended the time format and converted my times to 24 hour clock.

I managed to delete the second mute. It's simple with JSON expertise (which I don't have) but knowing where to stop, which brace, do I still need the comma, these are the challenges. I used a chop and JSON validate method and that worked out.

It's working for the ZMNinja notifications too.

Re: ES 6.0: Rules engine for notifications

Posted: Fri Sep 11, 2020 6:04 pm
by asker
Ok great. Thanks for testing!

Re: ES 6.0: Rules engine for notifications

Posted: Sun Sep 13, 2020 11:14 am
by Magic919
It doesn't care about the daysofweek and is still muting today (Sunday).

CONSOLE INF:2020-09-13,12:10:26 |----> FORK:Shed2 (12), eid:223247 Event 223247 for Monitor 12 has finished
CONSOLE DBG-1:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: (eid: 223247) -- Processing rule: 1 --
CONSOLE DBG-2:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: parsing rule 06:30/22:00 using format:%H:%M
CONSOLE DBG-2:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: parsed time from: Thu Jan 1 06:30:00 1970 and to:Thu Jan 1 22:00:00 1970
CONSOLE DBG-2:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules:(eid: 223247) seeing if now:12:10 is between:06:30 and 22:00
CONSOLE DBG-1:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: (eid: 223247) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-13,12:10:28 |----> FORK:Shed2 (12), eid:223247 rules: Not processing start notifications as rules checks failed

Re: ES 6.0: Rules engine for notifications

Posted: Sun Sep 13, 2020 11:55 am
by asker
1. Could you please update ES
2. Please make sure you are using the key "daysofweek" to specify days (In the past, I was using "dow" somewhere in error)

Re: ES 6.0: Rules engine for notifications

Posted: Sun Sep 13, 2020 1:16 pm
by Magic919
Thanks for the quick response.

I've updated and it's still behaving a bit strangely. It seems to think it is Thursday today if I understand correctly. First day of the Epoch too.

Code: Select all

CONSOLE DBG-1:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: (eid: 223265) -- Processing rule: 1 --
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: parsing rule 06:30/22:00 using format:%H:%M
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: parsed time from: Thu Jan  1 06:30:00 1970 and to:Thu Jan  1 22:00:00 1970
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules:(eid: 223265)  seeing if now:13:58 is between:06:30 and 22:00
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules:(eid: 223265)  seeing if now:Thu matches:Mon,Tue,Wed,Thu,Fri
CONSOLE DBG-1:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: (eid: 223265) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-13,13:58:36 |----> FORK:Shed2 (12), eid:223265 rules: Not processing start notifications as rules checks failed


Re: ES 6.0: Rules engine for notifications

Posted: Sun Sep 13, 2020 2:05 pm
by asker
Uh oh, that's right. It's a bug. Will fix it.

Re: ES 6.0: Rules engine for notifications

Posted: Sun Sep 13, 2020 6:23 pm
by asker
Please update and try (you'll still see 1970 but day of week should work as expected)

Re: ES 6.0: Rules engine for notifications

Posted: Sun Sep 13, 2020 6:48 pm
by Magic919
Ok, have updated and will see what happens.

Thanks.

Re: ES 6.0: Rules engine for notifications

Posted: Mon Sep 14, 2020 6:34 am
by Magic919
Hmmm. Seems to believe today is Thursday if I understand correctly. It's already muted based on time, however. I can drop Thur out of the json and see what occurs next.

Code: Select all

CONSOLE DBG-2:2020-09-14,06:57:42 |----> FORK:Shed2 (12), eid:223320 rules:(eid: 223320)  seeing if now:06:57 is between:06:30 and 22:00
CONSOLE DBG-2:2020-09-14,06:57:42 |----> FORK:Shed2 (12), eid:223320 rules:(eid: 223320)  seeing if now:Thu matches:Mon,Tue,Wed,Thu,Fri
CONSOLE DBG-1:2020-09-14,06:57:42 |----> FORK:Shed2 (12), eid:223320 rules: (eid: 223320) mute rule matched, not allowing

Re: ES 6.0: Rules engine for notifications

Posted: Mon Sep 14, 2020 10:22 am
by Magic919
Dropping out Thu just leaves it the time and it's happy to match on that and mute (incorrectly). Feels like it matches OR instead of AND.

Code: Select all

CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules: parsing rule 10:30/22:00 using format:%H:%M
CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules: parsed time from: Thu Jan  1 10:30:00 1970 and to:Thu Jan  1 22:00:00 1970
CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules:(eid: 223349)  seeing if now:10:59 is between:10:30 and 22:00
CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules:(eid: 223349)  seeing if now:Thu matches:Mon,Tue,Wed,Fri
CONSOLE DBG-1:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules: (eid: 223349) mute rule matched, not allowing
CONSOLE DBG-2:2020-09-14,10:59:06 |----> FORK:Shed2 (12), eid:223349 rules: Not processing start notifications as rules checks failed

Re: ES 6.0: Rules engine for notifications

Posted: Mon Sep 14, 2020 10:33 am
by asker
What is the output of this sample program?

Code: Select all

use Time::Piece;
my $now = Time::Piece->new;
print ("Date is $now\n");
print ("Weekday is ".$now->wdayname."\n");
Assuming you save it as foo.pl, you can run it by doing

Code: Select all

 perl ./foo.pl
Is the output correct?

Re: ES 6.0: Rules engine for notifications

Posted: Mon Sep 14, 2020 10:37 am
by asker
Also ,there was a logging error in ES - please update.

Re: ES 6.0: Rules engine for notifications

Posted: Mon Sep 14, 2020 11:35 am
by Magic919
Here's the Perl bit -

Code: Select all

perl ./foo.pl
Date is Mon Sep 14 12:34:47 2020
Weekday is Mon
Correct fror my TZ.

I'll update ES once I've eaten.

Re: ES 6.0: Rules engine for notifications

Posted: Mon Sep 14, 2020 12:23 pm
by Magic919
Have updated ES.