Created
April 19, 2017 14:51
-
-
Save xenithorb/f428aa893abbfa62a9b3325f659c0a87 to your computer and use it in GitHub Desktop.
Parse freeswitch log for DTMF codes and output a single string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
LOGFILE="/var/log/freeswitch/freeswitch.log*" | |
#LOGFILE="/usr/local/freeswitch/log/freeswitch.log*" | |
USER="centos" | |
REMOTE_ADDR="${1:?ERROR: No remote address provided}" | |
UUID="${2:?ERROR: No UUID provided}" | |
get_logs() { | |
"$SUDO" find "${LOGFILE%/*}" -type f -name "${LOGFILE##*/}" ! -empty | |
} | |
dtmf_extract() { | |
awk -F'[: ]' 'BEGIN{ ORS="" } /RTP RECV DTMF/ && /'$UUID'/ { print $12 }' | |
} | |
ssh -qtt "${USER}@${REMOTE_ADDR}" \ | |
" | |
# set -x; | |
LOGFILE=\"$LOGFILE\"; | |
UUID=\"$UUID\"; | |
SUDO=\"\$(command -v sudo)\"; | |
$(typeset -f dtmf_extract get_logs); | |
\$SUDO zcat -f \$(get_logs) | dtmf_extract; | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment