Get some information by AGI

Hi
I want to get some information from Asterisk by AGI:
1- Number of defined sip user
2- Number of defined logged sip user
3- Number of active users (users calling)

May five me some example ?

Thanks in advance

Why AGI?
Use: CLI>sip show peers
and if you want make some script to view registered users only or what you want.
For active users or calling users use: CLI>sip show channels.

One way to do it, if you use realtime, is to check the sip_buddies table; you will find the accounts
in there and the registration info such as the IP address. For who is calling, that depends on
how you handle the dial command (Agi?), but you maybe able to raise a flag when a user do so.

For what you want it would probably be better to try using the AMI.