Unsolved Get active calls overtime
-
I need to track the active calls over time on an Asterisk based system.
I know that i can get the information from the asterisk command
core show channels
I know I can manually monitor it per second with
watch -n 1 "asterisk -x 'core show channels' | grep 'active calls'"
How can I get this logged to a file with the timestamp?
Setup a cron to run every second and append a file? something else?
-
Something like this?
#!/bin/bash ActiveCallDateTime=`date "+%Y%m%d_%H%M%S"` asterisk -x 'core show channels' | grep 'active calls' > activecalls-$ActiveCallDateTime.log
-
I can't think of a way aside from cron every X seconds. I'd dump it into a csv file with just the timestamp and the number of calls. E.g.
#!/bin/sh if [ ! -f /var/log/activecalls.csv ]; then echo "Timestamp,Calls" > /var/log/activecalls.csv fi DateTime=`date "+%Y%m%d %H:%M:%S"` echo -ne "\n$DateTime," >> /var/log/activecalls.csv asterisk -x 'core show channels' | grep 'active calls' | cut -d " " -f1
Which SHOULD create a nice csv for you...