Billing system for two voip gateway

Hi,

I would like to implement a billing system for two voip gateway .
In one system would collect all the information about connections.
Below is a diagram. The four pbx-sip are in a LAN. Two of them have a outside interface by E1 links. And at the PBX-SIP (with access to the world) I would like to collect information about connections. What solution do you recommend?

Best Regards