Advertisement
Guest User

Untitled

a guest
May 26th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.04 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # HEP Server
  4. hepserver=127.0.0.1
  5. heport=9063
  6. hepid=199
  7. heptype=100
  8. localip=$(/sbin/ip -4 -o addr show dev eth0| awk '{split($4,a,"/");print a[1]}')
  9. syslogport=5514
  10.  
  11. script="tail -f -n 0 -q"
  12. netcat="nc -k -l ${syslogport}"
  13. command=$script
  14.  
  15. if ! [ $(which hepipe) ]; then
  16.     echo "ERROR: Please install HEPipe (https://github.com/sipcapture/hepipe)";
  17.     exit;
  18. fi
  19.  
  20. log="/usr/local/freeswitch/log/freeswitch.log"
  21. if [[ -f $log ]]; then
  22.     while read line
  23.     do
  24.         json_cdr=$(echo $line | grep /usr/local/freeswitch/log/json_cdr/ | sed 's/^.*\[\(.*\)\].*$/\1/')
  25.         size=${#json_cdr}
  26.  
  27.         if [[ $size != 0 ]]; then
  28.             logdate=$(echo $line | awk '{print $2, $3}')
  29.  
  30.             ts=$(date --date="$logdate" +%s)
  31.             tsu=$(date --date="$logdate" +%4N)
  32.  
  33.             echo $json_cdr
  34.             #echo "${ts};${tsu};${callid};${localip};${syslogport};${localip};${syslogport};${line}" | hepipe -s $hepserver -p $heport -i $hepid -t $heptype
  35.  
  36.         fi
  37.  
  38.     done < <($command $log)
  39. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement