Sophie

Sophie

distrib > Mandriva > 2008.0 > x86_64 > by-pkgid > 00bdf001b179ab7cab5a36ebc3f9271b > files > 166

gnugk-2.2.6-2mdv2008.0.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
 <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.21">
 <TITLE>OpenH323 Gatekeeper - The GNU Gatekeeper: Accounting Configuration</TITLE>
 <LINK HREF="manual-10.html" REL=next>
 <LINK HREF="manual-8.html" REL=previous>
 <LINK HREF="manual.html#toc9" REL=contents>
</HEAD>
<BODY>
<A HREF="manual-10.html">Next</A>
<A HREF="manual-8.html">Previous</A>
<A HREF="manual.html#toc9">Contents</A>
<HR>
<H2><A NAME="s9">9.</A> <A HREF="manual.html#toc9">Accounting Configuration</A></H2>

<P>The following sections in the config file can be used to configure accounting.</P>

<H2><A NAME="gkacct"></A> <A NAME="ss9.1">9.1</A> <A HREF="manual.html#toc9.1">Section [Gatekeeper::Acct]</A>
</H2>

<P>The section defines a list of modules that will be performing accounting.
The accounting is for logging gatekeeper on/off events and call start/stop/update
events. Each accounting module logs received events to a module specific storage.
Such storage can be a plain text file or a RADIUS server and many
more. The configuration is very similar to the one for gatekeeper authentication
(see 
<A HREF="manual-8.html#gkauth">[Gatekeeper::Auth]</A>).</P>

<P>All CDRs are also sent to the status port and can be used by external applications.</P>
<P>
<DL>
<DT><B>Syntax:</B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
acctmod=actions

 &lt;acctmod> := FileAcct | RadAcct | SQLAcct | StatusAcct | SyslogAcct | CapacityControl | ...
 &lt;actions> := &lt;control>[;&lt;event>,&lt;event>,...]
 &lt;control> := optional | required | sufficient | alternative
 &lt;event>   := start | stop | connect | update | on | off
</PRE>
</CODE></BLOCKQUOTE>
</P>
</DL>

The event list tells the gatekeeper, which events should trigger logging
with the given accounting module (if an event type is supported by the module):
<UL>
<LI><CODE>start</CODE> - a call has been started and a Setup message has been received (only available in routed mode),</LI>
<LI><CODE>connect</CODE> - a call has been connected (only available in routed mode),</LI>
<LI><CODE>update</CODE> - a call is active and the periodic update is performed
to reflect the new call duration. Frequency of such updates is determined
by <B>AcctUpdateInterval</B> variable from 
<A HREF="manual-12.html#calltable">[CallTable]</A>
section,</LI>
<LI><CODE>stop</CODE> - a call has been disconnected (removed from the GK call table),</LI>
<LI><CODE>on</CODE> - the gatekeeper has been started,</LI>
<LI><CODE>off</CODE> - the gatekeeper has been shut down.</LI>
</UL>

An event logging by a module may results in one of the three result codes:
<B>ok</B>, <B>fail</B>, <B>next</B>.
<UL>
<LI><CODE>ok</CODE> - the event has been logged successfully by this module,</LI>
<LI><CODE>fail</CODE> - the module failed to log the event,</LI>
<LI><CODE>next</CODE> - the event has not been logged by this module, because the module
is not configured for/does not support this event type.</LI>
</UL>

Accounting modules can be stacked to log events by multiple modules or to create
failover setups. <B>control</B> flag for each module, along with result codes,
define what is the final status of the event processing by the whole module stack.
If the final result is <B>failure</B>, some special actions may take place. Currently,
if a call <B>start</B> event logging fails, the call is disconnected immediatelly.
The following <B>control</B> flags are recognized:
<UL>
<LI><CODE>required</CODE> - if the module fails to log an event, the final status
is set to failure and the event is passed down to any remaining
modules,</LI>
<LI><CODE>optional</CODE> - the module tries to log an event, but the final status
is not affected by success or failure (except when the module
is last on the list). The event is always passed down
to any remaining modules,</LI>
<LI><CODE>sufficient</CODE> - the module determines the final status. If an event
is logged successfully, no remaining modules are processed.
Otherwise the final status is set to failure and the event
is passed down to any remaining modules,</LI>
<LI><CODE>alternative</CODE> - if the module logs an event successfully, no remaining
modules are processed. Otherwise the final status is
not modified and the event is passed down to any remaining
modules.</LI>
</UL>
</P>
<P>Currently supported accounting modules:
<UL>
<LI><CODE>FileAcct</CODE>
<P>A plain CDR text file logger. It outputs status line like CDR lines to
a specified text file. This module supports only <B>stop</B> accounting event.
Configuration settings are read from 
<A HREF="#fileacct">[FileAcct]</A> section.</P>

</LI>
<LI><CODE>RadAcct</CODE>
<P>This module performs RADIUS accounting. It supports all event types
(start, stop, update, on, off).
See the section 
<A HREF="#radacct">[RadAcct]</A> for configuration details.</P>

</LI>
<LI><CODE>SQLAcct</CODE>
<P>This module performs direct SQL accounting. It supports (start, connect, stop, update)
event types. 
See the section 
<A HREF="#sqlacct">[SQLAcct]</A> for configuration details.</P>

</LI>
<LI><CODE>StatusAcct</CODE>
<P>This module logs all accounting events on the status port. It can be used to interface to external application in real-time. It supports (start, connect, stop, update)
event types. 
See the section 
<A HREF="#statusacct">[StatusAcct]</A> for configuration details.</P>

</LI>
<LI><CODE>SyslogAcct</CODE>
<P>This module logs all accounting events on the Unix syslog. It supports (start, connect, stop, update)
event types. 
See the section 
<A HREF="#syslogacct">[SyslogAcct]</A> for configuration details.</P>

</LI>
<LI><CODE>CapacityControl</CODE>
<P>This module performs inbound call volume logging, required for <CODE>CapacityControl</CODE>
authentication module to work correctly. See the section 
<A HREF="manual-8.html#capctrl">[CapacityControl]</A>
for details.</P>

</LI>
<LI><CODE>default</CODE>
<P>This is a special pseudo module - it is used to set the final status
if preceding modules have not determined it. The format is as follows:
<DL>
<DT><B>Syntax:</B><DD><P>
<BLOCKQUOTE><CODE>
<PRE>
 default=&lt;status>[;&lt;event>,&lt;event>,...]
 &lt;status> := accept | fail
 &lt;event>  := start | stop | update | on | off
</PRE>
</CODE></BLOCKQUOTE>
</P>
</DL>
</P>

</LI>
</UL>
</P>
<P>The sample configuration #1 (try to log call start/stop with RADIUS server,
and always write a CDR to a text file):
<DL>
<DT><B>Example:</B><DD><P><CODE>RadAcct=optional;start,stop</CODE><BR>
<CODE>FileAcct=required</CODE><BR></P>
</DL>
</P>
<P>The sample configuration #2 (try to log call start/stop with RADIUS server,
if it fails use a CDR log file):
<DL>
<DT><B>Example:</B><DD><P><CODE>RadAcct=alternative;start,stop</CODE><BR>
<CODE>FileAcct=sufficient;stop</CODE><BR>
<CODE>default=accept</CODE><BR></P>
</DL>

The <B>default</B> rule is required here to prevent calls from being rejected
because of RadAcct start event logging failure. If RadAcct returns <B>fail</B>
return code, it is passed down to FileAcct module. FileAcct module does not
support <B>start</B> events, so it returns <B>next</B> return code. If there were
no the <B>default</B> rule, the final status would be failure, because no module
has been able to log the event.</P>
<P>The sample configuration #3 (always log call start and stop events with RADIUS
server, if it fails for call stop event, use a CDR file to store call info):
<DL>
<DT><B>Example:</B><DD><P><CODE>RadAcct=alternative;start,stop</CODE><BR>
<CODE>FileAcct=sufficient;stop</CODE><BR>
<CODE>default=fail;start</CODE><BR></P>
</DL>

The <B>default</B> rule is optional here. If RadAcct returns <B>fail</B>
return code for <B>start</B> event, the code is passed down to FileAcct module.
FileAcct module does not support <B>start</B> events, so it returns <B>next</B>
return code. The <B>default</B> rule ensures, that the call is disconnected
if call start event could not has been logged with RadAcct. But we want
to store a CDR in a text file in case the RADIUS server is down when the call
disconnects, so we can fetch call duration into a billing system later.</P>

<H2><A NAME="fileacct"></A> <A NAME="ss9.2">9.2</A> <A HREF="manual.html#toc9.2">Section [FileAcct]</A>
</H2>

<P>This accounting module writes CDR lines to a specified text file. The CDR
format can be a standard one (the same as displayed by the status interface)
or a customized one (using parametrized query string).</P>
<P>
<UL>
<LI><CODE>DetailFile=FULL_PATH_AND_FILENAME</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>A full path to the CDR plain text file. If a file with the given name already 
exists, new CDRs will be appended at the end of the file.</P>

</LI>
<LI><CODE>StandardCDRFormat=0</CODE><BR>
Default: <CODE>1</CODE><BR>
<P>Use a CDR format compatible with the status interface CDR format (<CODE>1</CODE>)
or build a custom CDR strings from the <B>CDRString</B> parametrized string.</P>

</LI>
<LI><CODE>CDRString=%s|%g|%u|%{Calling-Station-Id}|%{Called-Station-Id}|%d|%c</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>If <B>StandardCDRFormat</B> is disabled (0) or not specified at all, 
this parametrized string instructs the gatekeeper how to build a custom
CDRs. Parameters are specified using <CODE>%</CODE> character and can be one letter
(like <CODE>%n</CODE>) or longer (like <CODE>%{CallId}</CODE>). Any remaining characters that
are not parameter names are simply copied to a final CDR string. The following
parameters are recognized:
<UL>
<LI><CODE>%g</CODE> - gatekeeper name</LI>
<LI><CODE>%n</CODE> - call number (not unique after gatekeeper restart)</LI>
<LI><CODE>%d</CODE> - call duration (seconds)</LI>
<LI><CODE>%t</CODE> - total call duration (from Setup to Release Complete)</LI>
<LI><CODE>%c</CODE> - Q.931 disconnect cause (decimal integer)</LI>
<LI><CODE>%r</CODE> - who disconnected the call (-1 - unknown, 0 - the gatekeeper, 1 - the caller, 2 - the callee)</LI>
<LI><CODE>%p</CODE> - PDD (Post Dial Delay) in seconds</LI>
<LI><CODE>%s</CODE> - unique (for this gatekeeper) session identifier (Acct-Session-Id)</LI>
<LI><CODE>%u</CODE> - H.323 ID of the calling party</LI>
<LI><CODE>%{gkip}</CODE> - IP address of the gatekeeper</LI>
<LI><CODE>%{CallId}</CODE> - H.323 call identifier (16 hex 8-bit digits)</LI>
<LI><CODE>%{ConfId}</CODE> - H.323 conference identifier (16 hex 8-bit digits)</LI>
<LI><CODE>%{setup-time}</CODE> - timestamp string for Q.931 Setup message</LI>
<LI><CODE>%{alerting-time}</CODE> - timestamp string for Q.931 Alerting message</LI>
<LI><CODE>%{connect-time}</CODE> - timestamp string for a call connected event</LI>
<LI><CODE>%{disconnect-time}</CODE> - timestamp string for a call disconnect event</LI>
<LI><CODE>%{ring-time}</CODE> - time a remote phone was ringing for (from Alerting till Connect or Release Complete)</LI>
<LI><CODE>%{caller-ip}</CODE> - signaling IP address of the caller</LI>
<LI><CODE>%{caller-port}</CODE> - signaling port of the caller</LI>
<LI><CODE>%{callee-ip}</CODE> - signaling IP address of the called party</LI>
<LI><CODE>%{callee-port}</CODE> - signaling port of the called party</LI>
<LI><CODE>%{src-info}</CODE> - a colon separated list of source aliases</LI>
<LI><CODE>%{dest-info}</CODE> - a colon separated list of destination aliases</LI>
<LI><CODE>%{Calling-Station-Id}</CODE> - calling party number</LI>
<LI><CODE>%{Called-Station-Id}</CODE> - called party number (rewritten)</LI>
<LI><CODE>%{Dialed-Number}</CODE> - dialed number (as received from the calling party)</LI>
<LI><CODE>%{caller-epid}</CODE> - endpoint identifier of the calling party</LI>
<LI><CODE>%{callee-epid}</CODE> - endpoint identifier of the called party</LI>
<LI><CODE>%{call-attempts}</CODE> - number of attempts to establish the calls (with failover this can be > 1)</LI>
<LI><CODE>%{last-cdr}</CODE> - is this the last CDR for this call ? (0 / 1) only when using failover this can be 0</LI>
<LI><CODE>%{media-oip}</CODE> - caller's RTP media IP (only for H.245 routed/tunneled calls)</LI>
<LI><CODE>%{codec}</CODE> - audio codec used during the call (only for H.245 routed/tunneled calls)</LI>
</UL>
<BR></P>

</LI>
<LI><CODE>TimestampFormat=Cisco</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Format of timestamp strings printed in CDR strings. If this setting
is not specified, a global one from the main gatekeeper section is applied.</P>

</LI>
<LI><CODE>Rotate=hourly | daily | weekly | monthly | L... | S...</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>If set, the CDR file will be rotated based on this setting. Hourly rotation
enables rotation once per hour, daily - once per day, weekly - once per week
and monthly - once per month. An exact rotation moment is determined by a combination
of RotateDay and RotateTime. During rotation, an existing file is renamed 
to CURRENT_FILENAME.YYYYMMDD-HHMMSS, where YYYYMMDD-HHMMSS is replaced with 
the current timestamp, and new CDRs are logged to an empty file.<BR>
In addition, rotation per number of CDRs written (L...) and per file size (S...)
is supported. The <CODE>L</CODE> prefix specifies a number of CDR lines written,
the <CODE>S</CODE> prefix specifies CDR file size. <CODE>k</CODE> and <CODE>m</CODE> suffixes can
be used to specify thousands (kilobytes) and millions (megabytes). 
See the examples for more details.</P>
<P>
<DL>
<DT><B>Example 1 - no rotation:</B><DD><P><CODE>[FileAcct]</CODE><BR>
<CODE>DetailFile=/var/log/gk/cdr.log</CODE><BR></P>
</DL>
</P>
<P>
<DL>
<DT><B>Example 2 - rotate every hour (00:45, 01:45, ..., 23:45):</B><DD><P><CODE>[FileAcct]</CODE><BR>
<CODE>DetailFile=/var/log/gk/cdr.log</CODE><BR>
<CODE>Rotate=hourly</CODE><BR>
<CODE>RotateTime=45</CODE><BR></P>
</DL>
</P>
<P>
<DL>
<DT><B>Example 3 - rotate every day at 23:00 (11PM):</B><DD><P><CODE>[FileAcct]</CODE><BR>
<CODE>DetailFile=/var/log/gk/cdr.log</CODE><BR>
<CODE>Rotate=daily</CODE><BR>
<CODE>RotateTime=23:00</CODE><BR></P>
</DL>
</P>
<P>
<DL>
<DT><B>Example 4 - rotate every Sunday at 00:59:</B><DD><P><CODE>[FileAcct]</CODE><BR>
<CODE>DetailFile=/var/log/gk/cdr.log</CODE><BR>
<CODE>Rotate=weekly</CODE><BR>
<CODE>RotateDay=Sun</CODE><BR>
<CODE>RotateTime=00:59</CODE><BR></P>
</DL>
</P>
<P>
<DL>
<DT><B>Example 5 - rotate on the last day of each month:</B><DD><P><CODE>[FileAcct]</CODE><BR>
<CODE>DetailFile=/var/log/gk/cdr.log</CODE><BR>
<CODE>Rotate=monthly</CODE><BR>
<CODE>RotateDay=31</CODE><BR>
<CODE>RotateTime=23:00</CODE><BR></P>
</DL>
</P>
<P>
<DL>
<DT><B>Example 6 - rotate per every 10000 CDRs:</B><DD><P><CODE>[FileAcct]</CODE><BR>
<CODE>DetailFile=/var/log/gk/cdr.log</CODE><BR>
<CODE>Rotate=L10000</CODE><BR></P>
</DL>
</P>
<P>
<DL>
<DT><B>Example 7 - rotate per every 10 kilobytes:</B><DD><P><CODE>[FileAcct]</CODE><BR>
<CODE>DetailFile=/var/log/gk/cdr.log</CODE><BR>
<CODE>Rotate=S10k</CODE><BR></P>
</DL>
</P>

</LI>
</UL>
</P>

<H2><A NAME="radacct"></A> <A NAME="ss9.3">9.3</A> <A HREF="manual.html#toc9.3">Section [RadAcct]</A>
</H2>

<P>This accounting module sends accounting data to a RADIUS server. Module
configuration is almost the same as for RADIUS authenticators (see
<A HREF="manual-8.html#radauth">[RadAuth]</A> and 
<A HREF="manual-8.html#radaliasauth">[RadAliasAuth]</A>
for more details on the parameters).</P>
<P>
<UL>
<LI><CODE>Servers=SERVER1[:AUTH_PORT:ACCT_PORT[:SECRET]];SERVER2[:AUTH_PORT:ACCT_PORT[:SECRET]];...</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>RADIUS servers to send accounting data to. If no port information is given,
port number from <CODE>DefaultAcctPort</CODE> is be used. If no secret is set, 
the default shared secret from <CODE>SharedSecret</CODE> is used. Server names could 
be either IP addresses or DNS names.</P>
<P>
<DL>
<DT><B>Sample <CODE>Servers</CODE> lines:</B><DD><P><CODE>Servers=192.168.1.1</CODE><BR>
<CODE>Servers=192.168.1.1:1645:1646</CODE><BR>
<CODE>Servers=192.168.1.1:1645:1646:secret1</CODE><BR>
<CODE>Servers=radius1.mycompany.com:1812:1813</CODE><BR>
<CODE>Servers=radius1.mycompany.com;radius2.mycompany.com</CODE><BR>
<CODE>Servers=radius1.mycompany.com:1812:1813:secret1;radius2.mycompany.com:1812:1813:secret2</CODE><BR></P>
</DL>
</P>

</LI>
<LI><CODE>LocalInterface=IP_OR_FQDN</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Particular local network interface that RADIUS client should
use in order to communicate with RADIUS servers.</P>

</LI>
<LI><CODE>RadiusPortRange=10000-11000</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>By default (if this option is not set) RADIUS client
allocates ports dynamically as specified by the operating system.
If you want to restrict RADIUS client to use ports from
a particular range only - set this parameter.</P>

</LI>
<LI><CODE>DefaultAcctPort=PORT_NO</CODE><BR>
Default: <CODE>1813</CODE><BR>
<P>Default port number to be used for RADIUS accounting requests,
if not overridden by <CODE>Servers</CODE> attribute.</P>

</LI>
<LI><CODE>SharedSecret=SECRET</CODE><BR>
Default: <CODE>N/A (empty string)</CODE><BR>
<P>A secret used to authenticate this GnuGk (NAS client) to RADIUS
server. It should be a cryptographically strong password. This is the default
value used, if no server-specific secret is set in the <CODE>Servers</CODE>.
If <CODE>EncryptAllPasswords</CODE> is enabled, or a <CODE>KeyFilled</CODE> variable is defined
in this section, the password is in encrypted form and should be created using
the <CODE>addpasswd</CODE> utility.</P>

</LI>
<LI><CODE>RequestTimeout=TIMEOUT_MS</CODE><BR>
Default: <CODE>2000</CODE> (milliseconds)<BR>
<P>Timeout (milliseconds) for RADIUS server response to a request
sent by GnuGk. If no response is received within this time period,
next RADIUS server is queried.</P>

</LI>
<LI><CODE>IdCacheTimeout=TIMEOUT_MS</CODE><BR>
Default: <CODE>9000</CODE> (milliseconds)<BR>
<P>Timeout (milliseconds) for RADIUS request 8-bit identifiers to be
unique.</P>

</LI>
<LI><CODE>SocketDeleteTimeout=TIMEOUT_MS</CODE><BR>
Default: <CODE>60000</CODE> (milliseconds) - 60 s<BR>
<P>Timeout for unused RADIUS sockets to be closed.</P>

</LI>
<LI><CODE>RequestRetransmissions=NUMBER</CODE><BR>
Default: <CODE>2</CODE><BR>
<P>How many times a single RADIUS request is transmitted to every
configured RADIUS server (if no response is received).</P>

</LI>
<LI><CODE>RoundRobinServers=BOOLEAN</CODE><BR>
Default: <CODE>1</CODE><BR>
<P>RADIUS requests retransmission method.</P>

</LI>
<LI><CODE>AppendCiscoAttributes=BOOLEAN</CODE><BR>
Default: <CODE>0</CODE><BR>
<P>If set, Cisco Vendor Specific RADIUS attributes are included
in RADIUS requests (h323-conf-id,h323-call-origin,h323-call-type).</P>

</LI>
<LI><CODE>TimestampFormat=ISO8601</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Format of timestamp strings sent in RADIUS attributes. If this setting
is not specified, a global one from the main gatekeeper section is applied.</P>

</LI>
<LI><CODE>UseDialedNumber=BOOLEAN</CODE><BR>
Default: <CODE>0</CODE><BR>
<P>Select Called-Station-Id number type between the original one (as dialed
by the user) - <CODE>UseDialedNumber=1</CODE> - and the rewritten one - <CODE>UseDialedNumber=0</CODE>.</P>

</LI>
</UL>
</P>

<H2><A NAME="sqlacct"></A> <A NAME="ss9.4">9.4</A> <A HREF="manual.html#toc9.4">Section [SQLAcct]</A>
</H2>

<P>This accounting module stores accounting information directly
to an SQL database. Many configuration settings are common with
other SQL modules.</P>
<P>
<UL>
<LI><CODE>Driver=MySQL | PostgreSQL | Firebird</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>SQL database driver to use. Currently, <CODE>MySQL</CODE>, <CODE>PostgreSQL</CODE> and <CODE>Firebird</CODE> drivers
are implemented.</P>

</LI>
<LI><CODE>Host=DNS[:PORT] | IP[:PORT]</CODE><BR>
Default: <CODE>localhost</CODE><BR>
<P>SQL server host address. Can be in the form of <CODE>DNS[:PORT]</CODE> or <CODE>IP[:PORT]</CODE>.
Like <CODE>sql.mycompany.com</CODE> or <CODE>sql.mycompany.com:3306</CODE> or <CODE>192.168.3.100</CODE>.</P>

</LI>
<LI><CODE>Database=billing</CODE><BR>
Default: <CODE>billing</CODE><BR>
<P>The database name to connect to.</P>

</LI>
<LI><CODE>Username=gnugk</CODE><BR>
<P>The username used to connect to the database.</P>

</LI>
<LI><CODE>Password=secret</CODE><BR>
<P>The password used to connect to the database.
If the password is not specified, a database connection attempt 
without any password will be made.
If <CODE>EncryptAllPasswords</CODE> is enabled, or a <CODE>KeyFilled</CODE> variable is defined
in this section, the password is in an encrypted form and should be created 
using the <CODE>addpasswd</CODE> utility.</P>

</LI>
<LI><CODE>StartQuery=INSERT ...</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Defines SQL query used to insert a new call record to the database. The query
is parametrized - that means parameter replacement is made before each query
is executed. Parameter placeholders are denoted by % character and can be one
letter (like %u) or whole strings (like %{src-info}). Specify %% to embed 
a percent character inside the query string (like <B>%%</B>).
For <CODE>SQLAcct</CODE> the following parameters are defined:
<UL>
<LI><CODE>%g</CODE> - gatekeeper name</LI>
<LI><CODE>%n</CODE> - call number (not unique after gatekeeper restart)</LI>
<LI><CODE>%d</CODE> - call duration (seconds)</LI>
<LI><CODE>%t</CODE> - total call duration (from Setup to Release Complete)</LI>
<LI><CODE>%c</CODE> - Q.931 disconnect cause (<B>hexadecimal</B> integer)</LI>
<LI><CODE>%r</CODE> - who disconnected the call (-1 - unknown, 0 - the gatekeeper, 1 - the caller, 2 - the callee)</LI>
<LI><CODE>%p</CODE> - PDD (Post Dial Delay) in seconds</LI>
<LI><CODE>%s</CODE> - unique (for this gatekeeper) call (Acct-Session-Id)</LI>
<LI><CODE>%u</CODE> - H.323 ID of the calling party</LI>
<LI><CODE>%{gkip}</CODE> - IP address of the gatekeeper</LI>
<LI><CODE>%{CallId}</CODE> - H.323 call identifier (16 hex 8-bit digits)</LI>
<LI><CODE>%{ConfId}</CODE> - H.323 conference identifier (16 hex 8-bit digits)</LI>
<LI><CODE>%{setup-time}</CODE> - timestamp string for Q.931 Setup message</LI>
<LI><CODE>%{alerting-time}</CODE> - timestamp string for Q.931 Alerting message</LI>
<LI><CODE>%{connect-time}</CODE> - timestamp string for a call connected event</LI>
<LI><CODE>%{disconnect-time}</CODE> - timestamp string for a call disconnect event</LI>
<LI><CODE>%{ring-time}</CODE> - time a remote phone was ringing for (from Alerting till Connect or Release Complete)</LI>
<LI><CODE>%{caller-ip}</CODE> - signaling IP address of the caller</LI>
<LI><CODE>%{caller-port}</CODE> - signaling port of the caller</LI>
<LI><CODE>%{callee-ip}</CODE> - signaling IP address of the called party</LI>
<LI><CODE>%{callee-port}</CODE> - signaling port of the called party</LI>
<LI><CODE>%{src-info}</CODE> - a colon separated list of source aliases</LI>
<LI><CODE>%{dest-info}</CODE> - a colon separated list of destination aliases</LI>
<LI><CODE>%{Calling-Station-Id}</CODE> - calling party number</LI>
<LI><CODE>%{Called-Station-Id}</CODE> - called party number (rewritten Dialed-Number)</LI>
<LI><CODE>%{Dialed-Number}</CODE> - dialed number (as received from the calling party)</LI>
<LI><CODE>%{caller-epid}</CODE> - endpoint identifier of the calling party</LI>
<LI><CODE>%{callee-epid}</CODE> - endpoint identifier of the called party</LI>
<LI><CODE>%{call-attempts}</CODE> - number of attempts to establish the calls (with failover this can be > 1)</LI>
<LI><CODE>%{last-cdr}</CODE> - is this the last CDR for this call ? (0 / 1) only when using failover this can be 0</LI>
<LI><CODE>%{media-oip}</CODE> - caller's RTP media IP (only for H.245 routed/tunneled calls)</LI>
<LI><CODE>%{codec}</CODE> - audio codec used during the call (only for H.245 routed/tunneled calls)</LI>
</UL>
</P>
<P>Sample query string:
<BLOCKQUOTE><CODE>
<PRE>
INSERT INTO call (gkname, sessid, username, calling, called) 
        VALUES ('%g', '%s', '%u', '%{Calling-Station-Id}', '%{Called-Station-Id}')
</PRE>
</CODE></BLOCKQUOTE>
</P>

</LI>
<LI><CODE>StartQueryAlt=INSERT ...</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Defines SQL query used to insert a new call record to the database in case
the <CODE>StartQuery</CODE> failed for some reason (the call already exists, for example).
The syntax and parameters are the same as for <CODE>StartQuery</CODE>.</P>

</LI>
<LI><CODE>UpdateQuery=UPDATE ...</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Defines SQL query used to update call record in the database with the current 
call state. The syntax and parameters are the same as for <CODE>StartQuery</CODE>.</P>
<P>Sample query string:
<BLOCKQUOTE><CODE>
<PRE>
UPDATE call SET duration = %d WHERE gkname = '%g' AND sessid = '%s'
</PRE>
</CODE></BLOCKQUOTE>
</P>

</LI>
<LI><CODE>StopQuery=UPDATE ...</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Defines SQL query used to update call record in the database when the call
is finished (disconnected). The syntax and parameters are the same 
as for <CODE>StartQuery</CODE>.</P>
<P>Sample query string:
<BLOCKQUOTE><CODE>
<PRE>
UPDATE call SET duration = %d, dtime = '%{disconnect-time}' WHERE gkname = '%g' AND sessid = '%s'
</PRE>
</CODE></BLOCKQUOTE>
</P>

</LI>
<LI><CODE>StopQueryAlt=INSERT ...</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Defines SQL query used to update call record in the database when the call
is finished (disconnected) in case the regular <CODE>StopQuery</CODE> failed (because
the call record does not yet exist, for example). The syntax and parameters 
are the same as for <CODE>StartQuery</CODE>.</P>
<P>Sample query string:
<BLOCKQUOTE><CODE>
<PRE>
INSERT INTO call (gkname, sessid, username, calling, called, duration) 
        VALUES ('%g', '%s', '%u', '%{Calling-Station-Id}', '%{Called-Station-Id}', %d)
</PRE>
</CODE></BLOCKQUOTE>
</P>

</LI>
<LI><CODE>TimestampFormat=MySQL</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Format of timestamp strings used in queries. If this setting
is not specified, a global one from the main gatekeeper section is used.</P>

</LI>
<LI><CODE>MinPoolSize=5</CODE><BR>
Default: <CODE>1</CODE><BR>
<P>Number of concurrent SQL connections in the pool. The first available connection
in the pool is used to store accounting data.</P>

</LI>
</UL>
</P>

<H3><A NAME="mysqlscheme"></A> A Sample MySQL Schema</H3>

<P>The SQLAcct module is designed to adapt to whatever database structure you already have. You can define all queries so they fit your existing tables.
But here is an example what those tables might look like in MySQL and you can use these as a starting point.</P>
<P>Create a new database; here we use the name 'GNUGK':</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
create database GNUGK;
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>Then create a table in this database to store you accounting data; we call the table 'CDR'.</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
create table GNUGK.CDR (
        gatekeeper_name varchar(255),
        call_number int zerofill,
        call_duration mediumint unsigned zerofill,
                index duration_idx (call_duration),
        disconnect_cause smallint unsigned zerofill,
                index dcc_idx (disconnect_cause),
        acct_session_id varchar(255),
        h323_id varchar(255),
        gkip varchar(15),
        CallId varchar(255),
        ConfID varchar(255),
        setup_time datetime,
        connect_time datetime,
        disconnect_time datetime,
        caller_ip varchar(15),
                index srcip_idx (caller_ip),
        caller_port smallint unsigned zerofill,
        callee_ip varchar(15),
                index destip_idx (callee_ip),
        callee_port smallint unsigned zerofill,
        src_info varchar(255),
        dest_info varchar(255),
        Calling_Station_Id varchar(255),
        Called_Station_Id varchar(255),
                index dialednumber_idx (Called_Station_Id (20)),
        Dialed_Number varchar(255)
);
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>Then you need to create a username for accessing the data.</P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
GRANT delete,insert,select,update ON GNUGK.* TO 'YourDesiredUsername'@'localhost' IDENTIFIED BY 'APassword';
</PRE>
</CODE></BLOCKQUOTE>
</P>
<P>With this command you will permit accessing the data from only the local server. If you need to access these data from any other computer then you have to set the proper security options.</P>
<P>Then you can add the following settings into your gnugk.ini file to insert and update the history of the calls into your database. </P>
<P>
<BLOCKQUOTE><CODE>
<PRE>
[Gatekeeper::Acct]
SQLAcct=optional;start,stop,update
FileAcct=sufficient;stop

[FileAcct]
DetailFile=Add your desire path here something like /var/log/cdr.log
StandardCDRFormat=0
CDRString=%g|%n|%d|%c|%s|%u|%{gkip}|%{CallId}|%{ConfId}|%{setup-time}|%{connect-time}|%{disconnect-time}|%{caller-ip}|%{caller-port}|%{callee-ip}|%{callee-port}|%{src-info}|%{dest-info}|%{Calling-Station-Id}|%{Called-Station-Id}|%{Dialed-Number}
Rotate=daily
RotateTime=23:59

[SQLAcct]
Driver=MySQL
Database=GNUGK
Username=YourDesiredUsername
Password=APassword
StartQuery= insert into CDR (gatekeeper_name, call_number, call_duration, disconnect_cause, acct_session_id, h323_id, gkip, CallId, ConfId, setup_time, connect_time, disconnect_time, caller_ip, caller_port, callee_ip, callee_port, src_info, dest_info, Calling_Station_Id, Called_Station_Id, Dialed_Number) values ('%g', '%n', %d, %c, '%s', '%u', '%{gkip}', '%{CallId}', '%{ConfId}', '%{setup-time}', '%{connect-time}', '%{disconnect-time}', '%{caller-ip}', '%{caller-port}', '%{callee-ip}', '%{callee-port}', '%{src-info}', '%{dest-info}', '%{Calling-Station-Id}', '%{Called-Station-Id}', '%{Dialed-Number}')

StartQueryAlt= insert into CDR (gatekeeper_name, call_number, call_duration, disconnect_cause, acct_session_id, h323_id, gkip, CallId, ConfID, setup_time, connect_time, disconnect_time, caller_ip, caller_port, callee_ip, callee_port, src_info, dest_info, Calling_Station_Id, Called_Station_Id, Dialed_Number) values ('%g', '%n', %d, %c, '%s', '%u', '%{gkip}', '%{CallId}', '%{ConfID}', '%{setup-time}', '%{connect-time}', '%{disconnect-time}', '%{caller-ip}', '%{caller-port}', '%{callee-ip}', '%{callee-port}', '%{src-info}', '%{dest-info}', '%{Calling-Station-Id}', '%{Called-Station-Id}', '%{Dialed-Number}')

UpdateQuery= update CDR set call_duration=%d where gatekeeper_name='%g' and acct_session_id='%s'

StopQuery= update CDR set call_duration=%d, disconnect_cause=%c, disconnect_time='%{disconnect-time}' where gatekeeper_name='%g' and acct_session_id='%s'

StopQueryAlt= insert into CDR (gatekeeper_name, call_number, call_duration, disconnect_cause, acct_session_id, h323_id, gkip, CallId, ConfID, setup_time, connect_time, disconnect_time, caller_ip, caller_port, callee_ip, callee_port, src_info, dest_info, Calling_Station_Id, Called_Station_Id, Dialed_Number) values ('%g STOP Alt', '%n', %d, %c, '%s', '%u', '%{gkip}', '%{CallId}', '%{ConfID}', '%{setup-time}', '%{connect-time}', '%{disconnect-time}', '%{caller-ip}', '%{caller-port}', '%{callee-ip}', '%{callee-port}', '%{src-info}', '%{dest-info}', '%{Calling-Station-Id}', '%{Called-Station-Id}', '%{Dialed-Number}')

TimestampFormat=MySQL
</PRE>
</CODE></BLOCKQUOTE>
</P>


<H2><A NAME="statusacct"></A> <A NAME="ss9.5">9.5</A> <A HREF="manual.html#toc9.5">Section [StatusAcct]</A>
</H2>

<P>This accounting module sends all accounting information to the
status port where it can be used to interface to
external systems in real time.</P>
<P>
<UL>
<LI><CODE>StartEvent=CALL|Start|%{CallId}</CODE><BR>
Default: <CODE>CALL|Start|%{caller-ip}:%{caller-port}|%{callee-ip}:%{callee-port}|%{CallId}</CODE><BR>
<P>Defines the event to display for a new call. The string is parametrized
with the same variables as the other accounting modules (See 
<A HREF="#sqlacct">[SQLAacct]</A>).</P>

</LI>
<LI><CODE>StopEvent=CALL|Stop|%{CallId}</CODE><BR>
Default: <CODE>CALL|Stop|%{caller-ip}:%{caller-port}|%{callee-ip}:%{callee-port}|%{CallId}</CODE><BR>
<P>Defines the event when a call is finished (disconnected). The syntax and parameters are the same as for <CODE>StartEvent</CODE>. This event is equivalent to the old status port CDR event, but more flexible.</P>

</LI>
<LI><CODE>UpdateEvent=CALL|Update|%{CallId}</CODE><BR>
Default: <CODE>CALL|Update|%{caller-ip}:%{caller-port}|%{callee-ip}:%{callee-port}|%{CallId}</CODE><BR>
<P>Defines event used to update the current call state. The syntax and parameters are the same as for <CODE>StartEvent</CODE>.</P>

</LI>
<LI><CODE>ConnectEvent=CALL|Connect|%{CallId}</CODE><BR>
Default: <CODE>CALL|Connect|%{caller-ip}:%{caller-port}|%{callee-ip}:%{callee-port}|%{CallId}</CODE><BR>
<P>Defines the event when a call is connected. The syntax and parameters are the same as for <CODE>StartEvent</CODE>.</P>

</LI>
<LI><CODE>TimestampFormat=MySQL</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Format of timestamp strings used in events. If this setting
is not specified, a global one from the main gatekeeper section is used.</P>

</LI>
</UL>
</P>

<H2><A NAME="syslogacct"></A> <A NAME="ss9.6">9.6</A> <A HREF="manual.html#toc9.6">Section [SyslogAcct]</A>
</H2>

<P>This accounting module sends accounting information to the
Unix syslog and is not available on Windows. The local syslog daemon will then route the messages according to the it's configuration (generally /etc/syslog.conf).</P>
<P>
<UL>
<LI><CODE>SyslogFacility=LOG_LOCAL1</CODE><BR>
Default: <CODE>LOG_USER</CODE><BR>
<P>Set the syslog facility to one of LOG_USER, LOG_DAEMON, LOG_AUTH, LOG_LOCAL0, LOG_LOCAL1, LOG_LOCAL2, LOG_LOCAL3, LOG_LOCAL4, LOG_LOCAL5, LOG_LOCAL6, LOG_LOCAL7.</P>

</LI>
<LI><CODE>SyslogLevel=LOG_NOTICE</CODE><BR>
Default: <CODE>LOG_INFO</CODE><BR>
<P>Set the syslog level to on one LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, LOG_DEBUG.</P>

</LI>
<LI><CODE>StartEvent=CALL|Start|%{CallId}</CODE><BR>
Default: <CODE>CALL|Start|%{caller-ip}:%{caller-port}|%{callee-ip}:%{callee-port}|%{CallId}</CODE><BR>
<P>Defines the event to display for a new call. The string is parametrized
with the same variables as the other accounting modules (See 
<A HREF="#sqlacct">[SQLAacct]</A>).</P>

</LI>
<LI><CODE>StopEvent=CALL|Stop|%{CallId}</CODE><BR>
Default: <CODE>CALL|Stop|%{caller-ip}:%{caller-port}|%{callee-ip}:%{callee-port}|%{CallId}</CODE><BR>
<P>Defines the event when a call is finished (disconnected). The syntax and parameters are the same as for <CODE>StartEvent</CODE>. This event is equivalent to the old status port CDR event, but more flexible.</P>

</LI>
<LI><CODE>UpdateEvent=CALL|Update|%{CallId}</CODE><BR>
Default: <CODE>CALL|Update|%{caller-ip}:%{caller-port}|%{callee-ip}:%{callee-port}|%{CallId}</CODE><BR>
<P>Defines event used to update the current call state. The syntax and parameters are the same as for <CODE>StartEvent</CODE>.</P>

</LI>
<LI><CODE>ConnectEvent=CALL|Connect|%{CallId}</CODE><BR>
Default: <CODE>CALL|Connect|%{caller-ip}:%{caller-port}|%{callee-ip}:%{callee-port}|%{CallId}</CODE><BR>
<P>Defines the event when a call is connected. The syntax and parameters are the same as for <CODE>StartEvent</CODE>.</P>

</LI>
<LI><CODE>TimestampFormat=MySQL</CODE><BR>
Default: <CODE>N/A</CODE><BR>
<P>Format of timestamp strings used in events. If this setting
is not specified, a global one from the main gatekeeper section is used.</P>

</LI>
</UL>

</P>
<HR>
<A HREF="manual-10.html">Next</A>
<A HREF="manual-8.html">Previous</A>
<A HREF="manual.html#toc9">Contents</A>
</BODY>
</HTML>