Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
mod_feature_capping.pm [2016-09-18 11:57] nkukardmod_feature_capping.pm [2017-02-03 09:22] (current) – [SMRadius-AutoTopup-$TYPE-Threshold] nkukard
Line 2: Line 2:
  
 Implements traffic or session time based capping defined using certain attributes that can be set at a group or user level. Implements traffic or session time based capping defined using certain attributes that can be set at a group or user level.
 +
 +====== Config File ======
 +
 +The following section is supported in the ''smradiusd.conf'' configuration file.
 +===== [mod_feature_capping] =====
 +
 +==== enable_mikrotik ====
 +
 +Enable Mikrotik specific attributes to allow better control of capping and traffic control by setting session limits.
 +<code>
 +enable_mikrotik=yes
 +</code>
 +
 +==== caveat_captrafzero ====
 +
 +<btn type="success" size="xs">Supported <badge>v1.0.x</badge></btn>
 +
 +Enable the captrafzero caveat. This will swap the meaning of 0 and undef on traffic capping limits. There was a logic error prior to v1.0.x.
 +<code>
 +caveat_captrafzero=yes
 +</code>
  
 ====== Attributes ====== ====== Attributes ======
  
-===== Limits (Capping) =====+===== Limits =====
  
 +Limits, also known as capping.
 ==== SMRadius-Capping-Traffic-Limit ==== ==== SMRadius-Capping-Traffic-Limit ====
  
 Defines a maximum traffic usage allowed. This value is in Mbyte. Defines a maximum traffic usage allowed. This value is in Mbyte.
  
-If unset, this value is taken as undefined which translates to 0, this means prepaid.+If unset, this value is unlimited.
  
-If this value is set to 0 it is taken as unlimitedor uncapped.+If this value is set to 0, topups must be added.
  
 <code> <code>
Line 23: Line 45:
 Defines a maximum session time allowed. This value is in minutes. Defines a maximum session time allowed. This value is in minutes.
  
-If unset, this value is taken as undefined which translates to 0, this means prepaid.+If unset, this value is unlimited.
  
-If this value is set to 0 it is taken as unlimitedor uncapped.+If this value is set to 0, topups must be added.
  
 <code> <code>
Line 31: Line 53:
 </code> </code>
  
-===== Manipulation of Usage (Multiplication) =====+===== Usage Manipulation =====
  
 +Usage manipulation can be used to multiple the current usage to determine limits on other clients.
 +
 +For instance a user with a 1G traffic limit, may have a multiplication factor of 2 on a LTE network which would result in him only being able to use 500M of traffic.
  
 ==== SMRadius-Config-Capping-Traffic-Multiplier ==== ==== SMRadius-Config-Capping-Traffic-Multiplier ====
Line 51: Line 76:
  
 ===== AutoTopups ===== ===== AutoTopups =====
 +
 +<btn type="success" size="xs">Supported <badge>v1.0.x</badge></btn>
  
 The same attributes are used for ''Traffic'' and ''Uptime'', just replace $TYPE below. The same attributes are used for ''Traffic'' and ''Uptime'', just replace $TYPE below.
  
 +Auto-topups are stored in the ''topups'' table...
 +<code>
 +               ID: 2078471
 +           UserID: 11391
 +        Timestamp: 2016-09-18 13:59:42
 +             Type: 5   <= The 'Type' is OR'd with the value 4
 +        ValidFrom: 2016-09-18 00:00:00
 +          ValidTo: 2016-10-01 00:00:00
 +            Value: 500
 +         Depleted: 0
 +SMAdminDepletedOn: NULL
 +</code>
 +
 +Type 1 is a Traffic topup.
 +
 +Type 2 is a Uptime topup.
 +
 +Type 4 is a Auto-topup.
 ==== SMRadius-AutoTopup-$TYPE-Enabled ==== ==== SMRadius-AutoTopup-$TYPE-Enabled ====
  
Line 88: Line 133:
 ==== SMRadius-AutoTopup-$TYPE-NotifyTemplate ==== ==== SMRadius-AutoTopup-$TYPE-NotifyTemplate ====
  
 +The template parsing is done using [[http://www.template-toolkit.org/|Template::Toolkit]].
  
 +Supported macro's include:
 +  * user.ID
 +  * user.username
 +  * usage.total
 +  * usage.limit
 +  * autotopup.amount
 +  * autotopup.limit
 +  * autotopup.added
 +  * autotopup.toAdd (if this is 0, it means additional auto-topups cannot be added)
 +  * autotopup.toAddAmount
  
 +Example below...
 +<code>
 +To: [% notify.target %]
 +From: Test ISP <isp\@example.com>
 +Subject: [Test ISP] Your account [% user.username %]
 +
 +[% IF autotopup.toAdd %]
 +Please note that you have [% usage.limit - usage.total %]Mbyte available on username [% user.username %]. We added another [% autotopup.toAdd %] automatic topup(s) totalling [% autotopup.toAddAmount %]Mbyte to your username. Your automatic topup usage is [% autotopup.added + autotopup.toAddAmount %]Mbyte of [% autotopup.limit ? autotopup.limit : '-no-limit-' %]Mbyte.
 +[% ELSE %]
 +We cannot add another [% autotopup.amount %]Mbyte to your username as you have reached your automatic topup limit of [% autotopup.limit %]Mbyte. Your total usage is [% usage.total %]Mbyte.
 +[% END %]
 +
 +Regards
 +Your Test ISP
 +Support: +1 555 555 555
 +</code>
 +
 +==== SMRadius-AutoTopup-$TYPE-Threshold ====
 +
 +This attribute dictates when the usage falls below this amount a topup should be added.
 +
 +The threshold can be set to 0, which means only when the total limit has been exceeded will an auto-topup be added.
 +
 +If the value is left undefined it will default to (Amount / 2).
 ====== Configuration Attributes ====== ====== Configuration Attributes ======
  
 ===== Usage Statistics ===== ===== Usage Statistics =====
  
-==== SMRadius-Capping-Traffic-Topup (set by SMRadius) ====+The below configuration attributes are set by SMRadius.
  
-The amount of additional traffic in megabytes which the user can consume outside of the normal traffic limit before being disconnected and denied login. This attribute is set by the server using [[mod_config_sql_topups.pm]].+==== SMRadius-Capping-Traffic-Topup ====
  
-==== SMRadius-Capping-Uptime-Topup (set by SMRadius) ====+The amount of additional traffic in Mbyte which the user can consume outside of the normal traffic limit before being disconnected and denied login. This attribute is set by the server using [[mod_config_sql_topups.pm]]. 
 + 
 +==== SMRadius-Capping-Uptime-Topup ====
  
 The amount of additional uptime in minutes which the user can remain online for before being disconnected and denied login. This attribute is set by the server using [[mod_config_sql_topups.pm]]. The amount of additional uptime in minutes which the user can remain online for before being disconnected and denied login. This attribute is set by the server using [[mod_config_sql_topups.pm]].
 +
 +==== SMRadius-Capping-Traffic-AutoTopup ====
 +
 +<btn type="success" size="xs">Supported <badge>v1.0.x</badge></btn>
 +
 +The amount of traffic added by means of auto-topup in Mbyte. This attribute is set by the server using [[mod_config_sql_topups.pm]].
 +
 +==== SMRadius-Capping-Uptime-AutoTopup ====
 +
 +<btn type="success" size="xs">Supported <badge>v1.0.x</badge></btn>
 +
 +The amount of time added by means of auto-topup in minutes. This attribute is set by the server using [[mod_config_sql_topups.pm]].
  
 ====== Hooks ====== ====== Hooks ======