[asterisk-dev] cdr manager not posted after hours

MELARGA COULIBALY melargacoulibaly at yahoo.fr
Fri Dec 14 10:38:19 CST 2007


Please Godson,
   
  As you advise, i write a perl script to handle cdr events but after hours, it seems to stop. But if i type the commande manager show connected on the CLI i seem my process manager user account.
  So i dont know what wrong. this is the main part of my perl script :
  //######### start of the script #################
  // * Note that i have asterisk 1.4.13 installed on my box
  //*
  &daemonize($path_daemon);
  &load_config();
  $dbh=&connect_db($dbip,$dataname,$datauser,$passcode);
  if (!$dbh) {
  $MSG="Database is unavailable. Try later.";
  myinfo($MSG);
  } 
  $timestamp = localdate(time);
  appendfile($LOG, "$timestamp [SERVICE MAGICRATE STARTED AND FORKED]\n");
  while(1){ 
  # test if program is disconnected from manager, reconnect to it
  if ($astman==undef) {
  $MSG="magicrate-server disconnected to manager, trying to reconnect...";
  $astman->connect || myinfo($MSG.$astman->error);
  }
   
  #Handle manager events
   
  
  %data=$astman->handleevent;
  # if two channels are linked, i-e a live call is answered
  if ($data{'Event'} eq 'Link')
  {
  }
  # if two channels are unlinked, i-e a live call is hangup ( event occur before final hangup)
  if ($data{'Event'} eq 'Unlink')
  {
  }
  # Peer status register/unregister
  if ($data{'Event'} eq 'PeerStatus')
  {
  }
  # Cdr Event 
  if ($data{'Event'} eq 'Cdr')
  {
  if (!$dbh) {
  $MSG="magicbill database not available, reconnecting...";
  myinfo($MSG);
  $dbh=&connect_db($dbip,$dataname,$datauser,$passcode);
  } else { 
  $number=&trim($data{'Destination'});
  $callerid=&trim($data{'AccountCode'});
  $answeredtime=$data{'BillableSeconds'};
  $callstart=&trim($data{'StartTime'});
  $dialstatus=&trim($data{'Disposition'});
  $number=substr($number,2,length($number)-2) if (substr($number,0,2) eq '00');
  $phoneno=$number;
  $trunk{outboundname}=&trim($data{'DestinationChannel'});
  &ret_srv();
  %acc=&acc_data();
  &getrates();
  &calccost();
  &savedata();
  &savecdr();
  &setinuse(0);appendfile($LOG, "$callstart : New Cdr receive\n");
  }
  }
  
  } 
   
  //#######" End##########//
   
  Thanks for your replies,
  Melarga

       
---------------------------------
 Yahoo! Mail : un mail innovant avec Messenger compatible Windows Live + stockage illimité.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20071214/de6223e9/attachment-0001.htm 


More information about the asterisk-dev mailing list