What is even more interesting - I can't reproduce that behaviour on my laptop with 8.2402 on Fedora 38.

Either there is some change in either the behaviour of rsyslog itself or the linked libraries (the 8.2302 was on SUSe). Or there is something else in my config (that random-picking code was just a small part of a ruleset within a relatively big config) that's affecting the random generator.

Strange.

MK

On 6.02.2024 16:17, Mariusz Kruk via rsyslog wrote:
rsyslog-8.2302.0

A ruleset contains a piece of code supposed to chose somehting at random.

At first it was like this:

set $.set = "abcd";
set $.len = strlen($.set);
set $.n = random($.len);
set $.choice = substring($.set,$.len,1);

But I was afraid that random() could not be perfectly uniform with such small range so I did the usual trick and replaced it with

set $.n = random(30000) % $.len;

And...

I stopped getting "c" as a result. Completely. I know it's not supposed to be a crypto-grade random number generator but skewed this much?

I lowered the limit for random to 3000 and it seems it distributes my values pretty uniformly now

MK

_______________________________________________
rsyslog mailing list
https://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE THAT.
_______________________________________________
rsyslog mailing list
https://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to