diff --git a/data/tutorials/asterisk_ari/asterisk/etc/asterisk/asterisk.conf b/data/tutorials/asterisk_ari/asterisk/etc/asterisk/asterisk.conf index a86ab4d7f..a1434746c 100755 --- a/data/tutorials/asterisk_ari/asterisk/etc/asterisk/asterisk.conf +++ b/data/tutorials/asterisk_ari/asterisk/etc/asterisk/asterisk.conf @@ -1,8 +1,8 @@ [directories] -astetcdir => /usr/share/cgrates/tutorials/asterisk_events/asterisk/etc/asterisk -astspooldir => /tmp/cgr_astevents/asterisk/spool -astlogdir => /tmp/cgr_astevents/asterisk/log -astrundir => /tmp/cgr_astevents/asterisk/run +astetcdir => /usr/share/cgrates/tutorials/asterisk_ari/asterisk/etc/asterisk +astspooldir => /tmp/cgr_asterisk_ari/asterisk/spool +astlogdir => /tmp/cgr_asterisk_ari/asterisk/log +astrundir => /tmp/cgr_asterisk_ari/asterisk/run [options] runuser = asterisk ; The user to run as. The default is root. diff --git a/data/tutorials/asterisk_ari/asterisk/etc/init.d/asterisk b/data/tutorials/asterisk_ari/asterisk/etc/init.d/asterisk index fe9e202df..b729b7490 100755 --- a/data/tutorials/asterisk_ari/asterisk/etc/init.d/asterisk +++ b/data/tutorials/asterisk_ari/asterisk/etc/init.d/asterisk @@ -20,8 +20,8 @@ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin NAME=asterisk DESC="Asterisk PBX" -TUTDIR=/usr/share/cgrates/tutorials/asterisk_events/asterisk -TMP_DIR=/tmp/cgr_astevents/asterisk +TUTDIR=/usr/share/cgrates/tutorials/asterisk_ari/asterisk +TMP_DIR=/tmp/cgr_asterisk_ari/asterisk # Full path to asterisk binary DAEMON=/usr/sbin/asterisk ASTVARRUNDIR=$TMP_DIR/run @@ -32,7 +32,7 @@ ALTCONF=$TUTDIR/etc/asterisk/asterisk.conf TRUE=/bin/true AST_USER="asterisk" AST_GROUP="asterisk" -VERBOSITY=99 +VERBOSITY=1 ### BEGIN INIT INFO diff --git a/data/tutorials/asterisk_ari/cgrates/etc/cgrates/cgrates.json b/data/tutorials/asterisk_ari/cgrates/etc/cgrates/cgrates.json index cca0f1dcf..5eabe3c13 100644 --- a/data/tutorials/asterisk_ari/cgrates/etc/cgrates/cgrates.json +++ b/data/tutorials/asterisk_ari/cgrates/etc/cgrates/cgrates.json @@ -3,7 +3,26 @@ // Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments // Copyright (C) ITsysCOM GmbH - +"general": { + "http_skip_tls_verify": false, // if enabled Http Client will accept any TLS certificate + "rounding_decimals": 5, // system level precision for floats + "dbdata_encoding": "msgpack", // encoding used to store object data in strings: + "tpexport_dir": "/var/spool/cgrates/tpe", // path towards export folder for offline Tariff Plans + "httpposter_attempts": 3, // number of http attempts before considering request failed (eg: *call_url) + "http_failed_dir": "/var/spool/cgrates/http_failed", // directory path where we store failed http requests + "default_request_type": "*rated", // default request type to consider when missing from requests: <""|*prepaid|*postpaid|*pseudoprepaid|*rated> + "default_category": "call", // default category to consider when missing from requests + "default_tenant": "cgrates.org", // default tenant to consider when missing from requests + "default_timezone": "Local", // default timezone for timestamps where not specified <""|UTC|Local|$IANA_TZ_DB> + "connect_attempts": 3, // initial server connect attempts + "reconnects": -1, // number of retries in case of connection lost + "connect_timeout": "1s", // consider connection unsuccessful on timeout, 0 to disable the feature + "reply_timeout": "2s", // consider connection down for replies taking longer than this value + "response_cache_ttl": "0s", // the life span of a cached response + "internal_ttl": "2m", // maximum duration to wait for internal connections before giving up + "locking_timeout": "5s", // timeout internal locks to avoid deadlocks + "cache_dump_dir": "", // cache dump for faster start (leave empty to disable) +}, "rals": { "enabled": true, @@ -114,6 +133,9 @@ "sm_asterisk": { "enabled": true, // starts Asterisk SessionManager service: "create_cdr": true, + "asterisk_conns":[ // instantiate connections to multiple Asterisk servers + {"address": "127.0.0.1:8088", "user": "cgrates", "password": "CGRateS.org", "connect_attempts": 3,"reconnects": 10} + ], }, diff --git a/data/tutorials/asterisk_ari/cgrates/etc/init.d/cgrates b/data/tutorials/asterisk_ari/cgrates/etc/init.d/cgrates index f9dd971c5..2d8543976 100755 --- a/data/tutorials/asterisk_ari/cgrates/etc/init.d/cgrates +++ b/data/tutorials/asterisk_ari/cgrates/etc/init.d/cgrates @@ -21,7 +21,7 @@ DAEMON=/usr/bin/cgr-engine USER=cgrates GROUP=cgrates DAEMON_OPTS="" -TUTFOLDER=/usr/share/cgrates/tutorials/asterisk_events/cgrates +TUTFOLDER=/usr/share/cgrates/tutorials/asterisk_ari/cgrates TMP_DIR=/tmp/cgr_astevents/cgrates SCRIPTNAME=$TUTFOLDER/etc/init.d/$NAME RUNDIR=$TMP_DIR/run diff --git a/docs/tut_asterisk.rst b/docs/tut_asterisk.rst new file mode 100644 index 000000000..4350111eb --- /dev/null +++ b/docs/tut_asterisk.rst @@ -0,0 +1,18 @@ +Asterisk_ Integration Tutorials +=============================== + +In these tutorials we exemplify few cases of integration between Asterisk_ and CGRateS_. We start with common steps, installation and postinstall processes then we dive into particular configurations, depending on the case we run. + + +.. toctree:: + :maxdepth: 2 + + tut_asterisk_installs + tut_cgrates_installs + tut_jitsi_installs + tut_asterisk_ari + tut_cgrates_usage + +.. _Asterisk: http://www.asterisk.org/ +.. _CGRateS: http://www.cgrates.org/ + diff --git a/docs/tut_asterisk_ari.rst b/docs/tut_asterisk_ari.rst new file mode 100644 index 000000000..c392dc08f --- /dev/null +++ b/docs/tut_asterisk_ari.rst @@ -0,0 +1,59 @@ +Asterisk_ interaction via *ARI* +=========================================== + +Scenario +-------- + +- Asterisk out of *basic-pbx* configuration samples. + + - Considering the following users: 1001-prepaid, 1002-postpaid, 1003-pseudoprepaid, 1004-rated, 1007-rated. + +- **CGRateS** with following components: + + - CGR-SM started as translator between Asterisk_ and **CGR-RALs** for both authorization events (prepaid/pseudoprepaid) as well as postpaid ones. + - CGR-CDRS component processing raw CDRs from CGR-SM component and storing them inside CGR StorDB. + - CGR-CDRE exporting rated CDRs from CGR StorDB (export path: */tmp*). + - CGR-History component keeping the archive of the rates modifications (path browsable with git client at */tmp/cgr_history*). + + +Starting Asterisk_ with custom configuration +---------------------------------------------- + +:: + + asterisk -r -s /tmp/cgr_asterisk_ari/asterisk/run/asterisk.ctl + +To verify that Asterisk_ is running we run the console command: + +:: + + ari show status + + +Starting **CGRateS** with custom configuration +---------------------------------------------- + +:: + + /usr/share/cgrates/tutorials/asterisk_ari/cgrates/etc/init.d/cgrates start + +Make sure that cgrates is running + +:: + + cgr-console status + + +CDR processing +-------------- + +At the end of each call Asterisk_ will generate an CDR event and due to automatic handler registration built in **CGRateS-SM** component, this will be directed towards the port configured inside *cgrates.json*. This event will reach inside **CGRateS** through the *SM* component (close to real-time). Once in-there it will be instantly rated and be ready for export. + + +**CGRateS** Usage +----------------- + +Since it is common to most of the tutorials, the example for **CGRateS** usage is provided in a separate page `here `_ + + +.. _Asterisk: http://www.asterisk.org/ diff --git a/docs/tut_asterisk_installs.rst b/docs/tut_asterisk_installs.rst new file mode 100644 index 000000000..99b1c7b58 --- /dev/null +++ b/docs/tut_asterisk_installs.rst @@ -0,0 +1,23 @@ +Software installation +===================== + +As operating system we have choosen Debian stable. + +Asterisk_ +--------- + +We got Asterisk14_ installed via following commands: +:: + + apt-get install autoconf build-essential openssl libssl-dev libsrtp-dev libxml2-dev libncurses5-dev uuid-dev sqlite3 libsqlite3-dev pkg-config libjansson-dev + cd /tmp/ + wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-14-current.tar.gz + tar xzvf asterisk-14-current.tar.gz + cd asterisk-14.0.2/ + ./configure --with-pjproject-bundled + make + make install + +Once installed we proceed with loading the configuration out of specific tutorial cases bellow. + +.. _Asterisk14: http://www.asterisk.org/ diff --git a/docs/tut_freeswitch_installs.rst b/docs/tut_freeswitch_installs.rst index 4588c74d1..60d3864a6 100644 --- a/docs/tut_freeswitch_installs.rst +++ b/docs/tut_freeswitch_installs.rst @@ -23,8 +23,3 @@ We got FreeSWITCH_ installed via following commands: Once installed we proceed with loading the configuration out of specific tutorial cases bellow. .. _FreeSWITCH: http://www.freeswitch.org/ - - - - - diff --git a/engine/version.go b/engine/version.go index 87f2abfd1..234c8a1eb 100644 --- a/engine/version.go +++ b/engine/version.go @@ -46,7 +46,7 @@ func CheckVersion(acntDB AccountingStorage) error { // comparing versions if len(CurrentVersion.CompareAndMigrate(dbVersion)) > 0 { // write the new values - msg := "Migration needed: please backup cgr data and run cgr-cloader -migrate" + msg := "Migration needed: please backup cgr data and run cgr-loader -migrate" utils.Logger.Crit(msg) return errors.New(msg) } diff --git a/general_tests/tutorial_astevents_calls_test.go b/general_tests/tutorial_astevents_calls_test.go index 5460e02eb..cd98b0951 100644 --- a/general_tests/tutorial_astevents_calls_test.go +++ b/general_tests/tutorial_astevents_calls_test.go @@ -44,7 +44,7 @@ func TestTutAstCallsInitCfg(t *testing.T) { } // Init config first var err error - tutAstCallsCfg, err = config.NewCGRConfigFromFolder(path.Join(*dataDir, "tutorials", "asterisk_events", "cgrates", "etc", "cgrates")) + tutAstCallsCfg, err = config.NewCGRConfigFromFolder(path.Join(*dataDir, "tutorials", "asterisk_ari", "cgrates", "etc", "cgrates")) if err != nil { t.Error(err) } @@ -78,7 +78,7 @@ func TestTutAstCallsStartAsterisk(t *testing.T) { return } engine.KillProcName("asterisk", 1000) - if err := engine.CallScript(path.Join(*dataDir, "tutorials", "asterisk_events", "asterisk", "etc", "init.d", "asterisk"), "start", 2000); err != nil { + if err := engine.CallScript(path.Join(*dataDir, "tutorials", "asterisk_ari", "asterisk", "etc", "init.d", "asterisk"), "start", 2000); err != nil { t.Fatal(err) } } @@ -89,7 +89,7 @@ func TestTutAstCallsStartEngine(t *testing.T) { return } engine.KillProcName("cgr-engine", *waitRater) - if err := engine.CallScript(path.Join(*dataDir, "tutorials", "asterisk_events", "cgrates", "etc", "init.d", "cgrates"), "start", 100); err != nil { + if err := engine.CallScript(path.Join(*dataDir, "tutorials", "asterisk_ari", "cgrates", "etc", "init.d", "cgrates"), "start", 100); err != nil { t.Fatal(err) } } @@ -100,7 +100,7 @@ func TestTutAstCallsRestartAsterisk(t *testing.T) { if !*testCalls { return } - if err := engine.CallScript(path.Join(*dataDir, "tutorials", "asterisk_events", "asterisk", "etc", "init.d", "asterisk"), "restart", 2000); err != nil { + if err := engine.CallScript(path.Join(*dataDir, "tutorials", "asterisk_ari", "asterisk", "etc", "init.d", "asterisk"), "restart", 2000); err != nil { t.Fatal(err) } }