Here is a quick and dirty bash script I threw together today to log the concurrent calls for each of my long distance trunks in Asterisk to a MySQL database to be able to quickly analyze usage trends. Sure there is probably other open-source software out there that can do this and give pretty little graphs and what not (cdr-stats or maybe queue metrics come to mind), but where’s the fun in that? As I mentioned, the script is extremely primitive (just the bare minimum as I didn’t have much time to spend on it) and contains no error checking whatsoever but it could also be used as a pretty handy one-liner in bash.
Show all active SIP Calls on a single trunk
asterisk -x "core show channels verbose" | grep "^SIP/yourSIPTrunkName-"
Show concurrent number of SIP Calls on a single trunk
asterisk -x "core show channels verbose" | grep -c "^SIP/yourSIPTrunkName-"
Show all active DAHDI calls on channels 1-24
Continue reading “Bash Script – Log Concurrent Asterisk Calls to MySQL and Other Useful One-Liners”