You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.7 KiB

  1. From 7397526d0c80251b3006b1b45af754f5ad7adb76 Mon Sep 17 00:00:00 2001
  2. From: Nenad Merdanovic <nmerdan@anine.io>
  3. Date: Mon, 3 Oct 2016 04:57:37 +0200
  4. Subject: [PATCH 05/26] MINOR: Add fe_req_rate sample fetch
  5. The fe_req_rate is similar to fe_sess_rate, but fetches the number
  6. of HTTP requests per second instead of connections/sessions per second.
  7. Signed-off-by: Nenad Merdanovic <nmerdan@anine.io>
  8. (cherry picked from commit ad9a7e9770e673a70fb56ab95be18bf88666d92a)
  9. ---
  10. doc/configuration.txt | 5 +++++
  11. src/frontend.c | 14 ++++++++++++++
  12. 2 files changed, 19 insertions(+)
  13. diff --git a/doc/configuration.txt b/doc/configuration.txt
  14. index d4b1744..d18c399 100644
  15. --- a/doc/configuration.txt
  16. +++ b/doc/configuration.txt
  17. @@ -12253,6 +12253,11 @@ fe_conn([<frontend>]) : integer
  18. statistics to servers in HTTP headers. See also the "dst_conn", "be_conn",
  19. "fe_sess_rate" fetches.
  20. +fe_req_rate([<frontend>]) : integer
  21. + Returns an integer value corresponding to the number of HTTP requests per
  22. + second sent to a frontend. This number can differ from "fe_sess_rate" in
  23. + situations where client-side keep-alive is enabled.
  24. +
  25. fe_sess_rate([<frontend>]) : integer
  26. Returns an integer value corresponding to the sessions creation rate on the
  27. frontend, in number of new sessions per second. This is used with ACLs to
  28. diff --git a/src/frontend.c b/src/frontend.c
  29. index 74ec0ab..5cc6202 100644
  30. --- a/src/frontend.c
  31. +++ b/src/frontend.c
  32. @@ -167,6 +167,19 @@ smp_fetch_fe_id(const struct arg *args, struct sample *smp, const char *kw, void
  33. return 1;
  34. }
  35. +/* set temp integer to the number of HTTP requests per second reaching the frontend.
  36. + * Accepts exactly 1 argument. Argument is a frontend, other types will cause
  37. + * an undefined behaviour.
  38. + */
  39. +static int
  40. +smp_fetch_fe_req_rate(const struct arg *args, struct sample *smp, const char *kw, void *private)
  41. +{
  42. + smp->flags = SMP_F_VOL_TEST;
  43. + smp->data.type = SMP_T_SINT;
  44. + smp->data.u.sint = read_freq_ctr(&args->data.prx->fe_req_per_sec);
  45. + return 1;
  46. +}
  47. +
  48. /* set temp integer to the number of connections per second reaching the frontend.
  49. * Accepts exactly 1 argument. Argument is a frontend, other types will cause
  50. * an undefined behaviour.
  51. @@ -200,6 +213,7 @@ smp_fetch_fe_conn(const struct arg *args, struct sample *smp, const char *kw, vo
  52. static struct sample_fetch_kw_list smp_kws = {ILH, {
  53. { "fe_conn", smp_fetch_fe_conn, ARG1(1,FE), NULL, SMP_T_SINT, SMP_USE_INTRN, },
  54. { "fe_id", smp_fetch_fe_id, 0, NULL, SMP_T_SINT, SMP_USE_FTEND, },
  55. + { "fe_req_rate", smp_fetch_fe_req_rate, ARG1(1,FE), NULL, SMP_T_SINT, SMP_USE_INTRN, },
  56. { "fe_sess_rate", smp_fetch_fe_sess_rate, ARG1(1,FE), NULL, SMP_T_SINT, SMP_USE_INTRN, },
  57. { /* END */ },
  58. }};
  59. --
  60. 2.7.3