h1. Controllers {{>toc}} Controller - is application which performs constant monitoring of specific parameters of telephony traffic. In case if during configured period of time these parameters go beyond configured thresholds, the traffic might be blocked. In the moment of blocking there can occur a sending of warning e-mail to e-mail address of blocked partner, and also a sending of copy of this e-mail to your e-mail address. Blocking could last for specified amount of time. When this time elapses, telephony traffic could be unblocked and the process may begin once more. You can enable controller in 2 modes: * *peer*. Smartswitch compares traffic parameters with threshold values for whole peer and blocks whole peer. * *destination code*. System compares traffic parameters with threshold values for each controlled destination code and blocks each code independently. The list of controlled codes can be specified in form of [[Regex patterns]]. For most typical case - "control all destination codes" - should specify code pattern ".*". h2. Blocking To perform control, application is launched with some specific interval. By defaults it's 5 minutes. You can setup some other interval in _General->Tasks_. On each launch controller compares traffic parameters with threshold values on peers on which controller is enabled. As soon as traffic parameters go beyond threshold values on some peer (or, depending on configured mode, destination code), this peer (or destination code) is marked as needing for further monitoring. Totally, this peer (or destination code) is checked during the number of iterations, which is equal to the _check iterations_ options. For example: _check iterations_ = 10 _period of controller launch (minutes)_ = 5 If all of 10 launches of controller (i.e. during 50 minutes) the traffic parameters go beyond the threshold values - this peer (destination code) is blocked and further traffic is not sent/accepted to him. If you set _iteration count_ = 0, then on a very 1st failed check the peer (or destination code) code will be blocked. Now there comes a task of unblocking destination code to forward traffic there once more. This could be done either manually by deleting destination code from [[Blocked codes]], or automatically. h2. Automatic unblocking For automatic unblocking there is a parameter _block iterations_. It defined how many iterations this peer (destination code) will be blocked, afterwards it gets automatically unblocked. For example: _block iterations_ = 72 _period of controller launch (minutes)_ = 5 Destination code will be unblocked after 5 * 72 = 360 minutes (6 hours) If _block iterations_ = 0, peer (or destination code) won't be blocked. If _block iterations_ = 1, peer (or destination code) will be blocked and automatically unblocked in 5 minutes. h2. Simulate blocking Also it's possible to *simulate blocking*. In this case Smartswitch will send/receive traffic on blocked peer (or destination code), and all other functionality (displaying in [[Blocked codes]] and sending warning mail) will work. h2. Sending warning mail. It's possible to send warning e-mail at the moment when blocking occurs. When sending warning e-mail a configured [[Mail templates|Mail template]] is used. This template accepts following variables: *COMPANY* - the name of company, on which has been detected failure *PEER* - the name of peer, on which failure has been detected *PERIOD* - period, during which check has been done *DETAILS* - details regarding thresholds violation. *DETAILS_HTML* - same details, but in format of HTML table, suitable to using in HTML mail template. The description of details in described in section Implementation in corresponding section. h2. Implementation Below are described various implementations for logic described above. * [[Termination control]] * [[Origination control]] [[Контролёры|Русский перевод]]