Useful extensions for the server configuration. The cfgutils module can be used to introduce randomness to the behaviour of the server. It provides setup functions and the “rand_event” function. This function return either true or false, depending on a random value and a specified probability. E.g. if you set via fifo or script a probability value of 5%, then 5% of all calls to rand_event will return true. The pseudovariable “$RANDOM” could be used to introduce random values e.g. into a SIP reply. The benefit of this module is the probability of the decision can be manipulated by external applications such as web interface or command line tools. The probability must be specified as percent value, ranging from 0 to 100. The module exports commands to FIFO server that can be used to change the global settings via FIFO interface. The FIFO commands are: “set_prob”, “reset_prob” and “get_prob”. This module can be used for simple load-shedding, e.g. reply 5% of the Invites with a 503 error and an adequate random Retry-After value. The module provides as well functions to delay the execution of the server. The functions “sleep” and “usleep” could be used to let the server wait a specific time interval. It can also hash the config file used from the server with a (weak) cryptographic hash function on startup. This value is saved and can be later compared to the actual hash, to detect modifications of this file after the server start. This functions are available as the FIFO commands
| Parámetro | Tipo | Descripción |
|---|---|---|
| initial_probability | string | 3.2. hash_file (string) 3.3. initial_gflags (integer) 3.4. lock_set_size (integer) |
| hash_file | string | 3.3. initial_gflags (integer) 3.4. lock_set_size (integer) |
| initial_gflags | integer | 3.4. lock_set_size (integer) |
| lock_set_size | integer | 3.1. initial_probability (string) |
| initial_probability | string | The initial value of the probability. |
| hash_file | string | The config file name for that a hash value should be calculated on startup. |
| initial_gflags | integer | The initial value of global flags bitmap. |
| lock_set_size | integer | Size of lock set - the value is used as power of two to compute the size of lock array. |
4.2. rand_set_prob(probability) 4.3. rand_reset_prob() 4.4. rand_get_prob() 4.5. sleep(time) 4.6. usleep(time) 4.7. abort() 4.8. pkg_status() 4.9. pkg_summary() 4.10. shm_status() 4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14
4.3. rand_reset_prob() 4.4. rand_get_prob() 4.5. sleep(time) 4.6. usleep(time) 4.7. abort() 4.8. pkg_status() 4.9. pkg_summary() 4.10. shm_status() 4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key
4.4. rand_get_prob() 4.5. sleep(time) 4.6. usleep(time) 4.7. abort() 4.8. pkg_status() 4.9. pkg_summary() 4.10. shm_status() 4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock
4.5. sleep(time) 4.6. usleep(time) 4.7. abort() 4.8. pkg_status() 4.9. pkg_summary() 4.10. shm_status() 4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17.
4.6. usleep(time) 4.7. abort() 4.8. pkg_status() 4.9. pkg_summary() 4.10. shm_status() 4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key
4.7. abort() 4.8. pkg_status() 4.9. pkg_summary() 4.10. shm_status() 4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_ro
4.8. pkg_status() 4.9. pkg_summary() 4.10. shm_status() 4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_route_exists(ro
4.9. pkg_summary() 4.10. shm_status() 4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_route_exists(route) 4.19. route_i
4.10. shm_status() 4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_route_exists(route) 4.19. route_if_exists(route) 4.2
4.11. shm_summary() 4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_route_exists(route) 4.19. route_if_exists(route) 4.20. core_hash(string
4.12. set_gflag(flag) 4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_route_exists(route) 4.19. route_if_exists(route) 4.20. core_hash(string1, string2, size)
4.13. reset_gflag(flag) 4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_route_exists(route) 4.19. route_if_exists(route) 4.20. core_hash(string1, string2, size)
4.14. is_gflag(flag) 4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_route_exists(route) 4.19. route_if_exists(route) 4.20. core_hash(string1, string2, size)
4.15. lock(key [, key2]) 4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_route_exists(route) 4.19. route_if_exists(route) 4.20. core_hash(string1, string2, size)
4.16. trylock(key [, key2]) 4.17. unlock(key [, key2]) 4.18. check_route_exists(route) 4.19. route_if_exists(route) 4.20. core_hash(string1, string2, size)
4.17. unlock(key [, key2]) 4.18. check_route_exists(route) 4.19. route_if_exists(route) 4.20. core_hash(string1, string2, size)
4.18. check_route_exists(route) 4.19. route_if_exists(route) 4.20. core_hash(string1, string2, size)
4.19. route_if_exists(route) 4.20. core_hash(string1, string2, size)
4.20. core_hash(string1, string2, size)
4.1. rand_event()
Return true or false, depending on a random value and a probability value.
usage ... if (rand_event()) { append_to_reply("Retry-After: 120\n"); sl_send_reply("503", "Try later"); exit; }; # normal message processing follows ...
Set the “probability” of the decision.
usage ... rand_set_prob("4"); ...
Reset the probability back to the initial value.
Copyright © 2014, 2013, 2007, 2008, 2004 Edvina AB, 1und1 Internet AG,