Page MenuHomePhabricator

No OneTemporary

diff --git a/debian/cdrtool.default b/debian/cdrtool.default
index a0f31f9..0ccc2f1 100644
--- a/debian/cdrtool.default
+++ b/debian/cdrtool.default
@@ -1,6 +1,6 @@
# To enable rating engine first configure /var/www/CDRTool/global.inc
RUN_ratingEngine=no
START_MEMCACHE=no
-MEMCACHE_MEMORY=64
+MEMCACHE_MEMORY=128
MEMCACHE_IP=127.0.0.1
MEMCACHE_PORT=11212
diff --git a/debian/changelog b/debian/changelog
index 159a4d4..d5e979b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,114 +1,123 @@
+cdrtool (4.7-3) unstable; urgency=low
+
+ * Increased default memcache and php memory to 128MB
+ * Fixed statistics to work with domains that have no online users
+ * Corrected wrong example of memcache location in sample configuration file
+ * Added style.css file to debian package
+
+ -- Adrian Georgescu <ag@ag-projects.com> Thu, 26 Oct 2006 12:20:57 +0200
+
cdrtool (4.7-2) unstable; urgency=low
* Added monthly usage caches for SIP domains and platform total in and out
- * Improve display of SIP traces
+ * Improved display of SIP traces
* Added new screenshots
* Removed _darcs directory from the debian package
* Use DB_ser database class if DB_online not defined
* Add checks to mysql database creation script
* Log balance updates from the web in prepaid_history table
-- Adrian Georgescu <ag@ag-projects.com> Sun, 22 Oct 2006 14:57:35 +0200
cdrtool (4.7-1) unstable; urgency=low
* Renamed database class used by quota check system
* Updated rating documentation
-- Adrian Georgescu <ag@ag-projects.com> Wed, 11 Oct 2006 09:27:28 +0200
cdrtool (4.7-0) unstable; urgency=low
* Improved the speed of normalization and quota processes with a factor > 10
This requires the installation of a memcache server and setup of
global.inc to point to the memcache server (default is 127.0.0.1:11212)
* Added memcache to cdrtool startup script and /etc/default/cdrtool
* A new database table cdrtool.memcache has been created to store data in mysql
when a memcache server is not available (see setup/mysql/alter_tables.mysql)
* Added graphical statistics for SIP online subscriber and MediaProxy usage
Added a new cron script scripts/buildStatistics.php
* Hide Sendmail button if CDR query has no description
* Quota checks is now much faster by reusing incremental learned data
* Cache SIP subscribers and domains into memcache
* Cache destinations into memcache
* Calls can be rated if the duration is greater than a minimum duration
-- Adrian Georgescu <ag@ag-projects.com> Fri, 29 Sep 2006 18:18:58 +0200
cdrtool (4.6-9) unstable; urgency=low
* Added note about the dependency on the PHP SOAP library in doc/INSTALL.txt
-- Adrian Georgescu <ag@ag-projects.com> Tue, 19 Sep 2006 22:42:21 +0200
cdrtool (4.6-8) unstable; urgency=low
* Fixed variable names in phplib to avoid the need for registering
global variables in php.ini
* Tested CDRTool successfully against apache2/php5
* Create CDRTool/local/images directory during installation
* Remove sample apache configuration, is available in apache2
* Updated apache 2 virtual host definition
-- Adrian Georgescu <ag@ag-projects.com> Sun, 3 Sep 2006 12:26:56 +0200
cdrtool (4.6-7) unstable; urgency=low
* Update sample configuration for new installations
* Update documentation of rating engine
* Perform speeds test for the postpaid and prepaid applications
(results are available in the rating engine documentation)
* Removed Event-Timestamp from dictionary.ser, it is present now
in freeradius standard distribution
* Simplify default configuration
* Remove unused declaration of table_missed
* Replaced $cdr with $this->cdrtool and removed it from global.inc
* Allocate more memory at start time from phplib
-- Adrian Georgescu <ag@ag-projects.com> Fri, 25 Aug 2006 14:01:21 +0200
cdrtool (4.6-6) unstable; urgency=low
* Migrate from CVS to darcs version control
* Set executable flag for php scripts after installation
* Hide _darcs directory in apache
* Log the loading of prepaid accounts during start-up
-- Adrian Georgescu <ag@ag-projects.com> Thu, 10 Aug 2006 15:57:20 +0200
cdrtool (4.6-5) unstable; urgency=low
* Fixed search in query logs by string
-- Adrian Georgescu <ag@ag-projects.com> Tue, 8 Aug 2006 12:14:17 +0200
cdrtool (4.6-4) unstable; urgency=low
* Added script to reload rating engine scripts/reloadRatingTables.php
* cdrtool init.d script can reload the rating engine
* Added sample configuration for monit in setup/monit/monitrc
* Update description of 488 code
-- Adrian Georgescu <ag@ag-projects.com> Mon, 7 Aug 2006 10:49:19 +0200
cdrtool (4.6-3) unstable; urgency=low
* Properly put ratingEngine in background releasing the terminal
-- Adrian Georgescu <ag@ag-projects.com> Sun, 06 Aug 2006 18:05:05 +0200
cdrtool (4.6-2) unstable; urgency=low
* debian packaging improvements
-- Adrian Georgescu <ag@ag-projects.com> Sun, 06 Aug 2006 17:12:05 +0200
cdrtool (4.6-1) unstable; urgency=low
* Created CDRTool debian package
* Added filter for listing the query log, users with admin right may
select and edit all queries
* Added a new index in the log table (see setup/mysql/alter_tables.mysql)
-- Adrian Georgescu <ag@ag-projects.com> Sat, 5 Aug 2006 11:17:56 +0200
diff --git a/phplib/prepend.php3 b/phplib/prepend.php3
index ed8a16f..eae68d5 100644
--- a/phplib/prepend.php3
+++ b/phplib/prepend.php3
@@ -1,41 +1,41 @@
<?php
ini_set('register_globals','on');
ini_set('max_execution_time','120');
-ini_set('memory_limit','64M');
+ini_set('memory_limit','128M');
/*
* Session Management for PHP3
*
* Copyright (c) 1998,1999 SH Online Dienst GmbH
* Boris Erdmann, Kristian Koehntopp
*
* $Id: prepend.php3,v 1.1.1.1 2004-04-29 10:18:10 adigeo Exp $
*
*/
if (!is_array($_PHPLIB)) {
# Aren't we nice? We are prepending this everywhere
# we require or include something so you can fake
# include_path when hosted at provider that sucks.
$_PHPLIB["libdir"] = "";
}
require($_PHPLIB["libdir"] . "db_mysql.inc"); /* Change this to match your database. */
require($_PHPLIB["libdir"] . "db_sybase.inc"); /* Change this to match your database. */
require($_PHPLIB["libdir"] . "ct_sql.inc"); /* Change this to match your data storage container */
require($_PHPLIB["libdir"] . "session.inc"); /* Required for everything below. */
require($_PHPLIB["libdir"] . "auth.inc"); /* Disable this, if you are not using authentication. */
require($_PHPLIB["libdir"] . "perm.inc"); /* Disable this, if you are not using permission checks. */
require($_PHPLIB["libdir"] . "user.inc"); /* Disable this, if you are not using per-user variables. */
require($_PHPLIB["libdir"] . "oohforms.inc");
/* Additional require statements go below this line */
/* Additional require statements go before this line */
require($_PHPLIB["libdir"] . "local.inc"); /* Required, contains your local configuration. */
require($_PHPLIB["libdir"] . "page.inc"); /* Required, contains the page management functions. */
?>
diff --git a/sip_statistics_lib.phtml b/sip_statistics_lib.phtml
index b281425..fd50375 100644
--- a/sip_statistics_lib.phtml
+++ b/sip_statistics_lib.phtml
@@ -1,468 +1,494 @@
<?
class SIPstatistics {
var $SipEnabledZones = array();
var $online = array();
function SIPstatistics () {
global $CDRTool;
$this->mrtgcfg_file = $CDRTool['Path']."/status/usage/sip_statistics.mrtg";
$this->harvest_file = "/tmp/CDRTool-sip-statistics.txt";
$this->mrtgcfg_dir = $CDRTool['Path']."/status/usage";
$this->index_file = $CDRTool['Path']."/status/usage/index.html";
$this->harvest_script = $CDRTool['Path']."/scripts/harvestStatistics.php";
$this->generateMrtgDataScript = $CDRTool['Path']."/scripts/generateMrtgData.php";
$this->generateMrtgConfigScript = $CDRTool['Path']."/scripts/generateMrtgConfig.php";
$this->db = new DB_cdrtool();
$this->ser_db = new DB_ser();
if (class_exists('DB_siponline')) {
$this->online_db = new DB_siponline();
} else {
$this->online_db = new DB_ser();
}
$path = dirname(realpath($_SERVER['PHP_SELF']));
include($path."/../status/config/media_servers.php");
$this->mediaServers=$servers;
}
function getSipEnabledZones () {
global $CDRTool;
$query="select domain from domain";
dprint($query);
if (!$this->ser_db->query($query)) return 0;
if (!$this->ser_db->num_rows()) return 0;
while ($this->ser_db->next_record()) {
$zName=$this->ser_db->f('domain');
if (is_array($CDRTool['statistics']['zoneFilter']) && !in_array($zName,$CDRTool['statistics']['zoneFilter'])) continue;
if (!$seen[$zName]) {
$this->SipEnabledZones[$zName] = $zName;
$this->statistics[$zName] =
array( 'online_users' => '0',
'sessions' => '0',
'traffic' => '0',
'caller' => '0',
'called' => '0'
);
$seen[$zName]++;
}
}
//print_r($this->SipEnabledZones);
//dprint_r($this->statistics);
}
function generateHTMLUsageIndexPage () {
global $CDRTool;
$this->getSipEnabledZones();
if (!$handle = fopen($this->index_file, 'w+')) {
echo "Error opening {$this->index_file}.\n";
return 0;
}
// printing cfg header
$title=$CDRTool['provider']['name']." SIP statistics";
fwrite($handle,"
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>
<HTML>
<HEAD>
<TITLE>$title</TITLE>
<META HTTP-EQUIV='Refresh' CONTENT='300'>
<META HTTP-EQUIV='Cache-Control' content='no-cache'>
<META HTTP-EQUIV='Pragma' CONTENT='no-cache'>
<META HTTP-EQUIV='Expires' CONTENT='Thu, 16 Dec 2004 16:08:32 GMT'>
</HEAD>
<BODY bgcolor='#ffffff' text='#000000' link='#000000' vlink='#000000' alink='#000000'>
<DIV align='left'><font size='5' face=verdana><B>$title</B></font></DIV>
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=10>
");
while(list($key,$value) = each($this->SipEnabledZones)) {
$block=sprintf("<TR>
<TD><DIV align='center'><B> Online Users for %s </B></DIV>
<DIV><A HREF='%s_users.html'><IMG BORDER=0 ALT='%s_users Traffic Graph' SRC='%s_users-day.png'></A>
<SMALL><!--#flastmod file='%s_users.html' --></SMALL></DIV>
</TD><TD><DIV align='center'><B> Active Sessions for %s </B></DIV>
<DIV><A HREF='%s_sessions.html'><IMG BORDER=0 ALT='%s_sessions Traffic Graph' SRC='%s_sessions-day.png'></A>
<SMALL><!--#flastmod file='%s_sessions.html' --></SMALL></DIV>
</TD><TD><DIV align='center'><B> IP Traffic for %s </B></DIV>
<DIV><A HREF='%s_traffic.html'><IMG BORDER=0 ALT='%s_traffic Traffic Graph' SRC='%s_traffic-day.png'></A>
<SMALL><!--#flastmod file='%s_traffic.html' --></SMALL></DIV>
</TD></TR>
<TR>",
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key,
$key
);
fwrite($handle,$block);
}
fwrite($handle,"
</TABLE>
</BODY>
</HTML>"
);
fclose($handle);
}
function generateMrtgConfigFile () {
$this->getSipEnabledZones();
if (!$handle = fopen($this->mrtgcfg_file, 'w+')) {
echo "Error opening {$this->mrtgcfg_file}.\n";
return 0;
}
// printing cfg header
fwrite($handle,"
### Global Config Options
WorkDir: {$this->mrtgcfg_dir}
IconDir: {$this->mrtgcfg_dir}/images
Refresh: 300
#WriteExpires: Yes
");
while(list($key,$value) = each($this->SipEnabledZones)) {
fwrite($handle,"\n\n
## {$key}
Target[{$key}_users]: `{$this->generateMrtgDataScript} {$key} users`
Options[{$key}_users]: growright, gauge, nobanner
BodyTag[{$key}_users]: <BODY LEFTMARGIN=\"1\" TOPMARGIN=\"1\">
#PNGTitle[{$key}_users]: <center>Online Users for {$key}</center>
MaxBytes[{$key}_users]: 1250000
Title[{$key}_users]: Online Users for {$key}
ShortLegend[{$key}_users]: U
XSize[{$key}_users]: 300
YSize[{$key}_users]: 75
Ylegend[{$key}_users]: Users
Legend1[{$key}_users]: Online Users
LegendI[{$key}_users]: Online Users
LegendO[{$key}_users]:
PageTop[{$key}_users]: <H1> Online Users for {$key} </H1>
Target[{$key}_sessions]: `{$this->generateMrtgDataScript} {$key} sessions`
Options[{$key}_sessions]: growright, nobanner, gauge
BodyTag[{$key}_sessions]: <BODY LEFTMARGIN=\"1\" TOPMARGIN=\"1\">
MaxBytes[{$key}_sessions]: 1250000
Title[{$key}_sessions]: Sessions Statistics for {$key}
ShortLegend[{$key}_sessions]: Ses
XSize[{$key}_sessions]: 300
YSize[{$key}_sessions]: 75
Ylegend[{$key}_sessions]: Sessions
Legend1[{$key}_sessions]: Active Sessions
LegendI[{$key}_sessions]: Active Sessions
LegendO[{$key}_sessions]:
PageTop[{$key}_sessions]: <H1> Active Sessions for {$key} </H1>
Target[{$key}_traffic]: `{$this->generateMrtgDataScript} {$key} traffic`
Options[{$key}_traffic]: gauge, growright, bits, nobanner
BodyTag[{$key}_traffic]: <BODY LEFTMARGIN=\"1\" TOPMARGIN=\"1\">
#PNGTitle[{$key}_traffic]: {$key} traffic
MaxBytes[{$key}_traffic]: 1250000
Title[{$key}_traffic]: IP traffic for {$key}
XSize[{$key}_traffic]: 300
YSize[{$key}_traffic]: 75
Legend1[{$key}_traffic]: Caller Traffic in Bits per Second
Legend2[{$key}_traffic]: Called Traffic in Bits per Second
LegendI[{$key}_traffic]: caller
LegendO[{$key}_traffic]: called
PageTop[{$key}_traffic]: <H1> IP Traffic for {$key} </H1>
");
}
fclose($handle);
}
function generateMrtgData($domain,$dataType) {
$value1=0;
$value2=0;
$lines=explode("\n",file_get_contents($this->harvest_file));
foreach ($lines as $line) {
if (preg_match("/^$domain\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/",$line,$m)) {
if ($dataType == 'sessions') {
$value1 = $m[2];
$value2 = $m[2];
} else if ($dataType == 'traffic') {
$value1 = $m[3];
$value2 = $m[4];
} else if ($dataType == 'users') {
$value1 = $m[1];
$value2 = $m[1];
}
}
}
printf ("%d\n%d\n0\n0\n\n",$value1,$value2);
}
function getSIPOnlineUsers() {
$query="select count(*) as c, domain
from location group by domain";
dprint($query);
if (!$this->online_db->query($query)) return 0;
if (!$this->online_db->num_rows()) return 0;
while ($this->online_db->next_record()) {
$this->online[$this->online_db->f('domain')]=$this->online_db->f('c');
}
dprint_r($this->online);
}
function harvestStatistics() {
if (!$handle = fopen($this->harvest_file, 'w+')) {
echo "Error opening $this->harvest_file\n";
return 0;
}
fwrite($handle,"domains\t\t\tonline_users\tsessions\tcaller\tcalled\n\n");
$this->getSipEnabledZones();
$this->getSIPOnlineUsers();
$domains=array_keys($this->SipEnabledZones);
ksort($domains);
foreach($domains as $_domain) {
foreach (array_keys($this->online) as $_domain_online) {
if ($_domain == $_domain_online) {
// update online users in big stats array
$this->statistics[$_domain]['online_users']=$this->online[$_domain];
}
}
}
foreach($this->mediaServers as $server) {
$this->statistics = $this->getrtpsessions($server, "25060", $this->statistics);
}
while(list($key, $usage) = each($this->statistics)) {
- if ($usage['online_users'] >= 1) {
- fwrite($handle,"{$key}\t\t{$usage['online_users']}\t\t{$usage['sessions']}\t\t{$usage['caller']}\t{$usage['called']}\n");
+ if ($usage['online_users']) {
+ $online_users=$usage['online_users'];
+ } else {
+ $online_users=0;
}
+ if ($usage['sessions']) {
+ $sessions=$usage['sessions'];
+ } else {
+ $sessions=0;
+ }
+ if ($usage['caller']) {
+ $caller=$usage['caller'];
+ } else {
+ $caller=0;
+ }
+ if ($usage['called']) {
+ $called=$usage['called'];
+ } else {
+ $called=0;
+ }
+
+ fwrite($handle,"{$key}\t\t{$online_users}\t\t{$sessions}\t\t{$caller}\t{$called}\n");
}
fclose($handle);
}
function getrtpsessions($ip, $port, $_domains) {
if ($fp = fsockopen ($ip, $port, $errno, $errstr, "5") ) {
fputs($fp, "status\n");
$proxy = array('status' => 'Ok');
$crtSession = 'None';
while (!feof($fp)) {
$line = fgets($fp, 2048);
$elements = explode(" ", $line);
if ($elements[0] == 'proxy' && count($elements)==3) {
$proxy['sessionCount'] = $elements[1];
$traffic = explode("/", $elements[2]);
$proxy['traffic'] = array('caller' => $traffic[0],
'called' => $traffic[1],
'relayed' => $traffic[2]);
$proxy['sessions'] = array();
} else if ($elements[0]=='session' && count($elements)==7) {
$crtSession = $elements[1];
$info = array('from' => $elements[2],
'to' => $elements[3],
'fromAgent' => "'".$elements[4]."'",
'toAgent' => "'".$elements[5]."'",
'duration' => $elements[6],
'streams' => array());
$proxy['sessions'][$crtSession] = $info;
+
list($caller, $caller_domain) = explode("@", $proxy['sessions'][$crtSession]['from']);
+ $caller_domain_els=explode(":",$caller_domain);
+ $caller_domain=$caller_domain_els[0];
+
list($called, $called_domain) = explode("@", $proxy['sessions'][$crtSession]['to']);
+ $called_domain_els=explode(":",$called_domain);
+ $called_domain=$called_domain_els[0];
+
$_domains[$caller_domain]['sessions'] += 1;
if($caller_domain != $called_domain) $_domains[$called_domain]['sessions'] += 1;
} else if ($elements[0] == 'stream' && count($elements)==9 && $proxy['sessions'][$crtSession]['duration'] > 0) {
$stream = array('caller' => $elements[1],
'called' => $elements[2],
'via' => $elements[3],
'bytes' => explode("/", $elements[4]),
'status' => $elements[5],
'codec' => $elements[6],
'type' => $elements[7],
'idletime' => $elements[8]);
$proxy['sessions'][$crtSession]['streams'][] = $stream;
$_domains[$caller_domain]['caller'] += floor($proxy['sessions'][$crtSession]['streams'][0]['bytes'][0]/$proxy['sessions'][$crtSession]['duration']);
$_domains[$called_domain]['called'] += floor($proxy['sessions'][$crtSession]['streams'][0]['bytes'][1]/$proxy['sessions'][$crtSession]['duration']);
$_domains[$caller_domain]['traffic'] += $proxy['sessions'][$crtSession]['streams'][0]['bytes'][0];
$_domains[$called_domain]['traffic'] += $proxy['sessions'][$crtSession]['streams'][0]['bytes'][1];
}
}
return $_domains;
}
}
function normalizeBytes($bytes) {
$mb = $bytes/1024/1024.0;
$kb = $bytes/1024.0;
if ($mb >= 0.95) {
return sprintf("%.2fM", $mb);
} else if ($kb >= 1) {
return sprintf("%.2fk", $kb);
} else {
return sprintf("%d", $bytes);
}
}
function normalizeTraffic($traffic) {
// input is in bytes/second
$traffic = $traffic * 8;
$mb = $traffic/1024/1024.0;
$kb = $traffic/1024.0;
if ($mb >= 0.95) {
return sprintf("%.2fMbps", $mb);
} else if ($kb >= 1) {
return sprintf("%.2fkbps",$kb);
} else {
return sprintf("%dbps",$traffic);
}
}
function buildStatistics() {
system($this->generateMrtgConfigScript);
system($this->harvest_script);
system("mrtg $this->mrtgcfg_file");
}
function getOnlineTrend() {
$ips_old=array();
$ips_new=array();
$query="select count(*) as c from location";
$this->online_db->query($query);
$this->online_db->next_record();
$count_new=$this->online_db->f('c');
printf ("%d Contacts new registerd\n",$count_new);
$query="select count(*) as c from count_contacts";
$this->online_db->query($query);
$this->online_db->next_record();
$count_old=$this->online_db->f('c');
printf ("%d Contacts old registerd\n",$count_old);
$query="select * from online_ips";
dprint($query);
$this->online_db->query($query);
while ($this->online_db->next_record()) {
$els=explode(";",$this->online_db->f('ip'));
$ips_old[]=$els[0];
}
sort($ips_old);
printf ("%d IPs old registerd\n",count($ips_old));
$query="select distinct(SUBSTRING_INDEX(SUBSTRING_INDEX(contact, '@',-1),':',1))
as ip from location";
dprint($query);
$this->online_db->query($query);
while ($this->online_db->next_record()) {
$els=explode(";",$this->online_db->f('ip'));
$ips_new[]=$els[0];
}
sort($ips_new);
printf ("%d IPs new registerd\n",count($ips_new));
$left=array_diff($ips_old,$ips_new);
$join=array_diff($ips_new,$ips_old);
sort($left);
sort($join);
if (count($join)) {
printf ("%d IPs joined: ",count($join));
foreach ($join as $var) print "$var ";
print "\n";
}
if (count($left)) {
printf ("%d IPs left: ",count($left));
foreach ($left as $var) print "$var ";
print "\n";
}
//print_r($left);
$query="drop table if exists online_ips";
dprint($query);
$this->online_db->query($query);
$query="create table online_ips
select distinct(SUBSTRING_INDEX(SUBSTRING_INDEX(contact, '@',-1),':',1))
as ip from location";
dprint($query);
$this->online_db->query($query);
$query="drop table if exists count_contacts";
dprint($query);
$this->online_db->query($query);
$query="create table count_contacts
select count(*)a as c from location";
dprint($query);
$this->online_db->query($query);
//dprint_r($this->online);
}
}
?>
diff --git a/version b/version
index 711ee23..3d61389 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-4.7-2
+4.7-3

File Metadata

Mime Type
text/x-diff
Expires
Sat, Feb 1, 10:32 AM (22 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3488959
Default Alt Text
(24 KB)

Event Timeline