SQL or API to determine number of calls ringing?

Is it possible to determine how many numbers are being dialed as well as whether there are calls waiting for agents by using MySQL OR API?
For example: Exactly the same feature as found in the Real-Time Main Report which looks like this:
1 calls ringing 1 calls waiting for agents
Cheers,
Paul
Vicibox 2.12-565a from vicibox_v7x68_65.iso | Vicidial 2.12-565a Build 160827-0917 | Asterisk 11.23.1-vici | Single Server | No Digium/Sangoma Hardware | No Extra Software After Installation | DELL R710 | Intel Xeon CPU X5690 @ 3.47Ghz 6 Cores
For example: Exactly the same feature as found in the Real-Time Main Report which looks like this:
1 calls ringing 1 calls waiting for agents
Cheers,
Paul
Vicibox 2.12-565a from vicibox_v7x68_65.iso | Vicidial 2.12-565a Build 160827-0917 | Asterisk 11.23.1-vici | Single Server | No Digium/Sangoma Hardware | No Extra Software After Installation | DELL R710 | Intel Xeon CPU X5690 @ 3.47Ghz 6 Cores