Пожалуйста, войдите здесь. Часто задаваемые вопросы О нас
Задайте Ваш вопрос

История изменений [назад]

нажмите, чтобы скрыть/показать версии 1
изначальная версия
редактировать

ответил 2011-02-18 20:46:41 +0400

meral Gravatar meral flag of Ukraine

http://pro-sip.net/

можно написать скрипт который евент_лог парсит. выглядит вот так

#!/usr/bin/perl
$| = 1; 
open(DAT, 'last.time') || die("Could not open file!"); $last=<dat>; close(DAT);

while ($line = <>) { # process $line here $line=~s/Local\///; $line=~s/\@from-queue\/n//; #print $line; @input = split(/\|/, $line); $calltime=$input[0]; if($calltime>=$last){ open(DAT, '>last.time') || die("Could not open file!"); print DAT $calltime; close(DAT); print "select $calltime;\n"; $uniq=$input[1]; $queue=$input[2]; $agent=$input[3]; $ACTION=$input[4]; #create table monqueue(id serial, queue varchar(10) not null,description varchar(100), ok bigint default 0, notok bigint default 0, waiting bigint default 0,avg_wait double);

#create table monagent(id serial, agent varchar(10) not null,description varchar(100),ok bigint default 0); #create table moncalls(id serial, queue varchar(10),uniq varchar(20)); if($ACTION eq "RINGNOANSWER"){ }elsif($ACTION eq "ENTERQUEUE"){ print "insert into moncalls(queue,uniq) values('$queue','$uniq');"; print "update monqueue set waiting=waiting+1 where queue='$queue';\n"; }elsif($ACTION eq "CONNECT"){ $waittime=$input[5]; print "update monqueue set waiting=waiting-1,ok=ok+1, avgwait=case when ( (ok+notok)= 0) then $waittime else (avgwait*(ok+notok)+$waittime)/(ok+not_ok+1) end where queue='$queue';\n";

    print "delete from mon_calls where uniq='$uniq' and queue='$queue';";
}elsif(($ACTION eq "COMPLETECALLER")||($ACTION eq "COMPLETEAGENT")){ $time=$input[6]; if($time eq "0"){# not ok call print "update mon_queue set ok=ok-1,not_ok=not_ok+1 where queue='$queue';\n";
    }else{
            print "update mon_agent set ok=ok+1 where  agent=$agent ;\n";
    }
}elsif($ACTION eq "ABANDON"){ $wait_time=$input[7]; print "update mon_queue set waiting=waiting-1,not_ok=not_ok+1, avg_wait=case when ((ok+not_ok) = 0) then $wait_time else (avg_wait*(ok+not_ok)+$wait_time)/(ok+not_ok+1) end where queue='$queue';\n";
    print "delete from mon_calls where uniq='$uniq' and queue='$queue';\n";
} }}

можно написать скрипт который евент_лог парсит. выглядит вот так

#!/usr/bin/perl
$| = 1; 
open(DAT, 'last.time') || die("Could not open file!"); $last=<dat>; close(DAT);

$last=<DAT>; close(DAT); while ($line = <>) { # process $line here $line=~s/Local\///; $line=~s/\@from-queue\/n//; #print $line; @input = split(/\|/, $line); $calltime=$input[0]; if($calltime>=$last){ $call_time=$input[0]; if($call_time>=$last){ open(DAT, '>last.time') || die("Could not open file!"); print DAT $calltime; $call_time; close(DAT); print "select $calltime;\n"; $call_time;\n"; $uniq=$input[1]; $queue=$input[2]; $agent=$input[3]; $ACTION=$input[4]; #create table monqueue(id mon_queue(id serial, queue varchar(10) not null,description varchar(100), ok bigint default 0, notok not_ok bigint default 0, waiting bigint default 0,avg_wait double);

double); #create table monagent(id mon_agent(id serial, agent varchar(10) not null,description varchar(100),ok bigint default 0); #create table moncalls(id mon_calls(id serial, queue varchar(10),uniq varchar(20)); if($ACTION eq "RINGNOANSWER"){ }elsif($ACTION eq "ENTERQUEUE"){ print "insert into moncalls(queue,uniq) mon_calls(queue,uniq) values('$queue','$uniq');"; print "update monqueue mon_queue set waiting=waiting+1 where queue='$queue';\n"; }elsif($ACTION eq "CONNECT"){ $waittime=$input[5]; $wait_time=$input[5]; print "update monqueue mon_queue set waiting=waiting-1,ok=ok+1, avgwait=case avg_wait=case when ( (ok+notok)= (ok+not_ok)= 0) then $waittime $wait_time else (avgwait*(ok+notok)+$waittime)/(ok+not_ok+1) (avg_wait*(ok+not_ok)+$wait_time)/(ok+not_ok+1) end where queue='$queue';\n";

queue='$queue';\n";

        print "delete from mon_calls where uniq='$uniq' and queue='$queue';";
}elsif(($ACTION eq "COMPLETECALLER")||($ACTION eq "COMPLETEAGENT")){ $time=$input[6]; if($time eq "0"){# not ok call print "update mon_queue set ok=ok-1,not_ok=not_ok+1 where queue='$queue';\n";
     }else{
             print "update mon_agent set ok=ok+1 where  agent=$agent ;\n";
     }
}elsif($ACTION eq "ABANDON"){ $wait_time=$input[7]; print "update mon_queue set waiting=waiting-1,not_ok=not_ok+1, avg_wait=case when ((ok+not_ok) = 0) then $wait_time else (avg_wait*(ok+not_ok)+$wait_time)/(ok+not_ok+1) end where queue='$queue';\n";
     print "delete from mon_calls where uniq='$uniq' and queue='$queue';\n";

}
}}
} }}

Проект компании "АТС Дизайн"
Asterisk® и Digium® являются зарегистрированными торговыми марками компании Digium, Inc., США.
IP АТС Asterisk распространяется под лицензией GNU GPL.