Skip to content

Commit

Permalink
v 1.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
vassilux committed Mar 31, 2015
1 parent ede210b commit 062dc5e
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 10 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.7
1.0.9
10 changes: 7 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
{ "name": "DID_span_4", "direction": 1},
{ "name": "DLPN_DialPlan1", "direction": 1},
{ "name": "DLPN_DialPlan2", "direction": 2},
{ "name": "DLPN_DialPlan3", "direction": 2},
{ "name": "process-in-fax", "direction": 3},
{ "name": "process-in-Modem-RSI", "direction": 3},
{ "name": "process-in-rsi", "direction": 3},
Expand All @@ -57,11 +58,14 @@
{ "name": "ringroups-custom-4", "direction": 2},
{ "name": "ringroups-custom-5", "direction": 2},
{ "name": "stdexten", "direction": 3},
{ "name": "voicemenu-custom-1", "direction": 3}


{ "name": "voicemenu-custom-1", "direction": 3}
],
"excludeFromAnalytics": [
"8889"
],

"cleanupRequests" : [
"update cdr set import = 66 where dst LIKE '%N%' and import = 0",
"update cdr set import = 66 where dst LIKE '%NOANSWER%' and import = 0"
]
}
11 changes: 7 additions & 4 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ Crée un lien symbolic ln -s /opt/revor/vorimport_[version] /opt/vorimport/curre
Copier le fichier config.sample.json en config.json : cp config.sample.json config.json
Addapter ce fichier à la configuraiton de système : le dialplan de iPBX et les besoins du client.

Paramètre cleanupRequests permet d'exécuter les requetes personnalisées avant lencement d'importaiton de données de mysql vers mongo.
Mot clé delete est interdit à utiliser.

Paramètre excludeFromAnalytics permet exclure des SDA de processus d'importation. Ce cas peut être intéressant car les numéro des SDA sont équivalant au numéro des postes.

Importat : Importation de SDA est basée sur les SDA saisie dans la base de données. Ces SDA peut être saisie via l'interface graphique

Context app-alive-test de asterisk dialplan est utilisé pour générer un test cyclique de toute la chaine
Ce context peut être ajouter dans /etc/asterisk/extensions_custom.conf.
Voici un example
Expand All @@ -56,10 +63,6 @@ Mise à jour est identique à l'installation sans la partie de la configuration.

Il faut copier le ficheir de la configuration actuel (/opt/vorimport/current/config.json) dans le repertoire /opt/vorimport/vorimport_[version]

Paramètre excludeFromAnalytics permet exclure des SDA de processus d'importation. Ce cas peut être intéressant car les numéro des SDA sont équivalant au numéro des postes.

Importat : Importation de SDA est basée sur les SDA saisie dans la base de données. Ces SDA peut être saisie via l'interface graphique


## Notes
Cluster
Expand Down
18 changes: 18 additions & 0 deletions docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
Release Notes vorimport
----------

==================================================================================

Release 1.0.9 date : 31/03/2015

==================================================================================

Fixing:

Nothing jsut up the version

New:



==================================================================================


==================================================================================

Release 1.0.7 date : 20/03/2015
Expand All @@ -15,6 +32,7 @@ Fixing:
New:

Add new parameter excludeFromAnalytics. Allow exclude did from analysing process
Add new parameter cleanupRequests. Allow execute customize requests before import datas from mysql to mongo. Delete word is forbiden



Expand Down
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Config struct {
Notifications []string
Dids []string
ExcludeFromAnalytics []string
CleanupRequests []string
}

var (
Expand Down Expand Up @@ -237,6 +238,13 @@ func importJob() {
sendMongoEventNotification(MONGOK)
log.Debug("Connected to the mongo database with success.")
//
err = executeCustomRequests(db)
if err != nil {
log.Errorf("Error to execute customise request : %s", err)
log.Flush()
os.Exit(1)
}
//
cdrs, err := getMysqlCdr(db)
//
if err != nil {
Expand Down
24 changes: 22 additions & 2 deletions mysql.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"fmt"
log "github.com/cihub/seelog"
"github.com/ziutek/mymysql/mysql"
Expand Down Expand Up @@ -130,7 +131,7 @@ func getMysqlCdrTestCall(db mysql.Conn) (results []RawCall, err error) {
log.Tracef("Enter into getMysqlCdr")
myQuery := "SELECT UNIX_TIMESTAMP(calldate) as calldate, clid, src, dst, channel, dcontext, disposition,billsec,duration,uniqueid,dstchannel, dnid, recordfile from asteriskcdrdb.cdr WHERE import = 0 and dcontext LIKE 'app-alive-test' LIMIT " + config.DbMySqlFetchRowNumber
//
log.Debugf("Executing request [%s]\r\n", myQuery)
log.Debugf("Equery = strings.ToUpper(query)xecuting request [%s]\r\n", myQuery)
rows, res, err := db.Query(myQuery)
//
if err != nil {
Expand All @@ -145,7 +146,7 @@ func getMysqlCdrTestCall(db mysql.Conn) (results []RawCall, err error) {
for _, row := range rows {
//
var c RawCall //Cdr
//mapping databases fields
//mappingquery = strings.ToUpper(query) databases fields
calldate := res.Map("calldate")
clid := res.Map("clid")
src := res.Map("src")
Expand All @@ -161,6 +162,7 @@ func getMysqlCdrTestCall(db mysql.Conn) (results []RawCall, err error) {
dstchannel := res.Map("dstchannel")
//
raw_clid := strings.FieldsFunc(row.Str(clid), bracket)

caller_name := ""
caller_number := ""

Expand Down Expand Up @@ -303,6 +305,24 @@ func udpateMySqlCdrImportStatus(db mysql.Conn, uniqueid string, status int) (err
return err
}

//Execute customize requests provisted by configuration file
func executeCustomRequests(db mysql.Conn) (err error) {
for i := range config.CleanupRequests {
var query = config.CleanupRequests[i]

if strings.Contains(strings.ToLower(query), "delete") == true {
return errors.New("Using delete keyword is forbiden. Please check your configuration file(config.json)")
}
_, _, err = db.Query(query)

if err != nil {
return err
}

}
return nil
}

func deleteMySqlCdrRecord(db mysql.Conn, uniqueid string) (err error) {
var query = fmt.Sprintf("DELETE FROM cdr WHERE uniqueid = '%s'", uniqueid)
_, _, err = db.Query(query)
Expand Down
3 changes: 3 additions & 0 deletions samples/config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
],
"excludeFromAnalytics": [

],
"cleanupRequests" : [

]

}
2 changes: 2 additions & 0 deletions tests/clear_and_import_mysql.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ function main()
fi

echo "delete from cdr;" | mysql -u root -plepanos -h127.0.0.1 asteriskcdrdb

echo "delete from cel;" | mysql -u root -plepanos -h127.0.0.1 asteriskcdrdb

mysql -uroot -plepanos -h127.0.0.1 asteriskcdrdb < ${SCRIPTPATH}/asteriskcdrdb.sql
}

Expand Down

0 comments on commit 062dc5e

Please sign in to comment.