Prototype: randomint(lower, upper)

Return type: int

Description: Returns a random integer between lower and up to but not including upper.

The limits must be integer values and the resulting numbers are based on the entropy of the md5 algorithm.

The upper limit is excluded from the range. Thus randomint(0, 100) will return 100 possible values, not 101.

The function will be re-evaluated on each pass if it is not restricted with a context class expression as shown in the example.

NOTE: The randomness produced by randomint is not safe for cryptographic usage.


  • lower: int, in the range: -99999999999,99999999999
  • upper: int, in the range: -99999999999,99999999999


bundle agent main
      "low"    string => "4";
      "high"   string => "60";

      "random"    int => randomint($(low), $(high));
      "isabove" expression => isgreaterthan($(random), 3);

      "The generated random number was above 3";

      "Randomly generated '$(random)'";

Output: (when show_random is defined)

R: The generated random number was above 3
R: Randomly generated '9'
R: Randomly generated '52'
R: Randomly generated '26'