Deployment Guide

482 | Reference ClearPass Guest 3.9 | Deployment Guide
If $to_time is specified, the interval considered is between $from_time and $to_time.
Returns the total session time for all matching accounting records in the time interval specified.
GetSessions()
GetSessions($criteria, $from_time, $to_time = null)
Calculate the number of sessions from accounting records in the database.
$criteria is the criteria on which to search for matching accounting records.
As well as the criteria specified, the time interval specified by $from_time and optionally $to_time is
also used to narrow the search.
If $to_time is not specified, $from_time is a “look back” time, that is, the time interval in seconds before
the current time.
If $to_time is specified, the interval considered is between $from_time and $to_time.
Returns the total number of sessions for matching accounting records in the time interval specified.
GetCallingStationTraffic()
GetCallingStationTraffic($from_time, $to_time = null, $in_out = null, $mac_format =
null)
Calculate sum of traffic counters in a time interval. Sessions are summed if they have the same Calling-
Station-Id attribute as that specified in the RADIUS Access-Request.
If no Calling-Station-Id attribute was included in the request, returns zero.
Because different NAS equipment can send differently-formatted MAC addresses in the Calling-Station-Id
attribute, the $mac_format argument may be specified. This should be a sprintf-style format string that
accepts 6 arguments (the octets of the MAC address). The default if not specified is the IEEE 802 standard
format, %02X-%02X-%02X-%02X-%02X-%02X – that is, uppercase hexadecimal with each octet
separated with a hyphen. This string matches what ClearPass Guest sees from the NAS.
The time interval specified by $from_time and optionally $to_time is also used to narrow the search.
If $to_time is not specified, $from_time is a “look back” time, that is, the time interval in seconds before
the current time.
If $to_time is specified, the interval considered is between $from_time and $to_time.
$in_out may be “in” to count only input octets, “out” to count only output octets, or any other value to
count both input and output octets towards the traffic total.
Examples:
Use the following as the condition expression for a RADIUS role attribute. Authorizes a user only if their
total traffic (in + out) in the past day does not exceed 10 MB. Note that the attribute with this condition
expression will never be included in the response!
return GetUserTraffic(86400) > 10485760 && AccessReject()
Like the above, but only considers output (that is, user downloads):
return GetUserTraffic(86400,'out') > 10485760 && AccessReject()
This is a multi-purpose function that has a very flexible query interface; for ease of use, consider using one of the
related functions GetCallingStationSessions(), GetIpAddressSessions(), GetUserActiveSessions(), or
GetUserSessions().