/var/log/asterisk/queue_log
detailliert festgehalten (natürlich werden auch Einträge im CDR-Log
gemacht). Im queue_log steht ein Eintrag pro Zeile im
Format:Timestamp|Anruf-ID|Schlange|Channel|Event|Param1[|Param2[|Param3]]
TimestampAnruf-IDNULL oder NONE sein (z. B. bei dem
Ereignis QUEUESTART).Schlangesupport.
Kann auch NULL oder NONE sein.ChannelAgent/1001. Kann auch NULL oder
NONE sein.EventParam1, Param2 und
Param3 angegeben.doc/queuelog.txt):ABANDONAGENTDUMPAGENTLOGINSIP/127.0.0.1-0181ac00).AGENTCALLBACKLOGINAGENTLOGOFFAGENTCALLBACKLOGOFFCOMPLETEAGENTCOMPLETECALLERCONFIGRELOADasterisk -rx "module reload").CONNECTENTERQUEUEEXITEMPTYEXITWITHKEYEXITWITHTIMEOUTQUEUESTARTAnruf-ID, Schlange und
Kanal den Wert NULL.RINGNOANSWERSYSCOMPATTRANSFERQueueLog()“.queue_log durch eine Named-Pipe (FIFO) zu
ersetzen. Das Skript öffnet die FIFO zum Lesen, und sobald Asterisk eine
Log-Meldung hineinschreibt, wird diese in die Datenbank
eingetragen.SIGPIPE-Signal erhält, was Asterisk zum Absturz
bringen würde!#!/usr/bin/perl -w
#
# wlloyd at slap.net
# The asterisk version indpendant way to get queue stats into Mysql,
Postgres
# or whatever is supported by Perl DBI
# It's all about named pipes
# to setup this software
# stop asterisk
# rm /var/log/asterisk/queue_log
# mkfifo /var/log/asterisk/queue_log
# make sure permissions are setup
# chmod 777 /var/log/asterisk/queue_log
# run this program as root or under another user as you see fit.
# should start BEFORE asterisk. Add to /etc/rc.d/rc.local or whatever
# restart asterisk
# requires a DB table like the following..
# CREATE TABLE csr_queue (
# qname varchar(30) default NULL,
# agent varchar(30) default NULL,
# action text,
# info1 text,
# info2 text,
# info3 text,
# timestamp int(11) NOT NULL default '0',
# id tinytext NOT NULL
#) TYPE=MyISAM;
use DBI;
use IO::File;
my $opt_debug = 0;
# if you want postgres change this to "Pg"
my $db_type = "mysql";
my $db_host = "127.0.0.1";
my $db_user_name = 'username';
my $db_password = 'password';
my $db_database = 'asteriskstat';
my $dbh = DBI->connect("DBI:$db_type:dbname=$db_database;host=
$db_host;", $db_user_name, $db_password);
open(FIFO, "< /var/log/asterisk/queue_log") or die "Can't open
queue_log : $!\n";
while (1) {
$message = <FIFO>;
next unless defined $message; # interrupted or nothing logged
chomp $message;
# remove chars that will cause DB problems
$message =~ s/\"\'//g;
@data = split(/\|/,$message);
# these messages are almost useless for my purposes
next if ($data[4] eq "QUEUESTART" );
next if ($data[4] eq "CONFIGRELOAD" );
if (!defined($data[5])) {
$data[5] = '';
}
if (!defined($data[6])) {
$data[6] = '';
}
if (!defined($data[7])) {
$data[7] = '';
}
my $sql = "INSERT INTO csr_queue (timestamp, id, qname, agent,
action, info1, info2, info3) VALUES ('$data[0]', '$data[1]', '$data
[2]', '$data[3]', '$data[4]', '$data[5]', '$data[6]', '$data[7]')";
print "$sql \n\n" if ($opt_debug);
$dbh->do($sql);
# if you want an actual logfile you might want to uncomment this
# if ( open(LOG, ">> /var/log/asterisk/queue_log_real") ) {
# print LOG "$message\n";
# close(LOG);
# } else {
# warn "Couldn't log to /var/log/asterisk_queue_log: $!\n";
# }
#
}
$dbh->disconnect();
exit 0;queueLoader.pl mitgeliefert
(siehe aber die Warnung oben!).[87] siehe „leavewhenempty“
asterisk-users, siehe: http://lists.digium.com/pipermail/asterisk-users/2005-July/109892.html[92] Einen ähnlichen Ansatz findet man bei dem Hilfsprogramm
asterisk-qsync von André Herrmann: http://fisi-itse.de/index.php?option=com_content&task=view&id=24&Itemid=3