ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Unsolved Get active calls overtime

    IT Discussion
    asterisk cli logging
    3
    3
    477
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JaredBuschJ
      JaredBusch
      last edited by

      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 channelse4f3bb28-e729-4953-b638-b06fac82c7de-image.png

      I know I can manually monitor it per second with watch -n 1 "asterisk -x 'core show channels' | grep 'active calls'"

      ad34def4-e417-4ed5-a45e-c6205392f9c4-image.png

      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?

      1 Reply Last reply Reply Quote 0
      • black3dynamiteB
        black3dynamite
        last edited by

        Something like this?

        #!/bin/bash                                                                     
        ActiveCallDateTime=`date "+%Y%m%d_%H%M%S"`
        asterisk -x 'core show channels' | grep 'active calls' > activecalls-$ActiveCallDateTime.log
        
        1 Reply Last reply Reply Quote 2
        • M
          manxam
          last edited by manxam

          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...

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post