<!-- Module User's Guide -->

<chapter>
	<chapterinfo>
	<revhistory>
		<revision>
		<revnumber>$Revision: 1827 $</revnumber>
		<date>$Date: 2007-03-12 17:22:53 +0200 (Mon, 12 Mar 2007) $</date>
		</revision>
	</revhistory>
	</chapterinfo>
	<title>User's Guide</title>
	
	<section>
	<title>Overview</title>
	<para>
		The <acronym>Statistics</acronym> module is a wrapper over the internal
		statistics manager, allowing the script writer to dynamically define and
		use of statistic variables.
	</para>
	<para>
		By bringing the statistics support into the script, it takes advantage
		of the script flexibility in defining logics, making possible 
		implementation of any kind of statistic scenario.
	</para>
	</section>
	<section>
	<title>Dependencies</title>
	<section>
		<title>&ser; Modules</title>
		<para>
		The following modules must be loaded before this module:
			<itemizedlist>
			<listitem>
			<para>
				<emphasis>No dependencies on other &ser; modules</emphasis>.
			</para>
			</listitem>
			</itemizedlist>
		</para>
	</section>
	<section>
		<title>External Libraries or Applications</title>
		<para>
		The following libraries or applications must be installed before running
		&ser; with this module loaded:
			<itemizedlist>
			<listitem>
			<para>
				<emphasis>None</emphasis>.
			</para>
			</listitem>
			</itemizedlist>
		</para>
	</section>
	</section>

	<section>
	<title>Exported Parameters</title>
	<section>
		<title><varname>variable</varname> (string)</title>
		<para>
		Name of a new statistic variable. The name may be followed by additional
		flag which describe the variable behavior:
		</para>
			<itemizedlist>
			<listitem>
			<para>
				<emphasis>no_reset</emphasis> : variable cannot be reset.
			</para>
			</listitem>
			</itemizedlist>
		<example>
		<title>variable example</title>
		<programlisting format="linespecific">
modparam("statistics", "variable", "register_counter")
modparam("statistics", "variable", "active_calls/no_reset")
</programlisting>
		</example>
	</section>
	</section>

	<section>
	<title>Exported Functions</title>
	<section>
		<title>
		<function moreinfo="none">update_stat(variable,value)</function>
		</title>
		<para>
		Updates the value of the statistic variable with the new value.
		</para>
		<para>Meaning of the parameters is as follows:</para>
		<itemizedlist>
		<listitem>
			<para><emphasis>variable</emphasis> - variable to be updated
			</para>
		</listitem>
		<listitem>
			<para><emphasis>value</emphasis> - value to update with; it may be
			also negative
			</para>
		</listitem>
		</itemizedlist>
		<para>
		This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, 
		FAILURE_ROUTE and ONREPLY_ROUTE.
		</para>
		<example>
		<title><function>update_stat</function> usage</title>
		<programlisting format="linespecific">
...
update_stat("register_counter", "+1");
...
update_stat("active_calls", "-1");
...
</programlisting>
		</example>
	</section>

	<section>
		<title>
		<function moreinfo="none">reset_stat(variable)</function>
		</title>
		<para>
		Resets to zero the value of the statistic variable.
		</para>
		<para>
		This function can be used from REQUEST_ROUTE, BRANCH_ROUTE, 
		FAILURE_ROUTE and ONREPLY_ROUTE.
		</para>
		<example>
		<title><function>reset_stat</function> usage</title>
		<programlisting format="linespecific">
...
reset_stat("register_counter");
...
</programlisting>
		</example>
	</section>
	</section>
</chapter>

<!-- Keep this element at the end of the file
Local Variables:
sgml-parent-document: ("statistics.sgml" "Book" "chapter")
End:
-->
