Multiple channels state

I want to get the states of currently connectd channels to an extension.

AMI or PAMI call required.

Need to determine who is on hold and who is in use.

(If there are multiple lines available for an extension).

Thanks
Jayantha