counters_functions.xml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"
  4. [ <!ENTITY % local.common.attrib
  5. "xmlns:xi CDATA #FIXED 'http://www.w3.org/2001/XInclude'">
  6. <!-- Include general documentation entities -->
  7. <!ENTITY % docentities SYSTEM "../../../docbook/entities.xml">
  8. %docentities;
  9. ]
  10. >
  11. <section id="cnts.functions" xmlns:xi="http://www.w3.org/2001/XInclude">
  12. <sectioninfo>
  13. </sectioninfo>
  14. <title>Functions</title>
  15. <section id="cnt_inc">
  16. <title>
  17. <function>cnt_inc([group.]name)</function>
  18. </title>
  19. <para>
  20. Increments the counter <emphasis>group.name</emphasis>. The counter
  21. must be defined using the <varname>script_counter</varname>
  22. module parameter.
  23. If the group name is missing, the group specified by the
  24. <varname>script_cnt_grp_name</varname> modparam will be used.
  25. </para>
  26. <example>
  27. <title><function>cnt_inc</function> usage</title>
  28. <programlisting>
  29. ...
  30. modparam("counters", "script_counter", "reqs")
  31. modparam("counters", "script_counter", "out.reqs forwarded requests")
  32. ...
  33. route {
  34. cnt_inc("reqs");
  35. if (forward(uri:host, uri:port))
  36. cnt_inc("out.reqs");
  37. ...
  38. }
  39. </programlisting>
  40. </example>
  41. </section>
  42. <section id="cnt_add">
  43. <title>
  44. <function>cnt_add([group.]name, number)</function>
  45. </title>
  46. <para>
  47. Adds <emphasis>number</emphasis> the counter
  48. <emphasis>group.name</emphasis>.
  49. The counter must be defined using the
  50. <varname>script_counter</varname> module parameter.
  51. If the group name is missing, the group specified by the
  52. <varname>script_cnt_grp_name</varname> modparam will be used.
  53. </para>
  54. <example>
  55. <title><function>cnt_add</function> usage</title>
  56. <programlisting>
  57. ...
  58. modparam("counters", "script_counter", "reqs10 reqs times 10")
  59. ...
  60. route {
  61. cnt_add("reqs10", 10);
  62. ...
  63. }
  64. </programlisting>
  65. </example>
  66. </section>
  67. <section id="cnt_reset">
  68. <title>
  69. <function>cnt_reset([group.]name)</function>
  70. </title>
  71. <para>
  72. Resets the counter <emphasis>group.name</emphasis>. The counter
  73. must be defined using the <varname>script_counter</varname>
  74. module parameter.
  75. If the group name is missing, the group specified by the
  76. <varname>script_cnt_grp_name</varname> modparam will be used.
  77. </para>
  78. <example>
  79. <title><function>cnt_reset</function> usage</title>
  80. <programlisting>
  81. ...
  82. modparam("counters", "script_counter", "reqs")
  83. ...
  84. route {
  85. if (...)
  86. cnt_reset("reqs");
  87. ...
  88. }
  89. </programlisting>
  90. </example>
  91. </section>
  92. </section>