diff --git a/scripts/normalize.php b/scripts/normalize.php index 805fe0f..86d6e5a 100644 --- a/scripts/normalize.php +++ b/scripts/normalize.php @@ -1,100 +1,112 @@ #!/usr/bin/php -db_class)) { - $db_class=$CDRS->db_class[0]; + if (is_array($CDRS->db_class)) { + $db_class = $CDRS->db_class[0]; } else { - $db_class=$CDRS->db_class; + $db_class = $CDRS->db_class; } - if ($table) $CDRS->table=$table; + if ($table) $CDRS->table=$table; - $log=sprintf("Normalize datasource %s, database %s, table %s\n",$k,$db_class,$CDRS->table); + $log = sprintf("Normalize datasource %s, database %s, table %s\n", $k, $db_class, $CDRS->table); print $log; - syslog(LOG_NOTICE,$log); + syslog(LOG_NOTICE, $log); $CDRS->NormalizeCDRS(); $e=time(); $d=$e-$b; if ($CDRS->status['cdr_to_normalize']) { $speed=0; - if ($d) $speed=number_format($CDRS->status['cdr_to_normalize']/$d,0,"",""); - $log=sprintf(" %d CDRs, %d normalized in %s s @ %s cps\n",$CDRS->status['cdr_to_normalize'],$CDRS->status['normalized'],$d,$speed); + if ($d) $speed = number_format($CDRS->status['cdr_to_normalize']/$d, 0, "", ""); + $log = sprintf( + " %d CDRs, %d normalized in %s s @ %s cps\n", + $CDRS->status['cdr_to_normalize'], + $CDRS->status['normalized'], + $d, + $speed + ); print $log; - syslog(LOG_NOTICE,$log); + syslog(LOG_NOTICE, $log); } - if (!$table && preg_match("/^(\w+)\d{6}$/",$CDRS->table,$m)) { - $lastMonthTable=$m[1].date('Ym', mktime(0, 0, 0, date("m")-1, "01", date("Y"))); + if (!$table && preg_match("/^(\w+)\d{6}$/", $CDRS->table, $m)) { + $lastMonthTable=$m[1].date('Ym', mktime(0, 0, 0, date("m")-1, "01", date("Y"))); - $log=sprintf("Normalize datasource %s, database %s, table %s\n",$k,$db_class,$lastMonthTable); + $log = sprintf("Normalize datasource %s, database %s, table %s\n", $k, $db_class, $lastMonthTable); print $log; - syslog(LOG_NOTICE,$log); + syslog(LOG_NOTICE, $log); - $b=time(); + $b=time(); - $CDRS->table=$lastMonthTable; + $CDRS->table = $lastMonthTable; $CDRS->NormalizeCDRS(); if ($CDRS->status['cdr_to_normalize']) { $e=time(); $d=$e-$b; $speed=0; - if ($d) $speed=number_format($CDRS->status['cdr_to_normalize']/$d,0,"",""); - $log=sprintf(" %d CDRs, %d normalized in %s s @ %s cps\n",$CDRS->status['cdr_to_normalize'],$CDRS->status['normalized'],$d,$speed); + if ($d) $speed = number_format($CDRS->status['cdr_to_normalize']/$d, 0, "", ""); + $log = sprintf( + " %d CDRs, %d normalized in %s s @ %s cps\n", + $CDRS->status['cdr_to_normalize'], + $CDRS->status['normalized'], + $d, + $speed + ); print $log; - syslog(LOG_NOTICE,$log); + syslog(LOG_NOTICE, $log); } } } } keepAliveRatingEngine(); ?>