acc_log_request(comment)
acc_db_request(comment, table)
acc_rad_request(comment)
acc_diam_request(comment)
acc module is used to report on transactions to syslog, SQL and RADIUS.
To report on a transaction using syslog, use "setflag" to mark a transaction you are interested in with a flag, load accounting module and set its "log_flag" to the same flag number. The acc module will then report on completed transaction to syslog. A typical usage of the module takes no acc-specific script command -- the functionality binds invisibly through transaction processing. Script writers just need to mark the transaction for accounting with proper setflag.
What is printed depends on module's "log_fmt" parameter. It's a string with characters specifying which parts of request should be printed:
c = Call-Id
d = To tag (Dst)
f = From
i = Inbound Request-URI
m = Method
o = Outbound Request-URI
r = fRom
s = Status
t = To
u = digest Username
p = username Part of inbound Request-URI
Note that:
A single INVITE may produce multiple accounting reports -- that's due to SIP forking feature
Subsequent ACKs and other requests do not hit the server and can't be accounted unless record-routing is enforced. The ACKs assert very little useful information anyway and reporting on INVITE's 200 makes most accounting scenarios happy.
There is no session accounting -- ser maintains no sessions. If one needs to correlate INVITEs with BYEs for example for purpose of billing, then it is better done in the entity which collects accounting information. Otherwise, SIP server would have to become sessions-stateful, which would very badly impact its scalability.
If a UA fails in middle of conversation, a proxy will never learn it. In general, a better practice is to account from an end-device (such as PSTN gateway), which best knows about call status (including media status and PSTN status in case of the gateway).
Support for SQL and RADIUS works analogously. You need to enable it by recompiling the module with properly set defines. Uncomment the SQL_ACC and RAD_ACC lines in modules/acc/Makefile. To compile SQL support, you need to have mysqlclient package on your system. To compile RADIUS support, you need to have radiusclient installed on your system (version 0.4.1 or higher is required) which is available from http://developer.berlios.de/projects/radiusclient-ng/. The radius client needs to be configured properly. To do so, use the template at etc/radiusclient.conf and make sure that module's radius_config parameter points to its location. In particular, accounting secret must match that one configured in server and proper dictionary is used (one is available at etc/sip_dictionary). Uses along with FreeRadius (http://www.freeradius.org/) and Radiator (http://www.open.com.au/radiator/) servers have been reported to us.
Both mysql and radius libraries must be dynamically linkable. You need to configure your OS so that SER, when started, will find them. Typically, you do so by manipulating LD_LIBRARY_PATH environment variable or configuring ld.so.
loadmodule "modules/acc/acc.so" modparam("acc", "log_level", 1) modparam("acc", "log_flag", 1) if (uri=~"sip:+49") /* calls to Germany */ { if (!proxy_authorize("iptel.org" /* realm */, "subscriber" /* table name */)) { proxy_challenge("iptel.org" /* realm */, "0" /* no qop */ ); break; } if (method=="INVITE" & !check_from()) { log("from!=digest\n"); sl_send_reply("403","Forbidden"); break; } setflag(1); /* set for accounting (the same value as in log_flag!) t_relay(); /* enter stateful mode now */ };
Along the static information defined via FMT-s, ACC modules allows dynamical selection of extra information to be logged. There are two classes of information that are accessible by extra accounting: data from SIP messages (as headers) and internal SER data (as AVPs).
Selection of extra information is done via xxx_extra parameters by specifying the names of additional headers or AVPs you want to log. The syntax of is:
xxx_extra = extra_definition (';'extra_definition)*
extra_definition = log_name '=' data_type'/'data['/'flags]
data_type = 'hdr' | 'avp'
data = header_name | ['s:']AVP_name | 'i:'AVP_id
flags = 'g'
Via log_name you define how/where the data will be logged. Its meaning depends of the accounting support which is used:
LOG accounting - log_name will be just printed along with the data in log_name=data format;
DB accounting - log_name will be the name of the DB column where the data will be stored. IMPORTANT: add in db acc table the columns corresponding to each extra data;
RADIUS accounting - log_name will be the AVP name used for packing the data into RADIUS message. The log_name will be translated to AVP number via the dictionary. IMPORTANT: add in RADIUS dictionary the log_name attribute.
DIAMETER accounting - log_name will be the AVP code used for packing the data into DIAMETER message. the AVP code is given directly as integer, since DIAMETER has no dictionary support yet. IMPORTANT: log_name must be a number.
Data can be an header name or an AVP name/ID - depending of the data_type. If header, the search for it into SIP messages will be optimized by converting at start-up the header name (string) into header type (integer) - this is not possible for all headers (only for the the most important); otherwise case insensitive string matching will be used.
The only defined flag is 'g' - global - which will force logging all values of the given header or AVP. Without this flag, only the first found value will be logged. IMPORTANT for DB logging, this flag is disabled from DB data structure constraints.
The module depends on the following modules (in the other words the listed modules must be loaded before this module):
tm -- Transaction Manager
a database module -- If compiled with database support.
Log level at which accounting messages are issued to syslog.
Default value is L_NOTICE.
Defines what parts of header fields will be printed to syslog, see "overview" for list of accepted values.
Default value is "miocfs".
Should be failed transactions (status>=300) accounted too ?
Default value is 0 (no).
Request flag which needs to be set to account a transaction.
Default value is 1.
Request flag which needs to be set to account missed calls.
Default value is 2.
Shall acc attempt to account e2e ACKs too ? Note that this is really only an attempt, as e2e ACKs may take a different path (unless RR enabled) and mismatch original INVITE (e2e ACKs are a separate transaction).
Default value is 1 (yes).
By default, CANCEL reporting is disabled -- most accounting applications are happy to see INVITE's cancellation status. Turn on if you explicitly want to account CANCEL transactions.
Default value is 0 (no).
This parameter is radius specific. Path to radius client configuration file, set the referred config file correctly and specify there address of server, shared secret (should equal that in /usr/local/etc/raddb/clients for freeRadius servers) and dictionary, see etc for an example of config file and dictionary.
Default value is "/usr/local/etc/radiusclient/radiusclient.conf".
Request flag which needs to be set to account a transaction -- RADIUS specific.
Default value is 1.
Request flag which needs to be set to account missed calls -- RADIUS specific.
Default value is 2.
SQL address -- database specific.
Default value is "mysql://ser:heslo@localhost/ser"
Request flag which needs to be set to account a transaction -- database specific.
Default value is 1.
Request flag which needs to be set to account missed calls -- database specific.
Default value is 2.
Request flag which needs to be set to account a transaction -- DIAMETER specific.
Default value is 1.
Request flag which needs to be set to account missed calls -- DIAMETER specific.
Default value is 2.
Hostname of the machine where the DIAMETER Client is running -- DIAMETER specific.
Default value is "localhost".
Port number where the Diameter Client is listening -- DIAMETER specific.
Default value is 3000.
Extra values to be logged into database - DB specific.
Default value is NULL.
Extra values to be logged via RADIUS - RADIUS specific.
Default value is NULL.
Extra values to be logged via DIAMETER - DIAMETER specific.
Default value is NULL.
acc_log_request(comment)
acc_request
reports on a request, for example,
it can be used to report on missed calls to off-line users who are replied 404. To
avoid multiple reports on UDP request retransmission, you would need to embed the
action in stateful processing.
Meaning of the parameters is as follows:
comment - Comment to be appended.
acc_db_request(comment, table)
Like acc_log_request
, acc_db_request
reports on a request. The report is sent
to database at "db_url", in the table referred to in the second action
parameter
Meaning of the parameters is as follows:
comment - Comment to be appended.
table - Database table to be used.
acc_rad_request(comment)
Like acc_log_request
,
acc_rad_request
reports on a request. It
reports to radius server as configured in "radius_config".
Meaning of the parameters is as follows:
comment - Comment to be appended.
acc_diam_request(comment)
Like acc_log_request
,
acc_diam_request
reports on a request. It
reports to Diameter server.
Meaning of the parameters is as follows:
comment - Comment to be appended.