1 | изначальная версия редактировать | |
можно написать скрипт который евент_лог парсит. выглядит вот так
#!/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";
}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";print "delete from mon_calls where uniq='$uniq' and queue='$queue';";
}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";}else{ print "update mon_agent set ok=ok+1 where agent=$agent ;\n"; }
} }}print "delete from mon_calls where uniq='$uniq' and queue='$queue';\n";
2 | No.2 Revision редактировать |
можно написать скрипт который евент_лог парсит. выглядит вот так
}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";#!/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 tablemonqueue(idmon_queue(id serial, queue varchar(10) not null,description varchar(100), ok bigint default 0,notoknot_ok bigint default 0, waiting bigint default 0,avg_waitdouble);double); #create tablemonagent(idmon_agent(id serial, agent varchar(10) not null,description varchar(100),ok bigint default 0); #create tablemoncalls(idmon_calls(id serial, queue varchar(10),uniq varchar(20)); if($ACTION eq "RINGNOANSWER"){ }elsif($ACTION eq "ENTERQUEUE"){ print "insert intomoncalls(queue,uniq)mon_calls(queue,uniq) values('$queue','$uniq');"; print "updatemonqueuemon_queue set waiting=waiting+1 where queue='$queue';\n"; }elsif($ACTION eq "CONNECT"){$waittime=$input[5];$wait_time=$input[5]; print "updatemonqueuemon_queue set waiting=waiting-1,ok=ok+1,avgwait=caseavg_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 wherequeue='$queue';\n";queue='$queue';\n"; print "delete from mon_calls where uniq='$uniq' and queue='$queue';";
Проект компании "АТС Дизайн"
Asterisk® и Digium® являются зарегистрированными торговыми марками компании
Digium, Inc., США.
IP АТС Asterisk распространяется под лицензией
GNU GPL.