Group_count via AMI

who can we check goup_count via AMI ?

I am using Asterisk 1.6.

What is proper method to limit calls to the available number of channels ?

I planed to write a script outside asterisk which will check channel status/group count then make & move call file in spool directory. AM i in right direction ?