Skip to content

andrusstrockiy/asteracct

Repository files navigation

Radius Accounting script for Asterisk


## Description

Accounting script which connects to Asterisk through AMI interface monitors all events and sends Radius Accounting to Billing Server (BS) for account charging.

Requirements

OS CentOS/5x or 6x Debian 6 or 7

Python 2.6 or Python 3.2 or later

Asterisk version starting from 1.8 and later

Installation

  1. Get the source either by downloading an archive file or by cloning

    1. For Archive.Download as zip file archive
      • Download the script with :
         wget https://github.com/andrusstrockiy/asteracct/archive/master.zip -O asteramiacct.zip 
        • Then Unzip / Untar the following archive with the script
        sudo tar -zxvf asteramiacct.tar.gz -C /opt/
        • For unzip run the following:
        sudo unzip asteramiacct.zip -d /opt/ 
    2. To clone the repository
      • cd to opt directory:
         cd /opt 
      • and clone it:
        sudo git clone https://github.com/andrusstrockiy/asteracct.git
  2. Change permissions for installation folder in case you not planning of running that script as a root:

     chown _your_login_username_ /opt/asteracct/* 
  3. Edit asterisk dialplan extensions.conf set the following global variables in general section of that file

     [general]
     ....
     RADIUS_Server=Ip_of_your_Radius_Server
     RADIUS_Secret=secret
     RADIUS_Auth_Port=1812
     RAIUS_Acct_Port=1813
     Acct_Update_Timeout=30
     NAS_IP_Address=Ip_of_your_asterisk
     ...
     
  4. Enable and set asterisk AMI manager in managers.conf according the following example

    • To enable AMI interface on asterisk at the top of manageres.conf set :
      [general] 
      enabled = yes 
      port = 5038 
      
    • Then add manager (in same managers.conf file) by adding the following
[test]
 secret = test
 permit= 127.0.0.1/255.255.255.0 
 read = system,cdr,call,log,verbose,command,user
 write = system,cdr,call,log,verbose,command,user 
 
  1. Enable CDR output event to AMI console.Set in cdr manager.conf
 [general]
      enabled = yes 
  1. Copy init (start,stop) scripts to /etc/init.d directory
cp /opt/asteramiacct/init/aster* /etc/init.d/ 
  1. Enable cell events by setting in cel.conf Activate cel event in general settings

     [general]
     
     ; CEL Activation
     ;
     ; Use the 'enable' keyword to turn CEL on or off.
     ;
     ; Accepted values: yes and no
     ; Default value:   no
     enable=yes
     

    Forward cell events in AMI console

     [manager]
     ; AMI Backend Activation
     ;
     ; Use the 'enable' keyword to turn CEL logging to the Asterisk Manager Interface
     ; on or off.
     ;
     ; Accepted values: yes and no
     ; Default value:   no
     enabled=yes
     

    and then add

     events=ANSWER
     
  2. Install pyrad Radius library required for that script either from

    • Pypi Download and unzip\untar.
     cd pyrad-2.0 

    and then inside the above directory

    sudo python setup.py install
    • From local folder (bundled)
     cd /opt/asteracct/libs/pyrad-2.0 

    and then

     sudo python setup.py install
  3. Restart Asterisk through to apply new settings to asterisk

     service asterisk restart
     
  4. Start the script

 service asteramiacct start 
  1. Make some test calls and observe results.You should see Accounting-Start and Accounting-Stop packets to arrive at Radius

  2. Check that your script is actually running after making few telephone calls by doing in linux console

     ps aux | grep ast 

    Should give output like the following

     
    [root@pbx-msk andruss]# ps aux | grep ast
    root      3514  0.0  0.0 106064   528 ?        S    Sep01   0:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk
    asterisk  3517  0.4  1.4 1530376 31128 ?       Sl   Sep01 168:58 /usr/sbin/asterisk -f -U asterisk -G asterisk -vvvg -c
    root      5526  0.0  0.4  82880  8524 ?        S    15:11   0:00 /usr/bin/python2.6 /opt/asteracct/asteramiacct.py
    

Troubleshooting

For errors and troubleshooting please check log file asteracct.log of which located in /opt/asteracct/ directory. If still in trouble contact me.

Author, copyright, availability

asteramiacct was written by Andrew Tkachenko [email protected] and is licensed under a BSD license.

Copyright and license information can be found in the LICENSE.txt file.

The current version and documentation can be found on github: [source] (https://github.com/andrusstrockiy/asteracct)

Bugs and wishes can be submitted in the issue tracker on github: [issues] (https://github.com/andrusstrockiy/asteracct/issues)

About

Radius Accounting script for Asterisk PBX

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages